static Bool SyncDriverIsRemoteFSType(const char *fsType) { size_t i; for (i = 0; i < ARRAYSIZE(gRemoteFSTypes); i++) { if (Str_Strcmp(gRemoteFSTypes[i], fsType) == 0) { return TRUE; } } return FALSE; }
Err_Number Err_String2ErrnoDebug(const char *string) // IN { #ifdef __linux__ HashTable *strTable = STRTABLE(); ErrInfo *info; if (!HashTable_Lookup(strTable, string, (void **) &info)) { return ERR_INVALID; } ASSERT(Str_Strcmp(info->string, string) == 0); ASSERT(info->number != ERR_INVALID); if (info->string != string) { Log("%s: errno %d, string \"%s\" at %p, originally at %p.\n", __FUNCTION__, info->number, string, string, info->string); } return info->number; #else return ERR_INVALID; #endif }
static int StrUtilStrcmp(const char *s1, const char *s2) { return Str_Strcmp(s1, s2); }
const char * Err_Errno2String(Err_Number errorNumber) // IN { HashTable *numTable; HashTable *ptrTable; ErrInfo *info; ErrInfo *oldInfo; Err_Number oldErrno = Err_Errno(); ASSERT(errorNumber != ERR_INVALID); /* * Look up the error in numTable. * Or insert it if it's not there. */ numTable = NUMTABLE(); if (!HashTable_Lookup(numTable, (void *) (uintptr_t) errorNumber, (void **) &info)) { char buf[2048]; const char *p; size_t n; /* * Convert number to string and build the info structure. */ p = ErrErrno2String(errorNumber, buf, sizeof buf); info = Util_SafeMalloc(sizeof *info); info->number = errorNumber; info->string = Util_SafeStrdup(p); /* * To be safe, make sure the end of the string is at * a UTF-8 boundary, but we can only do this when the * string is in our buffer (it may not be). */ n = strlen(info->string); n = CodeSet_Utf8FindCodePointBoundary(info->string, n); info->string[n] = '\0'; /* * Try to insert new info into numTable. * If that fails, then we must have lost out to someone else. * Use theirs in that case. */ oldInfo = HashTable_LookupOrInsert(numTable, (void *) (uintptr_t) errorNumber, info); if (oldInfo != info) { ASSERT(oldInfo->number == info->number); ASSERT(Str_Strcmp(oldInfo->string, info->string) == 0); free(info->string); free(info); info = oldInfo; } } /* * Try to insert info into ptrTable. * We need to do it even if we didn't create this entry, * because we may get here before the other guy (who created * the entry and inserted it into numTable). */ ptrTable = PTRTABLE(); oldInfo = HashTable_LookupOrInsert(ptrTable, info->string, info); ASSERT(oldInfo == info); #if defined VMX86_DEBUG && defined __linux__ { HashTable *strTable = STRTABLE(); ErrInfo *i = HashTable_LookupOrInsert(strTable, info->string, info); ASSERT(i == info); } #endif Err_SetErrno(oldErrno); return info->string; }