ReactOS  0.4.14-dev-115-g4576127
uxini.c File Reference
#include "uxthemep.h"
Include dependency graph for uxini.c:

Go to the source code of this file.

Classes

struct  _UXINI_FILE
 

Typedefs

typedef struct _UXINI_FILE UXINI_FILE
 
typedef struct _UXINI_FILEPUXINI_FILE
 

Functions

PUXINI_FILE UXINI_LoadINI (HMODULE hTheme, LPCWSTR lpName)
 
void UXINI_CloseINI (PUXINI_FILE uf)
 
static BOOL UXINI_eof (PUXINI_FILE uf)
 
static BOOL UXINI_isspace (WCHAR c)
 
static LPCWSTR UXINI_GetNextLine (PUXINI_FILE uf, DWORD *dwLen)
 
static void UXINI_UnGetToLine (PUXINI_FILE uf, LPCWSTR lpLine)
 
LPCWSTR UXINI_GetNextSection (PUXINI_FILE uf, DWORD *dwLen)
 
BOOL UXINI_FindSection (PUXINI_FILE uf, LPCWSTR lpName)
 
LPCWSTR UXINI_GetNextValue (PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen)
 
BOOL UXINI_FindValue (PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen)
 

Variables

static const WCHAR szTextFileResource []
 

Typedef Documentation

◆ PUXINI_FILE

◆ UXINI_FILE

Function Documentation

◆ UXINI_CloseINI()

void UXINI_CloseINI ( PUXINI_FILE  uf)

Definition at line 83 of file uxini.c.

84 {
85  HeapFree(GetProcessHeap(), 0, uf);
86 }
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by GetThemeDocumentationProperty(), and MSSTYLES_ParseThemeIni().

◆ UXINI_eof()

static BOOL UXINI_eof ( PUXINI_FILE  uf)
inlinestatic

Definition at line 96 of file uxini.c.

97 {
98  return uf->lpCurLoc >= uf->lpEnd;
99 }
LPCWSTR lpEnd
Definition: uxini.c:34
LPCWSTR lpCurLoc
Definition: uxini.c:33

Referenced by UXINI_GetNextLine().

◆ UXINI_FindSection()

BOOL UXINI_FindSection ( PUXINI_FILE  uf,
LPCWSTR  lpName 
)

Definition at line 200 of file uxini.c.

201 {
202  LPCWSTR lpSection;
203  DWORD dwLen;
204  while((lpSection = UXINI_GetNextSection(uf, &dwLen))) {
205  if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, lpSection, dwLen, lpName, -1) == CSTR_EQUAL) {
206  return TRUE;
207  }
208  }
209  return FALSE;
210 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ LPCSTR lpName
Definition: winbase.h:2736
#define NORM_IGNORECASE
Definition: winnls.h:173
LPCWSTR UXINI_GetNextSection(PUXINI_FILE uf, DWORD *dwLen)
Definition: uxini.c:173
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
#define LOCALE_SYSTEM_DEFAULT
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CSTR_EQUAL
Definition: winnls.h:453

Referenced by GetThemeDocumentationProperty().

◆ UXINI_FindValue()

BOOL UXINI_FindValue ( PUXINI_FILE  uf,
LPCWSTR  lpName,
LPCWSTR lpValue,
DWORD dwValueLen 
)

Definition at line 280 of file uxini.c.

281 {
282  LPCWSTR name;
283  DWORD namelen;
284 
285  while((name = UXINI_GetNextValue(uf, &namelen, lpValue, dwValueLen))) {
287  return TRUE;
288  }
289  }
290  return FALSE;
291 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ LPCSTR lpName
Definition: winbase.h:2736
#define NORM_IGNORECASE
Definition: winnls.h:173
GLint namelen
Definition: glext.h:7232
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
#define LOCALE_SYSTEM_DEFAULT
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CSTR_EQUAL
Definition: winnls.h:453
LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen)
Definition: uxini.c:226
Definition: name.c:36
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by GetThemeDocumentationProperty().

◆ UXINI_GetNextLine()

static LPCWSTR UXINI_GetNextLine ( PUXINI_FILE  uf,
DWORD dwLen 
)
static

Definition at line 129 of file uxini.c.

130 {
131  LPCWSTR lpLineEnd;
132  LPCWSTR lpLineStart;
133  DWORD len;
134  do {
135  if(UXINI_eof(uf)) return NULL;
136  /* Skip whitespace and empty lines */
137  while(!UXINI_eof(uf) && (UXINI_isspace(*uf->lpCurLoc) || *uf->lpCurLoc == '\n')) uf->lpCurLoc++;
138  lpLineStart = uf->lpCurLoc;
139  lpLineEnd = uf->lpCurLoc;
140  while(!UXINI_eof(uf) && *uf->lpCurLoc != '\n' && *uf->lpCurLoc != ';') lpLineEnd = ++uf->lpCurLoc;
141  /* If comment was found, skip the rest of the line */
142  if(*uf->lpCurLoc == ';')
143  while(!UXINI_eof(uf) && *uf->lpCurLoc != '\n') uf->lpCurLoc++;
144  len = (lpLineEnd - lpLineStart);
145  if(*lpLineStart != ';' && len == 0)
146  return NULL;
147  } while(*lpLineStart == ';');
148  /* Remove whitespace from end of line */
149  while(UXINI_isspace(lpLineStart[len-1])) len--;
150  *dwLen = len;
151 
152  return lpLineStart;
153 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpCurLoc
Definition: uxini.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
static BOOL UXINI_eof(PUXINI_FILE uf)
Definition: uxini.c:96
static BOOL UXINI_isspace(WCHAR c)
Definition: uxini.c:109

Referenced by UXINI_GetNextSection(), and UXINI_GetNextValue().

◆ UXINI_GetNextSection()

LPCWSTR UXINI_GetNextSection ( PUXINI_FILE  uf,
DWORD dwLen 
)

Definition at line 173 of file uxini.c.

174 {
175  LPCWSTR lpLine;
176  while((lpLine = UXINI_GetNextLine(uf, dwLen))) {
177  /* Assuming a ']' ending to the section name */
178  if(lpLine[0] == '[') {
179  lpLine++;
180  *dwLen -= 2;
181  break;
182  }
183  }
184  return lpLine;
185 }
static LPCWSTR UXINI_GetNextLine(PUXINI_FILE uf, DWORD *dwLen)
Definition: uxini.c:129
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by MSSTYLES_ParseThemeIni(), and UXINI_FindSection().

◆ UXINI_GetNextValue()

LPCWSTR UXINI_GetNextValue ( PUXINI_FILE  uf,
DWORD dwNameLen,
LPCWSTR lpValue,
DWORD dwValueLen 
)

Definition at line 226 of file uxini.c.

227 {
228  LPCWSTR lpLine;
229  LPCWSTR lpLineEnd;
230  LPCWSTR name = NULL;
231  LPCWSTR value = NULL;
232  DWORD vallen = 0;
233  DWORD namelen = 0;
234  DWORD dwLen;
235  lpLine = UXINI_GetNextLine(uf, &dwLen);
236  if(!lpLine)
237  return NULL;
238  if(lpLine[0] == '[') {
239  UXINI_UnGetToLine(uf, lpLine);
240  return NULL;
241  }
242  lpLineEnd = lpLine + dwLen;
243 
244  name = lpLine;
245  while(namelen < dwLen && *lpLine != '=') {
246  lpLine++;
247  namelen++;
248  }
249  if(*lpLine != '=') return NULL;
250  lpLine++;
251 
252  /* Remove whitespace from end of name */
253  while(UXINI_isspace(name[namelen-1])) namelen--;
254  /* Remove whitespace from beginning of value */
255  while(UXINI_isspace(*lpLine) && lpLine < lpLineEnd) lpLine++;
256  value = lpLine;
257  vallen = dwLen-(value-name);
258 
259  *dwNameLen = namelen;
260  *dwValueLen = vallen;
261  *lpValue = value;
262 
263  return name;
264 }
static LPCWSTR UXINI_GetNextLine(PUXINI_FILE uf, DWORD *dwLen)
Definition: uxini.c:129
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLint namelen
Definition: glext.h:7232
smooth NULL
Definition: ftsmooth.c:416
static void UXINI_UnGetToLine(PUXINI_FILE uf, LPCWSTR lpLine)
Definition: uxini.c:155
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: name.c:36
static BOOL UXINI_isspace(WCHAR c)
Definition: uxini.c:109
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by MSSTYLES_ParseThemeIni(), and UXINI_FindValue().

◆ UXINI_isspace()

static BOOL UXINI_isspace ( WCHAR  c)
inlinestatic

Definition at line 109 of file uxini.c.

110 {
111  if (isspace(c)) return TRUE;
112  if (c=='\r') return TRUE;
113  return FALSE;
114 }
#define isspace(c)
Definition: acclib.h:69
#define TRUE
Definition: types.h:120
const GLubyte * c
Definition: glext.h:8905

Referenced by UXINI_GetNextLine(), and UXINI_GetNextValue().

◆ UXINI_LoadINI()

PUXINI_FILE UXINI_LoadINI ( HMODULE  hTheme,
LPCWSTR  lpName 
)

Definition at line 52 of file uxini.c.

52  {
53  HRSRC hrsc;
54  LPCWSTR lpThemesIni = NULL;
55  PUXINI_FILE uf;
56  DWORD dwIniSize;
57 
58  TRACE("Loading resource INI %s\n", debugstr_w(lpName));
59 
60  if((hrsc = FindResourceW(hTheme, lpName, szTextFileResource))) {
61  if(!(lpThemesIni = LoadResource(hTheme, hrsc))) {
62  TRACE("%s resource not found\n", debugstr_w(lpName));
63  return NULL;
64  }
65  }
66 
67  dwIniSize = SizeofResource(hTheme, hrsc) / sizeof(WCHAR);
68  uf = HeapAlloc(GetProcessHeap(), 0, sizeof(UXINI_FILE));
69  uf->lpIni = lpThemesIni;
70  uf->lpCurLoc = lpThemesIni;
71  uf->lpEnd = lpThemesIni + dwIniSize;
72  return uf;
73 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ LPCSTR lpName
Definition: winbase.h:2736
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
#define debugstr_w
Definition: kernel32.h:32
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpEnd
Definition: uxini.c:34
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPCWSTR lpCurLoc
Definition: uxini.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPCWSTR lpIni
Definition: uxini.c:32
static const WCHAR szTextFileResource[]
Definition: uxini.c:27

Referenced by MSSTYLES_GetActiveThemeIni(), and MSSTYLES_GetThemeIni().

◆ UXINI_UnGetToLine()

static void UXINI_UnGetToLine ( PUXINI_FILE  uf,
LPCWSTR  lpLine 
)
inlinestatic

Definition at line 155 of file uxini.c.

156 {
157  uf->lpCurLoc = lpLine;
158 }
LPCWSTR lpCurLoc
Definition: uxini.c:33

Referenced by UXINI_GetNextValue().

Variable Documentation

◆ szTextFileResource

const WCHAR szTextFileResource[]
static
Initial value:
= {
'T','E','X','T','F','I','L','E','\0'
}

Definition at line 27 of file uxini.c.

Referenced by UXINI_LoadINI().