/* * Displays a yes/no question and waits for an answer. Result * is returned in res. 1 if yesChar was selected, 0 otherwise. * Function return 0 normally or 1 if carrier is dropped. */ int GetYesOrNo(char *preStr, char *label, char *yesChar, char *noChar, char *yesStr, char *noStr, char *postStr, int yesIsDefault, int *res) { int ch; char *response, yes, no; yes = yesChar != NULL ? *yesChar : *yesStr; no = noChar != NULL ? *noChar : *noStr; radcnt = 0; SendString("%s%s", preStr != NULL ? preStr : "", label != NULL ? label : ""); SendString(" (%c/%c) ", yesIsDefault ? UPPERCASE(yes) : LOWERCASE(yes), yesIsDefault ? LOWERCASE(no) : UPPERCASE(no)); for(;;) { ch = GetChar(); if(ch == GETCHAR_LOGOUT) { return 1; } if(ch == GETCHAR_RETURN) { *res = yesIsDefault ? 1 : 0; } else if(LOWERCASE(ch) == LOWERCASE(yes)) { *res = 1; } else if(LOWERCASE(ch) == LOWERCASE(no)) { *res = 0; } else { continue; } response = *res ? yesStr : noStr; if(response != NULL) { SendString("%s%s", response, postStr != NULL ? postStr : ""); } return 0; } }
/*---------------------------------------------------------------------------*/ HTTP_BOOL _HTTP_ServerMatchPath (const HTTP_CHAR *pattern, const HTTP_CHAR *path, HTTP_BOOL exactMatch) { while (pattern[0]) { if (pattern[0] == '/' || pattern[0] == '\\') { if (path[0] != '/' && path[0] != '\\') { return (0); } } else { if (UPPERCASE(path[0]) != UPPERCASE(pattern[0])) { return (0); } } path++; pattern++; } if (!exactMatch || !path[0] || path[0] == '?') { return (1); } return (0); }
int webc_c_stricmp (const WEBC_CHAR *webcStr, const char *_str) { const unsigned char *str = (const unsigned char *) _str; for (; *webcStr && *str && (UPPERCASE(*webcStr) == UPPERCASE(*str)); webcStr++, str++) {;} return ((int)UPPERCASE(*webcStr) - (int)UPPERCASE(*str)); }
int webc_c_strnicmp (const WEBC_CHAR *webcStr, const char *_str, long n) { if (n <= 0) { return (0); } const unsigned char *str = (const unsigned char *) _str; for (; (n > 0) && *webcStr && *str && (UPPERCASE(*webcStr) == UPPERCASE(*str)); webcStr++, str++, n--) {;} if (n == 0) { return (0); } return ((int)UPPERCASE(*webcStr) - (int)UPPERCASE(*str)); }
void ToUpperCaseBuilder::BuildStringUT(WEBC_CHAR *pStringBuffer) { int n; for (n=0; n<GetStringLength(); n++) { pStringBuffer[n] = UPPERCASE(mpStr[n]); } }
long WebListBox::NextIndexStartingWith (WebChar ch) { if (miNumOptions > 0) { long newSelection = miSelected; newSelection = (newSelection + 1) % miNumOptions; while (newSelection != miSelected) { WebChar *str = GetOptionText(newSelection); if (str) { while (IS_WHITESPACE(str[0])) str++; if (UPPERCASE(str[0]) == UPPERCASE(ch)) { return newSelection; } } newSelection = (newSelection + 1) % miNumOptions; } } return -1; }
/**@brief look for BENCHIT_KERNEL_FILE_VERSION_<filename> in files and set * an ENVIRONMENT VARIABLE for it */ int main (void) { /** folder structure */ DIR *dp; struct dirent *ep; struct stat statbuf; char *buff, *found; /** buffer for file content */ int buffsize=100*1024; char temp[100]; char temp2[100]; int index; FILE *f; /* allocate memory for filecontent */ buff=(char *) malloc(buffsize); if(buff==NULL) { printf("Unable to allocate %dKB\n", buffsize/1024); exit(1); } /** open actual folder */ dp = opendir ("./"); if (dp != NULL) { while( (ep=readdir(dp))!=NULL ) { /* skip some special candidates */ /** everything, which starts with . */ if( ep->d_name[0]=='.' ) continue; /** CVS isnt what we want */ if( strcmp(ep->d_name,"CVS")==0 ) continue; /** neither are .o files */ index=strlen(ep->d_name); if( ep->d_name[index-2]=='.' && ep->d_name[index-1]=='o' ) continue; /** stat for filename (get information) */ if( stat(ep->d_name,&statbuf)!=0 ) { /** error! stat not succesful */ REPLACE( ep->d_name, '.', '_'); UPPERCASE( ep->d_name); printf("BENCHIT_KERNEL_FILE_VERSION_%s='%s (%s)'\n", ep->d_name, "NO REVISION, UNABLE TO STAT", "COULD NOT STAT"); continue; } /* stat succesful */ else { /** write changes since last time to temp2 */ strncpy( temp2, ctime(&statbuf.st_mtime), 100); for( index=0; index<100; index++) if( temp2[index]<' ' ) temp2[index]=0; /** maybe enlarge buffer for filecontent */ if( statbuf.st_size>buffsize ) { buff=(char *) realloc(buff,statbuf.st_size); if(buff==NULL) { printf("Unable to allocate %dKB\n", buffsize/1024); exit(1); } buffsize=statbuf.st_size; } /** open file */ if( (f=fopen(ep->d_name,"r"))==NULL ) { REPLACE( ep->d_name, '.', '_'); UPPERCASE( ep->d_name); printf("BENCHIT_KERNEL_FILE_VERSION_%s='%s (%s)'\n", ep->d_name, "NO REVISION, UNABLE TO OPEN", temp2); continue; } memset( buff, 0, buffsize); /** read complete file */ if( fread( buff, statbuf.st_size, 1, f)!= 1) { REPLACE( ep->d_name, '.', '_'); UPPERCASE( ep->d_name); printf("BENCHIT_KERNEL_FILE_VERSION_%s='%s (%s)'\n", ep->d_name, "NO REVISION, UNABLE TO READ", temp2); continue; } fclose(f); /** check for $Revision: */ found=strstr( buff, "$Revision:"); if( found==NULL ) { REPLACE( ep->d_name, '.', '_'); UPPERCASE( ep->d_name); printf("BENCHIT_KERNEL_FILE_VERSION_%s='%s (%s)'\n", ep->d_name, "NO REVISION", temp2); continue; } /** go to the beginning of '$Revision:' */ found+=10; while( *found==' ' ) found++; index=0; memset( temp, 0, 100); /** read revision number */ while( *found!='$' && *found>' ' && index<99 ) temp[index++]=*(found++); /** okay, write result */ REPLACE( ep->d_name, '.', '_'); UPPERCASE( ep->d_name); printf("BENCHIT_KERNEL_FILE_VERSION_%s='%s (%s)'\n", ep->d_name, temp, temp2 ); } } (void) closedir (dp); } else perror ("Couldn't open the directory"); free(buff); printf("\n"); return 0; }
DWORD XDVDFS_GetFileInfo( PXDVDFS_SESSION Session, LPSTR Filename, PSEARCH_RECORD SearchRecord) { DWORD Length, i, ReturnCode; // To begin, we will enter the root directory XDVDFS_GetRootDir(Session, SearchRecord); SearchRecord->CurrentFileStartSector = SearchRecord->SearchStartSector; SearchRecord->CurrentFileSize = SearchRecord->DirectorySize; SearchRecord->CurrentFileAttributes = XDVDFS_ATTRIBUTE_DIRECTORY; SearchRecord->CurrentFilename[0] = 0; // Skip leading backslash if present if (*Filename == DIRECTORY_SEPARATOR) Filename++; while(*Filename) { // Skip backslashes while(*Filename == DIRECTORY_SEPARATOR) Filename++; // If previously matched name is not a dir, fail if (!(SearchRecord->CurrentFileAttributes & XDVDFS_ATTRIBUTE_DIRECTORY)) return XDVDFS_FILE_NOT_FOUND; // Enter that directory Length = 0; SearchRecord->SearchStartSector = SearchRecord->CurrentFileStartSector; SearchRecord->DirectorySize = SearchRecord->CurrentFileSize; SearchRecord->Position = 0; // Browse the contents of the dir while( (ReturnCode = XDVDFS_EnumFiles(Session, SearchRecord)) == XDVDFS_NO_ERROR) { // Dxbx addition : Stop at first file if no further path is given if (*Filename == 0) break; // Calculate length of the filename Length = 0; while( (SearchRecord->CurrentFilename[Length])&& (SearchRecord->CurrentFilename[Length] != DIRECTORY_SEPARATOR) ) Length++; // Match the filename against the one given for(i = 0;i < Length;i++) { if ((Filename[i] == DIRECTORY_SEPARATOR)|| (!Filename[i])|| (UPPERCASE(Filename[i]) != UPPERCASE(SearchRecord->CurrentFilename[i]))) break; } // If it matched, exit if ((i == Length)&&((Filename[i] == 0) ||(Filename[i] == DIRECTORY_SEPARATOR))) break; } // If we reached the end of the dir without matching, fail if (ReturnCode == XDVDFS_NO_MORE_FILES) return XDVDFS_FILE_NOT_FOUND; // If any other error occured, fail if (ReturnCode != XDVDFS_NO_ERROR) return ReturnCode; // Match next part of the given filename Filename += Length; } // If we land here, everything matched and the SEARCH_RECORD structure is // filled. return XDVDFS_NO_ERROR; }