STDCALL long RtlCompareUnicodeString(const struct ustring *s1, const struct ustring *s2, int CaseInsensitive ) { unsigned int len; long ret = 0; const char *p1, *p2; len = min(s1->len, s2->len) / sizeof(__u16); p1 = s1->buf; p2 = s2->buf; if (CaseInsensitive) { while (!ret && len--) ret = toupperW(*p1++) - toupperW(*p2++); } else { while (!ret && len--) ret = *p1++ - *p2++; } if (!ret) ret = s1->len - s2->len; return ret; }
/* compare an ASCII and a Unicode string without depending on the current codepage */ static inline int strncmpiAW( const char *strA, const WCHAR *strW, int n ) { int ret = 0; for ( ; n > 0; n--, strA++, strW++) if ((ret = toupperW((unsigned char)*strA) - toupperW(*strW)) || !*strA) break; return ret; }
/****************************************************************************** * DnsNameCompare_W [DNSAPI.@] * */ BOOL WINAPI DnsNameCompare_W( LPWSTR name1, LPWSTR name2 ) { WCHAR *p, *q; TRACE( "(%s,%s)\n", debugstr_w(name1), debugstr_w(name2) ); if (!name1 && !name2) return TRUE; if (!name1 || !name2) return FALSE; p = name1 + lstrlenW( name1 ) - 1; q = name2 + lstrlenW( name2 ) - 1; while (*p == '.' && p >= name1) p--; while (*q == '.' && q >= name2) q--; if (p - name1 != q - name2) return FALSE; while (name1 <= p) { if (toupperW( *name1 ) != toupperW( *name2 )) return FALSE; name1++; name2++; } return TRUE; }
/*************************************************************************** * remove_dll_ext * * Remove extension if it is ".dll". */ static inline void remove_dll_ext( WCHAR *ext ) { if (ext[0] == '.' && toupperW(ext[1]) == 'D' && toupperW(ext[2]) == 'L' && toupperW(ext[3]) == 'L' && !ext[4]) ext[0] = 0; }
/*********************************************************************** * CharUpperBuffW (USER32.@) */ DWORD WINAPI CharUpperBuffW( LPWSTR str, DWORD len ) { DWORD ret = len; if (!str) return 0; /* YES */ for (; len; len--, str++) *str = toupperW(*str); return ret; }
/* * @implemented */ LPWSTR WINAPI CharUpperW(LPWSTR x) { if (HIWORD(x)) return struprW(x); else return (LPWSTR)((UINT_PTR)toupperW(LOWORD(x))); }
/****************************************************************** * _wcsupr_s_l (MSVCRT.@) */ int CDECL MSVCRT__wcsupr_s_l( MSVCRT_wchar_t* str, MSVCRT_size_t n, MSVCRT__locale_t locale ) { 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; /* FIXME: add locale support */ *ptr = toupperW(*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; }
static LPCWSTR COMM_ParseParity(LPCWSTR ptr, LPBYTE lpparity) { /* Contrary to what you might expect, Windows only sets the Parity member of DCB and not fParity even when parity is specified in the device control string */ switch(toupperW(*ptr++)) { case 'E': *lpparity = EVENPARITY; break; case 'M': *lpparity = MARKPARITY; break; case 'N': *lpparity = NOPARITY; break; case 'O': *lpparity = ODDPARITY; break; case 'S': *lpparity = SPACEPARITY; break; default: return NULL; } return ptr; }
/****************************************************************************** * ItemMonikerIROTData_GetComparisonData ******************************************************************************/ static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData, ULONG cbMax, ULONG* pcbData) { ItemMonikerImpl *This = impl_from_IROTData(iface); int len = (strlenW(This->itemName)+1); int i; LPWSTR pszItemName; LPWSTR pszItemDelimiter; TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData); *pcbData = sizeof(CLSID) + sizeof(WCHAR) + len * sizeof(WCHAR); if (cbMax < *pcbData) return E_OUTOFMEMORY; /* write CLSID */ memcpy(pbData, &CLSID_ItemMoniker, sizeof(CLSID)); /* write delimiter */ pszItemDelimiter = (LPWSTR)(pbData+sizeof(CLSID)); *pszItemDelimiter = *This->itemDelimiter; /* write name */ pszItemName = pszItemDelimiter + 1; for (i = 0; i < len; i++) pszItemName[i] = toupperW(This->itemName[i]); return S_OK; }
/* ask_confirm() adapted from programs/cmd/builtins.c */ static BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info) { HMODULE hmod; WCHAR Ybuffer[4]; WCHAR Nbuffer[4]; WCHAR defval[32]; WCHAR answer[MAX_PATH]; DWORD count; hmod = GetModuleHandleW(NULL); LoadStringW(hmod, STRING_YES, Ybuffer, ARRAY_SIZE(Ybuffer)); LoadStringW(hmod, STRING_NO, Nbuffer, ARRAY_SIZE(Nbuffer)); LoadStringW(hmod, STRING_DEFAULT_VALUE, defval, ARRAY_SIZE(defval)); while (1) { output_message(msgid, reg_info ? reg_info : defval); output_message(STRING_YESNO); ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), answer, ARRAY_SIZE(answer), &count, NULL); answer[0] = toupperW(answer[0]); if (answer[0] == Ybuffer[0]) return TRUE; if (answer[0] == Nbuffer[0]) return FALSE; } }
/********************************************************************* * _getdrive (MSVCRT.@) * * Get the current drive number. * * PARAMS * None. * * RETURNS * Success: The drive letter number from 1 to 26 ("A:" to "Z:"). * Failure: 0. */ int CDECL MSVCRT__getdrive(void) { WCHAR buffer[MAX_PATH]; if (GetCurrentDirectoryW( MAX_PATH, buffer ) && buffer[0] >= 'A' && buffer[0] <= 'z' && buffer[1] == ':') return toupperW(buffer[0]) - 'A' + 1; return 0; }
/************************************************************************* * StrChrIW [COMCTL32.367] * * See StrChrA. */ LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch) { TRACE("(%s,%i)\n", debugstr_w(lpszStr), ch); if (lpszStr) { ch = toupperW(ch); while (*lpszStr) { if (toupperW(*lpszStr) == ch) return (LPWSTR)lpszStr; lpszStr++; } lpszStr = NULL; } return (LPWSTR)lpszStr; }
/*********************************************************************** * GetTempDrive (KERNEL.92) * A closer look at krnl386.exe shows what the SDK doesn't mention: * * returns: * AL: driveletter * AH: ':' - yes, some kernel code even does stosw with * the returned AX. * DX: 1 for success */ UINT WINAPI GetTempDrive( BYTE ignored ) { WCHAR buffer[8]; BYTE ret; if (GetTempPathW( 8, buffer )) ret = (BYTE)toupperW(buffer[0]); else ret = 'C'; return MAKELONG( ret | (':' << 8), 1 ); }
static void WCEL_UpperCaseWord(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] = toupperW(ctx->line[i]); WCEL_Update(ctx, ctx->ofs, new_ofs - ctx->ofs + 1); ctx->ofs = new_ofs; } }
static BOOL is_full_path( const WCHAR *path ) { WCHAR first = toupperW(path[0]); BOOL ret; if (first >= 'A' && first <= 'Z' && path[1] == ':') ret = TRUE; else if (path[0] == '\\' && path[1] == '\\') ret = TRUE; else ret = FALSE; return ret; }
static BOOL ACTION_IsFullPath(LPCWSTR path) { WCHAR first = toupperW(path[0]); BOOL ret; if (first >= 'A' && first <= 'Z' && path[1] == ':') ret = TRUE; else if (path[0] == '\\' && path[1] == '\\') ret = TRUE; else ret = FALSE; return ret; }
/****************************************************************** * SymMatchFileNameW (DBGHELP.@) * */ BOOL WINAPI SymMatchFileNameW(PCWSTR file, PCWSTR match, PWSTR* filestop, PWSTR* matchstop) { PCWSTR fptr; PCWSTR mptr; TRACE("(%s %s %p %p)\n", debugstr_w(file), debugstr_w(match), filestop, matchstop); fptr = file + strlenW(file) - 1; mptr = match + strlenW(match) - 1; while (fptr >= file && mptr >= match) { if (toupperW(*fptr) != toupperW(*mptr) && !(is_sepW(*fptr) && is_sepW(*mptr))) break; fptr--; mptr--; } if (filestop) *filestop = (PWSTR)fptr; if (matchstop) *matchstop = (PWSTR)mptr; return mptr == match - 1; }
/****************************************************************************** * ItemMoniker_Hash ******************************************************************************/ static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) { ItemMonikerImpl *This = impl_from_IMoniker(iface); DWORD h = 0; int i,len; int off = 0; LPOLESTR val; if (pdwHash==NULL) return E_POINTER; val = This->itemName; len = lstrlenW(val); for (i = len ; i > 0; i--) h = (h * 3) ^ toupperW(val[off++]); *pdwHash=h; return S_OK; }
/****************************************************************************** * FileMonikerIROTData_GetComparisonData */ static HRESULT WINAPI FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData, ULONG cbMax, ULONG* pcbData) { FileMonikerImpl *This = impl_from_IROTData(iface); int len = strlenW(This->filePathName)+1; int i; LPWSTR pszFileName; TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData); *pcbData = sizeof(CLSID) + len * sizeof(WCHAR); if (cbMax < *pcbData) return E_OUTOFMEMORY; memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID)); pszFileName = (LPWSTR)(pbData+sizeof(CLSID)); for (i = 0; i < len; i++) pszFileName[i] = toupperW(This->filePathName[i]); return S_OK; }
/* Create Unicode upper-cased copy */ static WCHAR *RES_GetUnicodeName (LPCSTR pName, BOOL bUnicode) { LPWSTR pNameW; unsigned int i, Len; if (!bUnicode) { pNameW = HEAP_strdupAtoW (GetProcessHeap (), 0, pName); if (!pNameW) { ERR ("Out of memory!\n"); return NULL; } Len = strlenW (pNameW); } else { Len = strlenW ((LPWSTR)pName); pNameW = HeapAlloc (GetProcessHeap (), 0, (Len + 1) * sizeof (WCHAR)); if (!pNameW) { ERR ("Out of memory!\n"); return NULL; } memcpy (pNameW, pName, (Len + 1) * sizeof (WCHAR)); } for (i = 0; i < Len; i++) pNameW[i] = toupperW (pNameW[i]); pNameW[Len] = 0; return pNameW; }
/****************************************************************** * _wcsupr_s (MSVCRT.@) * */ INT CDECL _wcsupr_s( wchar_t* str, size_t n ) { wchar_t* ptr = str; if (!str || !n) { if (str) *str = '\0'; _set_errno(EINVAL); return EINVAL; } while (n--) { if (!*ptr) return 0; *ptr = toupperW(*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'; _set_errno(EINVAL); return EINVAL; }
/********************************************************************* * towupper (NTDLL.@) */ WCHAR __cdecl NTDLL_towupper( WCHAR ch ) { return toupperW(ch); }
long int strtolW( const WCHAR *nptr, WCHAR **endptr, int base ) { int negative; register unsigned long int cutoff; register unsigned int cutlim; register unsigned long int i; register const WCHAR *s; register WCHAR c; const WCHAR *save, *end; int overflow; if (base < 0 || base == 1 || base > 36) return 0; save = s = nptr; /* Skip white space. */ while (isspaceW (*s)) ++s; if (!*s) goto noconv; /* Check for a sign. */ negative = 0; if (*s == '-') { negative = 1; ++s; } else if (*s == '+') ++s; /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ if (*s == '0') { if ((base == 0 || base == 16) && toupperW(s[1]) == 'X') { s += 2; base = 16; } else if (base == 0) base = 8; } else if (base == 0) base = 10; /* Save the pointer so we can check later if anything happened. */ save = s; end = NULL; cutoff = ULONG_MAX / (unsigned long int) base; cutlim = ULONG_MAX % (unsigned long int) base; overflow = 0; i = 0; c = *s; for (;c != '\0'; c = *++s) { if (s == end) break; if (c >= '0' && c <= '9') c -= '0'; else if (isalphaW (c)) c = toupperW (c) - 'A' + 10; else break; if ((int) c >= base) break; /* Check for overflow. */ if (i > cutoff || (i == cutoff && c > cutlim)) overflow = 1; else { i *= (unsigned long int) base; i += c; } } /* Check if anything actually happened. */ if (s == save) goto noconv; /* Store in ENDPTR the address of one character past the last character we converted. */ if (endptr != NULL) *endptr = (WCHAR *)s; /* Check for a value that is within the range of `unsigned LONG int', but outside the range of `LONG int'. */ if (overflow == 0 && i > (negative ? -((unsigned long int) (LONG_MIN + 1)) + 1 : (unsigned long int) LONG_MAX)) overflow = 1; if (overflow) { return negative ? LONG_MIN : LONG_MAX; } /* Return the result of the appropriate sign. */ return negative ? -i : i; noconv: /* We must handle a special case here: the base is 0 or 16 and the first two characters are '0' and 'x', but the rest are not hexadecimal digits. This is no error case. We return 0 and ENDPTR points to the `x`. */ if (endptr != NULL) { if (save - nptr >= 2 && toupperW (save[-1]) == 'X' && save[-2] == '0') *endptr = (WCHAR *)&save[-1]; else /* There was no number to convert. */ *endptr = (WCHAR *)nptr; } return 0L; }
/* compare an ASCII and a Unicode string without depending on the current codepage */ static inline int strcmpiAW( const char *strA, const WCHAR *strW ) { while (*strA && (toupperW((unsigned char)*strA) == toupperW(*strW))) { strA++; strW++; } return toupperW((unsigned char)*strA) - toupperW(*strW); }
/*********************************************************************** * COMM_BuildOldCommDCB (Internal) * * Build a DCB using the old style settings string eg: "96,n,8,1" */ static BOOL COMM_BuildOldCommDCB(LPCWSTR device, LPDCB lpdcb) { WCHAR last = 0; if(!(device = COMM_ParseNumber(device, &lpdcb->BaudRate))) return FALSE; switch(lpdcb->BaudRate) { case 11: case 30: case 60: lpdcb->BaudRate *= 10; break; case 12: case 24: case 48: case 96: lpdcb->BaudRate *= 100; break; case 19: lpdcb->BaudRate = 19200; break; } while(*device == ' ') device++; if(*device++ != ',') return FALSE; while(*device == ' ') device++; if(!(device = COMM_ParseParity(device, &lpdcb->Parity))) return FALSE; while(*device == ' ') device++; if(*device++ != ',') return FALSE; while(*device == ' ') device++; if(!(device = COMM_ParseByteSize(device, &lpdcb->ByteSize))) return FALSE; while(*device == ' ') device++; if(*device++ != ',') return FALSE; while(*device == ' ') device++; if(!(device = COMM_ParseStopBits(device, &lpdcb->StopBits))) return FALSE; /* The last parameter for flow control is optional. */ while(*device == ' ') device++; if(*device == ',') { device++; while(*device == ' ') device++; if(*device) last = toupperW(*device++); while(*device == ' ') device++; } /* Win NT sets the flow control members based on (or lack of) the last parameter. Win 9x does not set these members. */ switch(last) { case 0: lpdcb->fInX = FALSE; lpdcb->fOutX = FALSE; lpdcb->fOutxCtsFlow = FALSE; lpdcb->fOutxDsrFlow = FALSE; lpdcb->fDtrControl = DTR_CONTROL_ENABLE; lpdcb->fRtsControl = RTS_CONTROL_ENABLE; break; case 'X': lpdcb->fInX = TRUE; lpdcb->fOutX = TRUE; lpdcb->fOutxCtsFlow = FALSE; lpdcb->fOutxDsrFlow = FALSE; lpdcb->fDtrControl = DTR_CONTROL_ENABLE; lpdcb->fRtsControl = RTS_CONTROL_ENABLE; break; case 'P': lpdcb->fInX = FALSE; lpdcb->fOutX = FALSE; lpdcb->fOutxCtsFlow = TRUE; lpdcb->fOutxDsrFlow = TRUE; lpdcb->fDtrControl = DTR_CONTROL_HANDSHAKE; lpdcb->fRtsControl = RTS_CONTROL_HANDSHAKE; break; default: return FALSE; } /* This should be the end of the string. */ if(*device) return FALSE; return TRUE; }
int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int show) { LPWSTR *argv; int argc; int i; WCHAR check, cmd = 0; WCHAR path[MAX_PATH]; LPCWSTR cabfile = NULL; path[0] = 0; /* Do not use CommandLineToArgvW() or __wgetmainargs() to parse * command line for this program. It should treat each quote as argument * delimiter. This doesn't match with behavior of mentioned functions. * Do not use args provided by wmain() for the same reason. */ argv = get_extrac_args(cmdline, &argc); if(!argv) { WINE_ERR("Command line parsing failed\n"); return 0; } /* Parse arguments */ for(i = 0; i < argc; i++) { /* Get cabfile */ if (argv[i][0] != '/' && argv[i][0] != '-') { if (!cabfile) { cabfile = argv[i]; continue; } else break; } /* Get parameters for commands */ check = toupperW( argv[i][1] ); switch(check) { case 'A': WINE_FIXME("/A not implemented\n"); break; case 'Y': force_mode = TRUE; break; case 'L': if ((i + 1) >= argc) return 0; if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL)) return 0; break; case 'C': case 'E': case 'D': if (cmd) return 0; cmd = check; break; default: return 0; } } if (!cabfile) return 0; if (cmd == 'C') { if ((i + 1) != argc) return 0; if (!GetFullPathNameW(argv[i], MAX_PATH, path, NULL)) return 0; } else if (!cmd) /* Use extraction by default if names of required files presents */ cmd = i < argc ? 'E' : 'D'; if (cmd == 'E' && !path[0]) GetCurrentDirectoryW(MAX_PATH, path); PathAddBackslashW(path); /* Execute the specified command */ switch(cmd) { case 'C': /* Copy file */ copy_file(cabfile, path); break; case 'D': /* Display CAB archive */ show_content = TRUE; /* Fall through */ case 'E': /* Extract CAB archive */ extract(cabfile, path); break; } return 0; }