43#include "wine/unicode.h"
51static const char bom_utf8[] = {0xEF,0xBB,0xBF};
86#define N_CACHED_PROFILES 10
91#define CurProfile (MRUProfile[0])
94#define IS_ENTRY_COMMENT(str) ((str)[0] == ';')
117 0, 0, { (
DWORD_PTR)(__FILE__
": PROFILE_CritSect") }
123static const char hex[16] =
"0123456789ABCDEF";
138 if (strip_quote && ((*
value ==
'\'') || (*
value ==
'\"')))
159 DWORD dwBytesWritten;
182 int write_buffer_len;
183 DWORD dwBytesWritten;
192 if (!write_buffer)
return;
200 if (!write_buffer)
return;
288 next_key =
key->next;
339 const WCHAR *szLineStart, *szLineEnd;
340 const WCHAR *szValueStart, *szEnd, *next_line;
354 if (!buffer_base)
return NULL;
371 TRACE(
"ANSI encoding\n");
381 szEnd = szFile +
len;
384 TRACE(
"UTF8 encoding\n");
394 szEnd = szFile +
len;
397 TRACE(
"UTF16 Little Endian encoding\n");
402 TRACE(
"UTF16 Big Endian encoding\n");
408 FIXME(
"encoding type %d not implemented\n", *pEncoding);
414 if(first_section ==
NULL)
421 first_section->
name[0] = 0;
424 next_section = &first_section->
next;
425 next_key = &first_section->
key;
429 while (next_line < szEnd)
431 szLineStart = next_line;
432 next_line =
memchrW(szLineStart,
'\n', szEnd - szLineStart);
433 if (!next_line) next_line =
memchrW(szLineStart,
'\r', szEnd - szLineStart);
434 if (!next_line) next_line = szEnd;
436 szLineEnd = next_line;
441 while (szLineStart < szLineEnd &&
PROFILE_isspaceW(*szLineStart)) szLineStart++;
442 while ((szLineEnd > szLineStart) &&
PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--;
444 if (szLineStart >= szLineEnd)
continue;
446 if (*szLineStart ==
'[')
448 const WCHAR * szSectionEnd;
449 if (!(szSectionEnd =
memrchrW( szLineStart,
']', szLineEnd - szLineStart )))
451 WARN(
"Invalid section header at line %d: %s\n",
457 len = (
int)(szSectionEnd - szLineStart);
479 len = szLineEnd - szLineStart;
480 if ((szValueStart =
memchrW( szLineStart,
'=', szLineEnd - szLineStart )) !=
NULL)
482 const WCHAR *szNameEnd = szValueStart;
483 while ((szNameEnd > szLineStart) &&
PROFILE_isspaceW(szNameEnd[-1])) szNameEnd--;
484 len = szNameEnd - szLineStart;
486 while (szValueStart < szLineEnd &&
PROFILE_isspaceW(*szValueStart)) szValueStart++;
489 if (
len || !prev_key || *prev_key->
name)
498 len = (
int)(szLineEnd - szValueStart);
507 next_key = &
key->next;
511 TRACE(
"New key: name=%s, value=%s\n",
515 TRACE(
"New key: name=%s, value=%s\n",
523 return first_section;
560 if (!
strcmpiW( (*section)->name, section_name ))
592 if (!
strcmpiW( (*section)->name, section_name ))
618 int seclen = 0, keylen = 0;
623 p = section_name +
strlenW(section_name) - 1;
625 seclen =
p - section_name + 1;
638 if (!
strncmpiW((*section)->name, section_name, seclen) &&
639 ((*section)->name)[seclen] ==
'\0')
653 && (((*key)->name)[keylen] ==
'\0') )
662 (*key)->value =
NULL;
671 strcpyW( (*section)->name, section_name );
672 (*section)->next =
NULL;
680 (*section)->key->value =
NULL;
682 return (*section)->key;
698 WARN(
"No current profile!\n");
756 TRACE(
"%08x;%08x\n",(
unsigned)ftll+21000000,(
unsigned)nowll);
757 return ftll + 21000000 < nowll;
773 ZeroMemory(&LastWriteTime,
sizeof(LastWriteTime));
799 static const WCHAR wszSeparator[] = {
'\\', 0};
843 TRACE(
"(%s): already opened (mru=%d)\n",
847 TRACE(
"(%s): already opened, needs refreshing (mru=%d)\n",
856 else TRACE(
"(%s): already opened, not yet created (mru=%d)\n",
922 if (!return_values && !
key->
value)
continue;
980 if (tmplen >= buflen) {
1030 static const WCHAR empty_strW[] = { 0 };
1034 if (!def_val) def_val = empty_strW;
1040 TRACE(
"(%s,%s,%s): returning %s\n",
1088 TRACE(
"(%s,%s,%s):\n",
1100 TRACE(
" no change needed\n" );
1106 else TRACE(
" creating key\n" );
1158 while (
p > def_val && *
p ==
' ')
1163 int vlen = (
int)(
p - def_val) + 1;
1166 memcpy(defval_tmp, def_val, vlen *
sizeof(
WCHAR));
1167 defval_tmp[vlen] =
'\0';
1168 def_val = defval_tmp;
1180 }
else if (
buffer && def_val) {
1403 if (retW ==
len * 2 - 2) retW++;
1532 while(*
string &&
ret) {
1567 lenA =
p -
string + 1;
1716 for (
p=
k->value;
p <
end;
p++)
1720 WARN(
"invalid char '%x' in file %s->[%s]->%s !\n",
1734 for (
p=
k->value;
p <
end;
p++)
1738 (
c -
'A' + 10) : (
c -
'0');
1752 b = ( (
c >
'9') ? (
c -
'A' + 10) : (
c -
'0') ) << 4;
1754 b += (
c >
'9') ? (
c -
'A' + 10) : (
c -
'0');
1812 *
p++ =
hex[*binbuf >> 4];
1813 *
p++ =
hex[*binbuf & 0xf];
1817 *
p++ =
hex[(
sum & 0xf0) >> 4];
1866 FIXME(
"(), stub!\n");
1875 FIXME(
"(), stub!\n");
#define DECLSPEC_HOTPATCH
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
#define DEBUG_CHANNEL(args)
static const WCHAR quote[]
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
#define FILE_ATTRIBUTE_NORMAL
#define WideCharToMultiByte
#define MultiByteToWideChar
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
DWORD WINAPI GetPrivateProfileSectionNamesW(LPWSTR buffer, DWORD size, LPCWSTR filename)
static void PROFILE_DeleteAllKeys(LPCWSTR section_name)
BOOL WINAPI WriteProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string)
static INT PROFILE_GetSection(PROFILESECTION *section, LPCWSTR section_name, LPWSTR buffer, UINT len, BOOL return_values)
static INT PROFILE_GetString(LPCWSTR section, LPCWSTR key_name, LPCWSTR def_val, LPWSTR buffer, UINT len)
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
UINT WINAPI GetProfileIntA(LPCSTR section, LPCSTR entry, INT def_val)
BOOL WINAPI WriteProfileSectionA(LPCSTR section, LPCSTR keys_n_values)
static BOOL PROFILE_Open(LPCWSTR filename, BOOL write_access)
static BOOL PROFILE_DeleteSection(PROFILESECTION **section, LPCWSTR name)
BOOL WINAPI WriteProfileSectionW(LPCWSTR section, LPCWSTR keys_n_values)
static PROFILESECTION * PROFILE_Load(HANDLE hFile, ENCODING *pEncoding)
static void PROFILE_ByteSwapShortBuffer(WCHAR *buffer, int len)
INT WINAPI GetPrivateProfileSectionA(LPCSTR section, LPSTR buffer, DWORD len, LPCSTR filename)
BOOL WINAPI WritePrivateProfileStructA(LPCSTR section, LPCSTR key, LPVOID buf, UINT bufsize, LPCSTR filename)
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
static BOOL PROFILE_FlushFile(void)
static BOOL is_not_current(FILETIME *ft)
#define N_CACHED_PROFILES
BOOL WINAPI OpenProfileUserMapping(void)
static void PROFILE_Save(HANDLE hFile, const PROFILESECTION *section, ENCODING encoding)
struct tagPROFILEKEY PROFILEKEY
static CRITICAL_SECTION_DEBUG critsect_debug
static BOOL PROFILE_SetString(LPCWSTR section_name, LPCWSTR key_name, LPCWSTR value, BOOL create_always)
static const WCHAR emptystringW[]
struct tagPROFILESECTION PROFILESECTION
BOOL WINAPI WritePrivateProfileSectionA(LPCSTR section, LPCSTR string, LPCSTR filename)
static ENCODING PROFILE_DetectTextEncoding(const void *buffer, int *len)
INT WINAPI GetProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len)
INT WINAPI GetPrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len, LPCSTR filename)
DWORD WINAPI GetPrivateProfileSectionNamesA(LPSTR buffer, DWORD size, LPCSTR filename)
static const char bom_utf8[]
static CRITICAL_SECTION PROFILE_CritSect
INT WINAPI GetProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len)
BOOL WINAPI WritePrivateProfileStructW(LPCWSTR section, LPCWSTR key, LPVOID buf, UINT bufsize, LPCWSTR filename)
static void PROFILE_WriteMarker(HANDLE hFile, ENCODING encoding)
static void PROFILE_ReleaseFile(void)
INT WINAPI GetProfileSectionA(LPCSTR section, LPSTR buffer, DWORD len)
#define IS_ENTRY_COMMENT(str)
static void PROFILE_WriteLine(HANDLE hFile, WCHAR *szLine, int len, ENCODING encoding)
static PROFILE * MRUProfile[N_CACHED_PROFILES]
static const WCHAR wininiW[]
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
BOOL WINAPI CloseProfileUserMapping(void)
static void PROFILE_CopyEntry(LPWSTR buffer, LPCWSTR value, int len, BOOL strip_quote)
INT WINAPI GetPrivateProfileSectionW(LPCWSTR section, LPWSTR buffer, DWORD len, LPCWSTR filename)
static BOOL PROFILE_DeleteKey(PROFILESECTION **section, LPCWSTR section_name, LPCWSTR key_name)
INT WINAPI GetProfileSectionW(LPCWSTR section, LPWSTR buffer, DWORD len)
static void PROFILE_Free(PROFILESECTION *section)
static INT PROFILE_GetSectionNames(LPWSTR buffer, UINT len)
BOOL WINAPI WritePrivateProfileSectionW(LPCWSTR section, LPCWSTR string, LPCWSTR filename)
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
static BOOL PROFILE_isspaceW(WCHAR c)
BOOL WINAPI GetPrivateProfileStructA(LPCSTR section, LPCSTR key, LPVOID buffer, UINT len, LPCSTR filename)
static PROFILEKEY * PROFILE_Find(PROFILESECTION **section, LPCWSTR section_name, LPCWSTR key_name, BOOL create, BOOL create_always)
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
BOOL WINAPI GetPrivateProfileStructW(LPCWSTR section, LPCWSTR key, LPVOID buf, UINT len, LPCWSTR filename)
UINT WINAPI GetProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val)
static const char hex[16]
BOOL WINAPI WriteProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
static const WCHAR stringW[]
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLsizei bufsize
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
WINE_UNICODE_INLINE WCHAR * memrchrW(const WCHAR *ptr, WCHAR ch, size_t n)
WINE_UNICODE_INLINE WCHAR * memchrW(const WCHAR *ptr, WCHAR ch, size_t n)
static u32_t chksum(void *dataptr, u16_t len)
#define memcpy(s1, s2, n)
#define ERROR_FILE_NOT_FOUND
static const WCHAR filenameW[]
static const struct access_res create[16]
NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode(_In_ CONST VOID *Buffer, _In_ INT Size, _Inout_opt_ INT *Flags)
NTSYSAPI RTL_PATH_TYPE NTAPI RtlDetermineDosPathNameType_U(_In_ PCWSTR Path)
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
#define FILE_SHARE_DELETE
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static int sum(int x_, int y_)
#define strncmpiW(s1, s2, n)
LIST_ENTRY ProcessLocksList
struct tagPROFILEKEY * next
struct tagPROFILESECTION * next
struct tagPROFILEKEY * key
DWORD WINAPI GetLastError(void)
#define INVALID_FILE_SIZE
#define IS_TEXT_UNICODE_ODD_LENGTH
#define IS_TEXT_UNICODE_REVERSE_SIGNATURE
#define IS_TEXT_UNICODE_SIGNATURE
#define RtlUshortByteSwap(_x)