int strncmpiW( const WCHAR *str1, const WCHAR *str2, int n ) { int ret = 0; for ( ; n > 0; n--, str1++, str2++) if ((ret = tolowerW(*str1) - tolowerW(*str2)) || !*str1) break; return ret; }
int memicmpW( const WCHAR *str1, const WCHAR *str2, int n ) { int ret = 0; for ( ; n > 0; n--, str1++, str2++) if ((ret = tolowerW(*str1) - tolowerW(*str2))) break; return ret; }
uint64_t compat_wcstoui64(const wchar_t *nptr, wchar_t **endptr, int base) { BOOL negative = FALSE; uint64_t ret = 0; if(nptr == NULL || (base < 2 && base != 0) || base > 36) { errno = EINVAL; return 0; } while(iswspace(*nptr)) nptr++; if(*nptr == '-') { negative = TRUE; nptr++; } else if(*nptr == '+') nptr++; if((base==0 || base==16) && *nptr=='0' && tolowerW(*(nptr+1))=='x') { base = 16; nptr += 2; } if(base == 0) { if(*nptr=='0') base = 8; else base = 10; } while(*nptr) { wchar_t cur = tolowerW(*nptr); int v; if(iswdigit(cur)) { if(cur >= '0'+base) break; v = *nptr-'0'; } else { if(cur<L'a' || cur>=L'a'+base-10) break; v = cur-L'a'+10; } nptr++; if(ret>UINT64_MAX/base || ret*base>UINT64_MAX-v) { ret = UINT64_MAX; errno = ERANGE; } else ret = ret*base + v; } if(endptr) *endptr = (wchar_t*)nptr; return negative ? (uint64_t)(-(int64_t)ret) : ret; }
int strcmpiW( const WCHAR *str1, const WCHAR *str2 ) { for (;;) { int ret = tolowerW(*str1) - tolowerW(*str2); if (ret || !*str1) return ret; str1++; str2++; } }
/*********************************************************************** * CharLowerBuffW (USER32.@) */ DWORD WINAPI CharLowerBuffW( LPWSTR str, DWORD len ) { DWORD ret = len; if (!str) return 0; /* YES */ for (; len; len--, str++) *str = tolowerW(*str); return ret; }
/* * @implemented */ LPWSTR WINAPI CharLowerW(LPWSTR x) { if (HIWORD(x)) return strlwrW(x); else return (LPWSTR)((UINT_PTR)tolowerW(LOWORD(x))); }
static void WCEL_LowerCaseWord(WCEL_Context* ctx) { unsigned int new_ofs = WCEL_GetRightWordTransition(ctx, ctx->ofs); if (new_ofs != ctx->ofs) { unsigned int i; for (i = ctx->ofs; i <= new_ofs; i++) ctx->line[i] = tolowerW(ctx->line[i]); WCEL_Update(ctx, ctx->ofs, new_ofs - ctx->ofs + 1); ctx->ofs = new_ofs; } }
BOOLEAN STDCALL equal_unistr( IN const UNICODE_STRING *String1, IN const UNICODE_STRING *String2, IN BOOLEAN CaseInsensitive) { ULONG i; WCHAR wc1, wc2; PWCHAR pw1, pw2; if (String1->Length != String2->Length) return FALSE; pw1 = String1->Buffer; pw2 = String2->Buffer; for (i = 0; i < String1->Length / sizeof(WCHAR); i++) { if (CaseInsensitive == TRUE) { wc1 = UpcaseUnicodeChar (*pw1); wc2 = UpcaseUnicodeChar (*pw2); } else { wc1 = tolowerW(*pw1); wc2 = tolowerW(*pw2); } if (wc1 != wc2) return FALSE; pw1++; pw2++; } return TRUE; }
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) { const WCHAR *p1 = ctx->ptr; const WCHAR *p2 = word; WCHAR c; while(p1 < ctx->end && *p2) { c = tolowerW(*p1); if(c != *p2) return c - *p2; p1++; p2++; } if(*p2 || (p1 < ctx->end && is_identifier_char(*p1))) return 1; ctx->ptr = p1; return 0; }
static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) { const WCHAR *loader = get_wine_loader_name(); const WCHAR *ptr, *endptr; size_t len, l; ptr = get_filename(in, endptr = in + strlenW(in)); len = min(endptr - ptr, size - 1); memcpy(out, ptr, len * sizeof(WCHAR)); out[len] = '\0'; if (len > 4 && (l = match_ext(out, len))) out[len - l] = '\0'; else if (len > strlenW(loader) && !strcmpiW(out + len - strlenW(loader), loader)) lstrcpynW(out, S_WineLoaderW, size); else { if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) strcpyW(&out[len - l - 3], S_ElfW); } while ((*out = tolowerW(*out))) out++; }
/****************************************************************** * _wcslwr_s (MSVCRT.@) */ int CDECL MSVCRT__wcslwr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n ) { MSVCRT_wchar_t* ptr = str; if (!str || !n) { if (str) *str = '\0'; *MSVCRT__errno() = MSVCRT_EINVAL; return MSVCRT_EINVAL; } while (n--) { if (!*ptr) return 0; *ptr = tolowerW(*ptr); ptr++; } /* MSDN claims that the function should return and set errno to * ERANGE, which doesn't seem to be true based on the tests. */ *str = '\0'; *MSVCRT__errno() = MSVCRT_EINVAL; return MSVCRT_EINVAL; }
int wmain(int argc, WCHAR* argv[]) { int i, res, ret = 0; BOOL CallRegister = TRUE; BOOL CallInstall = FALSE; BOOL Unregister = FALSE; BOOL DllFound = FALSE; WCHAR* wsCommandLine = NULL; WCHAR EmptyLine[1] = {0}; OleInitialize(NULL); /* We mirror the Microsoft version by processing all of the flags before * the files (e.g. regsvr32 file1 /s file2 is silent even for file1). * * Note the complication that this version may be passed Unix format filenames * which could be mistaken for flags. The Windows version conveniently * requires each flag to be separate (e.g. no /su), so we will simply * assume that anything longer than /. is a filename. */ for(i = 1; i < argc; i++) { if (argv[i][0] == '/' || argv[i][0] == '-') { if (!argv[i][1]) return INVALID_ARG; if (argv[i][2] && argv[i][2] != ':') continue; switch (tolowerW(argv[i][1])) { case 'u': Unregister = TRUE; break; case 's': Silent = TRUE; break; case 'i': CallInstall = TRUE; wsCommandLine = parse_command_line(argv[i] + 2); /* argv[i] + strlen("/i") */ if (!wsCommandLine) wsCommandLine = EmptyLine; break; case 'n': CallRegister = FALSE; break; case 'c': /* console output */; break; default: output_write(STRING_UNRECOGNIZED_SWITCH, argv[i]); output_write(STRING_USAGE); return INVALID_ARG; } argv[i] = NULL; } } if (!CallInstall && !CallRegister) /* flags: /n or /u /n */ return INVALID_ARG; for (i = 1; i < argc; i++) { if (argv[i]) { WCHAR *DllName = argv[i]; res = 0; DllFound = TRUE; if (CallInstall && Unregister) res = InstallDll(!Unregister, DllName, wsCommandLine); /* The Windows version stops processing the current file on the first error. */ if (res) { ret = res; continue; } if (!CallInstall || (CallInstall && CallRegister)) { if(Unregister) res = UnregisterDll(DllName); else res = RegisterDll(DllName); } if (res) { ret = res; continue; } if (CallInstall && !Unregister) res = InstallDll(!Unregister, DllName, wsCommandLine); if (res) { ret = res; continue; } } } if (!DllFound) { output_write(STRING_HEADER); output_write(STRING_USAGE); return INVALID_ARG; } OleUninitialize(); /* return the most recent error code, even if later DLLs succeed */ return ret; }
/********************************************************************* * towlower (NTDLL.@) */ WCHAR __cdecl NTDLL_towlower( WCHAR ch ) { return tolowerW(ch); }
static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *reg_count) { static const WCHAR empty; LPBYTE out_data = NULL; *reg_count = 0; if (!data) data = ∅ switch (reg_type) { case REG_NONE: case REG_SZ: case REG_EXPAND_SZ: { *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR); out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); lstrcpyW((LPWSTR)out_data,data); break; } case REG_DWORD: /* case REG_DWORD_LITTLE_ENDIAN: */ case REG_DWORD_BIG_ENDIAN: /* Yes, this is correct! */ { LPWSTR rest; DWORD val; val = strtoulW(data, &rest, (tolowerW(data[1]) == 'x') ? 16 : 10); if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) { output_message(STRING_MISSING_INTEGER); break; } *reg_count = sizeof(DWORD); out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); ((LPDWORD)out_data)[0] = val; break; } case REG_BINARY: { BYTE hex0, hex1; int i = 0, destByteIndex = 0, datalen = lstrlenW(data); *reg_count = ((datalen + datalen % 2) / 2) * sizeof(BYTE); out_data = HeapAlloc(GetProcessHeap(), 0, *reg_count); if(datalen % 2) { hex1 = hexchar_to_byte(data[i++]); if(hex1 == 0xFF) goto no_hex_data; out_data[destByteIndex++] = hex1; } for(;i + 1 < datalen;i += 2) { hex0 = hexchar_to_byte(data[i]); hex1 = hexchar_to_byte(data[i + 1]); if(hex0 == 0xFF || hex1 == 0xFF) goto no_hex_data; out_data[destByteIndex++] = (hex0 << 4) | hex1; } break; no_hex_data: /* cleanup, print error */ HeapFree(GetProcessHeap(), 0, out_data); output_message(STRING_MISSING_HEXDATA); out_data = NULL; break; } case REG_MULTI_SZ: { int i, destindex, len = strlenW(data); WCHAR *buffer = HeapAlloc(GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR)); for (i = 0, destindex = 0; i < len; i++, destindex++) { if (!separator && data[i] == '\\' && data[i + 1] == '0') { buffer[destindex] = 0; i++; } else if (data[i] == separator) buffer[destindex] = 0; else buffer[destindex] = data[i]; if (destindex && !buffer[destindex - 1] && (!buffer[destindex] || destindex == 1)) { HeapFree(GetProcessHeap(), 0, buffer); output_message(STRING_INVALID_STRING); return NULL; } } buffer[destindex] = 0; if (destindex && buffer[destindex - 1]) buffer[++destindex] = 0; *reg_count = (destindex + 1) * sizeof(WCHAR); return (BYTE *)buffer; } default: output_message(STRING_UNHANDLED_TYPE, reg_type, data); } return out_data; }