char *MYRTLEXP StrCase( char *str,msCaseTypes type ) { int n; if ( !str || *str == 0 ) return str; switch( type ){ case mscLower: StrLwr( str ); break; case mscUpper: StrUpr( str ); break; case mscCapitalize: StrLwr( str ); str[0] = ToUpper(str[0]); break; case mscUpLower: for ( n = 0; str[n]; n++ ) if ( isLower(str[n]) ) return str; return StrCase( str,mscLower ); case mscLoUpper: for ( n = 0; str[n]; n++ ) if ( isUpper(str[n]) ) return str; return StrCase( str,mscUpper ); case mscInvert: for ( n = 0; str[n]; n++ ) if ( isUpper(str[n]) ) str[n] = ToLower(str[n]); else str[n] = ToUpper(str[n]); break; } return str; }
/** * Set a filesystem GUID according to the filesystem name * We use a static ID for the first 8 bytes, and then roll the lowercase name * for the last 8 bytes (eg. exfat => {'e', 'x', 'f', 'a', 't', 'e', 'x', 'f'}) */ EFI_GUID * GetFSGuid(VOID) { INTN i, j, k, Len = StrLen(ShortDriverName); static EFI_GUID Guid = { 0xEF1F5EF1, 0xF17E, 0x5857, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; CHAR16 *FsName = StrDuplicate(ShortDriverName); const CHAR16 *PlusName = L"plus"; UINT8 Data4[12]; /* +4 so that we can also reduce something like "1234567plus" into "1234567+" */ StrLwr(FsName); for (i = 0, j = 0, k = 0; j < ARRAYSIZE(Data4); i = (i+1)%Len, j++) { /* Convert any 'plus' that is part of the name to '+' */ if (FsName[i] == PlusName[k]) { if (++k == 4) { k = 0; j -= 3; Data4[j] = (UINT8) '+'; } else { Data4[j] = (UINT8) FsName[i]; } } else { k = 0; Data4[j] = (UINT8) FsName[i]; } } FreePool(FsName); CopyMem(Guid.Data4, Data4, 8); return &Guid; }
VOID AppendCSDGuid ( DEVICE_CONSIST_MAPPING_INFO *MappingItem, EFI_GUID *Guid ) { CHAR16 Buffer[64]; ASSERT(Guid != NULL); ASSERT(MappingItem != NULL); SPrint ( Buffer, 0, L"%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x", (UINTN) Guid->Data1, (UINTN) Guid->Data2, (UINTN) Guid->Data3, (UINTN) Guid->Data4[0], (UINTN) Guid->Data4[1], (UINTN) Guid->Data4[2], (UINTN) Guid->Data4[3], (UINTN) Guid->Data4[4], (UINTN) Guid->Data4[5], (UINTN) Guid->Data4[6], (UINTN) Guid->Data4[7] ); StrLwr (Buffer); AppendCSDStr (MappingItem, Buffer); }
EFI_STATUS AttribSet ( IN CHAR16 *Str, IN OUT UINT64 *Attr ) { // // Convert to Lower, lest case/break not equal // StrLwr (Str); while (*Str) { // // Check one by one // switch (*Str) { case 'b': EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF); break; case 'a': *Attr |= EFI_FILE_ARCHIVE; break; case 's': *Attr |= EFI_FILE_SYSTEM; break; case 'h': *Attr |= EFI_FILE_HIDDEN; break; case 'r': *Attr |= EFI_FILE_READ_ONLY; break; default: return EFI_INVALID_PARAMETER; } Str += 1; } return EFI_SUCCESS; }
MODULE classify_token_as_action (void) { typedef struct { /* Lookup table structure: */ char *name; /* Action name */ event_t event; /* Corresponding event */ } ACTION_LOOKUP; /* Table of actions */ /* arranged alphabetically for cosmetic purposes */ static ACTION_LOOKUP lookup [] = { { "animate", animate_event }, { "caps", caps_event }, { "check", check_event }, { "cobol", cobol_event }, { "defaults", defaults_event }, { "event", event_event }, { "exist", exist_event }, { "headline", headline_event }, { "module", module_event }, { "normal", normal_event }, { "not", not_event }, { "plain", plain_event }, { "state", state_event }, { "test", test_event }, { "title", title_event }, /* Sentinel marks end of table */ { NULL, other_event } }; ACTION_LOOKUP *lptr; /* Index into lookup table */ StrLwr (token); /* Actions names are lower-case */ for (lptr = lookup; lptr-> name; lptr++) if (streq (lptr-> name, token)) break; /* Scan till we find match, or end */ the_next_event = lptr-> event; /* and set appropriate event */ }
char *GetCurrentUserProfilePath() { char profilePath[_MAX_PATH] = ""; char partialPath[] = "Application Data\\Mozilla\\Firefox"; char profileFile[_MAX_PATH]; char line[1024]; DWORD pathSize = _MAX_PATH; char *finalProfilePath = NULL; int isDefaultFound = 0; HANDLE token; // Get current user's profile directory if( fOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == FALSE ) { //DisplayMesg(TYPE_DEBUG, "\n Failed to get current process token "); return NULL; } if( fGetUserProfileDirectory(token, profilePath, &pathSize) == FALSE ) { //DisplayMesg(TYPE_DEBUG, "\n Failed to get user profile directory"); return NULL; } //DisplayMesg(TYPE_DEBUG, "\n User Profile directory = %s", profilePath); // Get firefox profile directory strcpy(profileFile, profilePath); strcat(profileFile,"\\"); strcat(profileFile,partialPath); strcat(profileFile,"\\profiles.ini"); // Open the firefox profile setting file FILE *profile = fopen(profileFile, "r"); if( profile == NULL ) { //DisplayMesg(TYPE_DEBUG, "\n Unable to find firefox profile file : %s ", profileFile); return NULL; } // Check each line of profile settings file for line "name=default" string // This indicates that we are looking under default profile... // So one among next few lines will have path information..just copy that... while(fgets(line, 1024, profile)) { StrLwr(line); if( !isDefaultFound && ( strstr(line, "name=default") != NULL) ) { isDefaultFound = 1; continue; } // We have got default profile ..now check for path if( isDefaultFound ) { if( strstr(line,"path=") != NULL) { char *slash = strstr(line,"/"); if( slash != NULL ) *slash = '\\'; // remove \n from the end of line line[strlen(line)-1] = 0; char *start = strstr(line,"="); int totalLen = strlen(profilePath) + strlen(partialPath) + strlen(start) + 3 ; finalProfilePath = (char *) malloc(totalLen); if( finalProfilePath ) { strcpy(finalProfilePath,profilePath); strcat(finalProfilePath,"\\"); strcat(finalProfilePath,partialPath); strcat(finalProfilePath,"\\"); strcat(finalProfilePath,start+1); //DisplayMesg(TYPE_DEBUG, "\n Final profile path is : %s ", finalProfilePath); } break; } } } fclose(profile); return finalProfilePath; }