bool CCryptosaurEngine::ValidateAuthDescActual (CDatum dAuthDesc, const CString &sScope, CDatum dUserData) // ValidateAuthDescActual // // Validates that dAuthDesc is valid authorization from the actual user. { CDatum dAuthToken = dAuthDesc.GetElement(FIELD_AUTH_TOKEN); CDatum dCredentials = dAuthDesc.GetElement(FIELD_CREDENTIALS); // Do we have an authToken? if (!dAuthToken.IsNil()) { // Get the key to sign with (the key is guaranteed to exist because we // checked at boot time). CIPInteger *pAuthTokenKey = m_Keys.GetAt(KEY_CRYPTOSAUR_AUTH_TOKEN); // Validate CDatum dData; if (!CCryptosaurInterface::ValidateAuthToken(dAuthToken, *pAuthTokenKey, &dData)) return false; // The proper user? if (!strEquals(strToLower(dData.GetElement(FIELD_USERNAME)), strToLower(dUserData.GetElement(FIELD_USERNAME)))) return false; // AuthToken for actual? if (!dData.GetElement(FIELD_SCOPE).IsNil()) return false; // OK return true; } // Otherwise, we better have credentials else if (!dCredentials.IsNil()) { // Compare credentials against user record CDatum dTrueAuthDesc = dUserData.GetElement(FIELD_AUTH_DESC); if (!((const CIPInteger &)dCredentials == (const CIPInteger &)dTrueAuthDesc.GetElement(FIELD_CREDENTIALS))) return false; // OK return true; } // Otherwise we fail. else return false; }
//Not case-sensitive search User *getUserByNick(std::string nick) { // Get coordinates for(unsigned int i = 0; i < Users.size(); i++) { if(strToLower(Users[i]->nick) == strToLower(nick)) return Users[i]; } return NULL; }
ALERROR WriteModuleImages (CTDBCompiler &Ctx, CXMLElement *pModule, const CString &sFolder, CDataFile &Out) { ALERROR error; int i; for (i = 0; i < pModule->GetContentElementCount(); i++) { CXMLElement *pItem = pModule->GetContentElement(i); if (strEquals(pItem->GetTag(), TAG_IMAGES)) { CString sSubFolder = pathAddComponent(sFolder, pItem->GetAttribute(ATTRIB_FOLDER)); if (error = WriteModuleImages(Ctx, pItem, sSubFolder, Out)) return error; } else if (strEquals(pItem->GetTag(), TAG_IMAGE)) { CString sFilename = pItem->GetAttribute(ATTRIB_BITMAP); if (!sFilename.IsBlank()) { bool bCompress = strEquals(strToLower(pathGetExtension(sFilename)), CONSTLIT("bmp")); if (error = WriteResource(Ctx, sFilename, sFolder, bCompress, Out)) continue; } sFilename = pItem->GetAttribute(ATTRIB_BITMASK); if (!sFilename.IsBlank()) { bool bCompress = strEquals(strToLower(pathGetExtension(sFilename)), CONSTLIT("bmp")); if (error = WriteResource(Ctx, sFilename, sFolder, bCompress, Out)) continue; } sFilename = pItem->GetAttribute(ATTRIB_SHADOW_MASK); if (!sFilename.IsBlank()) { bool bCompress = strEquals(strToLower(pathGetExtension(sFilename)), CONSTLIT("bmp")); if (error = WriteResource(Ctx, sFilename, sFolder, bCompress, Out)) continue; } sFilename = pItem->GetAttribute(ATTRIB_HIT_MASK); if (!sFilename.IsBlank()) { bool bCompress = strEquals(strToLower(pathGetExtension(sFilename)), CONSTLIT("bmp")); if (error = WriteResource(Ctx, sFilename, sFolder, bCompress, Out)) continue; } } } return NOERROR; }
static void fontSetEnumCB(void *data, const char *, const char *fname) { FontSetsCBData *d = static_cast<FontSetsCBData*>(data); FileSystemPrivate *p = d->p; /* Only consider filenames with font extensions */ const char *ext = p->findExt(fname); if (!ext) return; std::string lower(ext); strToLower(lower); if (!contains(p->extensions[FileSystem::Font], lower)) return; std::string filename("Fonts/"); filename += fname; PHYSFS_File *handle = PHYSFS_openRead(filename.c_str()); if (!handle) return; SDL_RWops ops; p->initReadOps(handle, ops, false); d->sfs->initFontSetCB(ops, filename); SDL_RWclose(&ops); }
void InitStoplistConfig() { char *stoplist_path = Config("STOPLIST"); if (stoplist_path == NULL) { return; } FILE *fp = fopen(stoplist_path, "rb"); if (fp == NULL) { fprintf(stderr, "Unable to load stoplist: %s\n", stoplist_path); return; } char term[TERM_MAX_LEN+1]; for (;;) { if (fscanf(fp, "%s\n", term) < 1) break; strToLower(term); Stem(term); Stopword *newStopword; HASH_FIND_STR(stoplist, term, newStopword); if (newStopword == NULL) { newStopword = malloc(sizeof(Stopword)); strcpy(newStopword->t, term); HASH_ADD_STR(stoplist, t, newStopword); } } fclose(fp); }
/** * Handles getting a parameter for an opcode */ void get_parameter() { int nvalue; if (token == NUMBER) { literal.value.integer = strToInt(token_string); return; } if (token != IDENTIFIER) return; nvalue = symbolFind(); if (nvalue != -1) { // Found symbol, so get it's numeric value and return token = NUMBER; literal.value.integer = strToInt(symbolTable[nvalue].value); return; } // Check if the parameter is the name of an already processed subroutine strToLower(token_string); nvalue = subIndexOf(); if (nvalue == -1) { token = ERROR; return; } // Store the index (not the offset) of the subroutine to call token = NUMBER; literal.value.integer = nvalue; }
/*Adds a node to the head node with word occurrences and cases*/ void addNode(char *d){ struct node *newNode, *current; struct casenode *casehead; #ifdef DEBUG printf("IN ADDNODE\n"); #endif newNode=(struct node *)malloc(sizeof(struct node)); casehead=(struct casenode *)malloc(sizeof(struct casenode)); newNode->data=(strToLower(d)); newNode->occur = 1; newNode->caseSensitive = 1; casehead->convertedCase = d; casehead->next=NULL; newNode->caseHead = casehead; current=Head; if(Head == NULL || strcmp(Head->data, newNode->data)>=0){ newNode->next = Head; Head = newNode; }else{ while(current->next != NULL && strcmp(current->next->data, newNode->data)<0) current = current->next; newNode->next=current->next; current->next=newNode; } #ifdef DEBUG printf("OUT OF ADDNODE\n"); #endif }
/*Checks wordcase in list*/ bool wordCase(char *word){ #ifdef DEBUG printf("IN WORDCASE\n"); #endif struct node *ptr = Head; while(ptr!=NULL){ if(!strcmp(ptr->data, strToLower(word))){ struct casenode *caseptr = ptr->caseHead; while(caseptr->next!=NULL){ if(!strcmp(caseptr->convertedCase, word)){ return true; } caseptr = caseptr->next; } struct casenode *newCaseNode = (struct casenode*)malloc(sizeof(struct casenode)); newCaseNode->convertedCase = word; newCaseNode->next= NULL; caseptr->next = newCaseNode; ptr->caseSensitive++; return true; }else{ ptr=ptr->next; } } #ifdef DEBUG printf("OUT WORDCASE\n"); #endif return false; }
LPCTSTR CFileName::GetType(const __int8 _case /* = 0*/) { if (!filename || (m_attribute & CFN_NOTFILE)) return _T(""); if (ext && _case == m_iLastExtCase) return ext; LPTSTR ptr = filename; ptr = _tcsrchr(ptr, _T('.')); if (ptr) { ptr++; if (ext) free(ext); ext = (LPTSTR) malloc(sizeof(TCHAR) * (_tcslen(ptr) + 1)); switch (_case) { case 1: strToUpper(ext, ptr); break; case -1: strToLower(ext, ptr); break; default: _tcscpy(ext, ptr); break; } m_iLastExtCase = _case; return ext; } return _T(""); }
LPCTSTR CFileName::GetTitle(const __int8 _case /* = 0*/) { if (!filename) return _T(""); LPTSTR ptr = _tcsrchr(filename, _T('.')); if ((m_attribute & CFN_NOTFILE) || !ptr) return filename; if (title) { if (m_iLastTitleCase == _case) return title; free(title); } title = (LPTSTR) malloc(sizeof(TCHAR) * (_tcslen(filename) + 1)); switch (_case) { case 1: strToUpper(title, filename); break; case -1: strToLower(title, filename); break; default: _tcscpy(title, filename); break; } ptr = _tcsrchr(title, _T('.')); *ptr = _T('\0'); m_iLastTitleCase = _case; return title; }
/* * retrieve user input * user enters a line of input(sentence) * split word by word * return a vector of the words entered by the user in order */ std::vector<std::string> getUserInput(){ std::string prompt = "Please enter a sentence:"; std::string input; std::string quit("q"); //get user input std::cout << prompt << std::endl; std::getline(std::cin, input); std::vector<std::string> words; char *word = strtok(&input[0], " "); while(word != NULL){ std::string str(word); str = strToLower(str); words.push_back(str); word = strtok(NULL, " "); } if(words.size() == 1 && words[0].compare(quit) == 0){ std::cout << "exiting..." << std::endl; exit(0); } return words; }
bool_t dictionaryInitialize(dictionary_t * self, const char * rawDict) { uint_t i = 0; uint_t dictLen = 0; char * currWord; uint_t currWordLen = 0; uint_t rawDictLen = strlen(rawDict); /* Create a copy of the raw data - lower cased followed by upper cased */ self->rawDataLowerUpper = (char *) malloc(((2 * rawDictLen) + 1) * sizeof(*(self->rawDataLowerUpper))); CHECK(NULL != self->rawDataLowerUpper); strcpy(self->rawDataLowerUpper, rawDict); strToLower(self->rawDataLowerUpper, rawDictLen); strcpy(self->rawDataLowerUpper + rawDictLen, rawDict); strToUpper(self->rawDataLowerUpper + rawDictLen, rawDictLen); self->rawDataLowerUpper[2 * rawDictLen] = '\0'; /* Scan the upper cased part in order to count the words */ currWord = self->rawDataLowerUpper + rawDictLen; while (findNextWordInRawDict(currWord, &currWord, &currWordLen)) { ++dictLen; currWord += currWordLen + 1; } /* Alloc the vector of string pointer pairs. We alloc one extra member for a null terminator */ self->entries = (stringPair_t *) calloc(dictLen + 1, sizeof(*(self->entries))); CHECK(NULL != self->entries); self->numEntries = dictLen + 1; self->maxEntryLength = 0; /* Now scan the raw dict again, this time updating the resulting array and splitting the strings */ currWord = self->rawDataLowerUpper + rawDictLen; findNextWordInRawDict(currWord, &currWord, &currWordLen); for (i = 0; i < dictLen; ++i) { findNextWordInRawDict(currWord, &currWord, &currWordLen); self->entries[i][LOWER_CASE] = currWord - rawDictLen; self->entries[i][LOWER_CASE][currWordLen] = '\0'; self->entries[i][UPPER_CASE] = currWord; self->entries[i][UPPER_CASE][currWordLen] = '\0'; if (self->maxEntryLength < currWordLen) { self->maxEntryLength = currWordLen; } currWord += currWordLen + 1; } /* Every dictionary contains the empty word, so the last entry points to '\0' */ self->entries[i][LOWER_CASE] = self->rawDataLowerUpper + (2 * rawDictLen); self->entries[i][UPPER_CASE] = self->rawDataLowerUpper + (2 * rawDictLen); return TRUE; LBL_ERROR: PERROR(); FREE(self->rawDataLowerUpper); return FALSE; }
CUserInfoSession (CCryptosaurEngine *pEngine, const CString &sScope, const CString &sUsername, CDatum dPayload = CDatum()) : m_pEngine(pEngine), m_sScope(sScope), m_sUsername(sUsername), m_sUsernameKey(strToLower(sUsername)), m_dPayload(dPayload), m_iState(stateWaitingForUserRecord) { }
void ExtractGameobjectModels() { printf("Extracting GameObject models..."); DBCFile dbc(LocaleMpq, "DBFilesClient\\GameObjectDisplayInfo.dbc"); if(!dbc.open()) { printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n"); exit(1); } std::string basepath = szWorkDirWmo; basepath += "/"; std::string path; FILE * model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb"); for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it) { path = it->getString(1); if (path.length() < 4) continue; FixNameCase((char*)path.c_str(), path.size()); char * name = GetPlainName((char*)path.c_str()); FixNameSpaces(name, strlen(name)); char * ch_ext = GetExtension(name); if (!ch_ext) continue; strToLower(ch_ext); bool result = false; if (!strcmp(ch_ext, ".wmo")) result = ExtractSingleWmo(path); else if (!strcmp(ch_ext, ".mdl")) // TODO: extract .mdl files, if needed continue; else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2")) result = ExtractSingleModel(path); if (result) { uint32 displayId = it->getUInt(0); uint32 path_length = strlen(name); fwrite(&displayId, sizeof(uint32), 1, model_list); fwrite(&path_length, sizeof(uint32), 1, model_list); fwrite(name, sizeof(char), path_length, model_list); } } fclose(model_list); printf("Done!\n"); }
int List::AccessIgnoreCase(string str) { if (m_Head == NULL) // empty list return -1; else { // Assessment // To add some code here int count = 0; Node *ptrTemp = m_Head; while(strToLower(ptrTemp->str) != strToLower(str)) { count++; ptrTemp = ptrTemp->ptrNext; if (ptrTemp == NULL) { return -1; } } return count; // return -1; } }
void doTest(const string &arg, const string &ip){ SingleLogServer::getInstance()->InitLog("./log", "network_"); g_Ip = ip; string argTmp = strToLower(arg); DEBUG_D("run doTest : = " << argTmp); //doLink(argTmp); //doMemCpy(argTmp); doPerformance(argTmp); }
bool RESGen::CacheWad(const std::string &wadfile) { File wad; if(!OpenFirstValidPath(wad, wadfile, "rb")) { printf("Failed to open WAD file \"%s\".\n", wadfile.c_str()); return false; } wadheader_s header; if (fread(&header, sizeof(wadheader_s), 1, wad) != 1) { printf("WAD file \"%s\" is corrupt.\n", wadfile.c_str()); return false; } if (strncmp(header.identification, "WAD", 3)) { printf("\"%s\" is not a WAD file.\n", wadfile.c_str()); return false; } if (header.identification[3] != '2' && header.identification[3] != '3') { printf("Incorrect WAD file version for \"%s\"\n", wadfile.c_str()); return false; } if (fseek(wad, header.infotableofs, SEEK_SET)) { printf("Cannot find WAD info table in \"%s\"\n", wadfile.c_str()); return false; } const std::string wadFileLower(strToLowerCopy(wadfile)); for (int i = 0; i < header.numlumps; i++) { wadlumpinfo_s lumpinfo; if (fread(&lumpinfo, sizeof(wadlumpinfo_s), 1, wad) != 1) { printf("WAD file info table \"%s\" is corrupt.\n", wadfile.c_str()); return false; } std::string lumpNameLower(lumpinfo.name); strToLower(lumpNameLower); wadcache[wadFileLower].insert(lumpNameLower); } return true; }
void RESGen::AddRes(std::string res, const char * const prefix, const char * const suffix) { // Sometimes res entries start with a non alphanumeric character. Strip // until valid char found while ( !res.empty() && !isalnum(res[0]) ) { // Remove character res.erase(res.begin()); } if(res.empty()) { // Nothing to add return; } replaceCharAll(res, '\\', '/'); // Add prefix and suffix if (prefix) { res.insert(0, prefix); } if (suffix) { res += suffix; } if (tolower) { // Convert name to lowercase strToLower(res); } // Add file to list if it isn't in it yet. // We shouldn't care if this overwrites a previous entry (it shouldn't) - // it'll only differ by case resfile[strToLowerCopy(res)] = res; // Report file found if (contentdisp) { printf("\r%-21s\n", res.c_str()); // With 21 chars, there is support for up to 999999 bsp's to parse untill the statbar might remain in screen } statcount = STAT_MAX; // Make statbar print on next update return; }
void SBTarget::validateSDK() { // Check if this is an iphoneos target // Could take the form of "iphone" or a full path to the SDK for (auto bs : m_buildSettings) { const VariableCollectionHierarchy& vch = bs.second->getHierarchy(); String sdkRoot = vch.getValue("SDKROOT", vch.size() - 2); sdkRoot = strToLower(sb_basename(sdkRoot)); if (!strBeginsWith(sdkRoot, "iphoneos")) { SBLog::warning() << "The \"" << bs.first << "\" configuration of the \"" << getName() << "\" target does not target an iOS SDK." << std::endl; } } }
/** * Retrieves a specified vocab entry */ void Dialog::getVocab(int vocabId, char **line) { assert(vocabId > 0); const char *vocabStr = _madsVm->globals()->getVocab(vocabId); strcpy(*line, vocabStr); if (_commandCase) strToUpper(*line); else strToLower(*line); // Move the string pointer to after the added string while (!**line) ++*line; }
jstring Java_cn_knet_seal_financial_api_KnetFinancialHttpApi_pt( JNIEnv* env,jobject thiz, jstring u, jstring t, jstring p) { char* ustr = jstringTostring(env,u); char* tstr = jstringTostring(env,t); char* pstr = jstringTostring(env,p); char md5c[33]={0}; char c_char[20480]=""; strcat(c_char,ustr); strcat(c_char,pstr); strcat(c_char,tstr); getmd5(c_char,md5c); strToLower(md5c); jstring result = (*env)->NewStringUTF(env,md5c); return result; }
EContentEncodingTypes IMediaType::GetDefaultEncodingType (const CString &sMediaType) // GetDefaultEncodingType // // Returns the default encoding type for the given media type { int i; CString sSearch = strToLower(sMediaType); for (i = 0; i < g_MediaTypeDataCount; i++) if (strEquals(sSearch, g_MediaTypeData[i].sMediaType)) return g_MediaTypeData[i].iDefaultEncoding; return http_encodingIdentity; }
inline bool isSupportedExtension(const std::string& in,std::string& suffix) { suffix = ""; std::string ext = in; strToLower(ext); for(int i = 0; i < 6; i++) { if(ext.rfind(supportedExtensions[i]) != std::string::npos) { suffix = supportedExtensions[i]; return true; } } return false; }
bool KFontProperties::enumerateFont(const KFile *file, int ptSize) { if(file->isFile()) { if(strToLower(file->getExtension()) == ".ttf") { if(!TTF_WasInit()) { TTF_Init(); } TTF_Font *_Font = TTF_OpenFont(file->getAbsolutePath().c_str(), ptSize); if(_Font != nullptr) { KFontProperties *fp = new KFontProperties(_Font, file, ptSize); // free the font. TTF_CloseFont(_Font); auto lock = getLock(); fontList[file->getAbsolutePath()][ptSize].reset(fp); return true; } } } return false; }
void AddWord (TraverseCtx &Ctx, const CString &sWord) { // If this is a single character, then skip it if (sWord.GetLength() == 1) ; // Skip words that are all numbers and hex numbers else if (isAllNumbers(sWord) || strFind(sWord, CONSTLIT("0x")) == 0) ; // Otherwise, add it else { Ctx.pWordList->AddEntry(strToLower(sWord), NULL); } }
/*Check if word exists*/ bool wordExist(char *word) { #ifdef DEBUG printf("IN WORDEXIST\n"); #endif struct node *ptr = Head; while(ptr!=NULL){ if(!strcmp(ptr->data, strToLower(word))){ ptr->occur++; #ifdef DEBUG printf("OUT WORDEXIST\n"); #endif return true; }else{ ptr=ptr->next; } } #ifdef DEBUG printf("OUT WORDEXIST\n"); #endif return false; }
std::string getUserLanguage() { const char* pLang = NULL; fprintf(stdout,"Detecting locale...\t\t"); fflush(stdout); #if defined (_WIN32) char ISO639_LanguageName[10]; if(GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SISO639LANGNAME, ISO639_LanguageName, sizeof(ISO639_LanguageName)) == 0) { return ""; } else { pLang = ISO639_LanguageName; } #elif defined (__APPLE__) pLang = getMacLanguage(); if(pLang == NULL) { return ""; } #else // should work on most unices pLang = getenv("LC_ALL"); if(pLang == NULL) { // try LANG pLang = getenv("LANG"); if(pLang == NULL) { return ""; } } #endif fprintf(stderr, "'%s'\n", pLang); fflush(stdout); if(strlen(pLang) < 2) { return ""; } else { return strToLower(std::string(pLang, 2)); } }
void setTraceLevelStr(const std::string& str) { std::string lower_lstr = strTrim(strToLower(str)); if (kTraceVerbose == lower_lstr) setTraceLevel(Trace::Verbose); else if (kTraceDebug == lower_lstr) setTraceLevel(Trace::Debug); else if (kTraceInfo == lower_lstr) setTraceLevel(Trace::Info); else if (kTraceWarn == lower_lstr) setTraceLevel(Trace::Warn); else if (kTraceError == lower_lstr) setTraceLevel(Trace::Error); else if (kTraceFatal == lower_lstr) setTraceLevel(Trace::Fatal); else if (kTraceAssert == lower_lstr) setTraceLevel(Trace::Assert); else if (kTraceSilent == lower_lstr) setTraceLevel(Trace::Silent); else setTraceLevel(Trace::Info); }
bool CCryptosaurEngine::ValidateRightsGrant (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx, const CAttributeList &Rights) // ValidRightsGrant // // Validates that the service has the permission to grant the given rights to // a user. { int i; // Check sandbox if (pSecurityCtx && !pSecurityCtx->HasServiceRightArcAdmin()) { // Get the sandbox prefix (rights are case-insensitive) CString sSandboxPrefix = strToLower(pSecurityCtx->GetSandbox()); // Get the list of rights TArray<CString> All; Rights.GetAll(&All); // Make sure each right is sandboxed for (i = 0; i < All.GetCount(); i++) { if (!strStartsWith(All[i], sSandboxPrefix)) { SendMessageReplyError(MSG_ERROR_NOT_ALLOWED, strPattern(ERR_CANNOT_GRANT_RIGHT, All[i]), Msg); return false; } } } // OK return true; }
int flib_ini_enter_section(flib_ini *ini, const char *section) { int result = INI_ERROR_OTHER; if(ini) { free(ini->currentSection); ini->currentSection = NULL; } if(!log_badargs_if2(ini==NULL, section==NULL)) { if(!iniparser_find_entry(ini->inidict, section)) { flib_log_d("Ini section %s not found", section); result = INI_ERROR_NOTFOUND; } else { ini->currentSection = flib_strdupnull(section); if(ini->currentSection) { // Usually iniparser ignores case, but some section-handling functions don't, // so we set it to lowercase manually strToLower(ini->currentSection); result = 0; } } } return result; }