rendered paste bodystatic void DoAutoExec(void){ HANDLE hFind; char szMirandaDir[MAX_PATH],szUse[7],szIniPath[MAX_PATH],szFindPath[MAX_PATH],szExpandedFindPath[MAX_PATH]; char szLine[2048]; char *str2; WIN32_FIND_DATAA fd; FILE *fp; char szSection[128]; int lineLength; char szSafeSections[2048],szUnsafeSections[2048],szSecurity[11],szOverrideSecurityFilename[MAX_PATH]; int warnThisSection=0; GetPrivateProfileStringA("AutoExec","Use","prompt",szUse,sizeof(szUse),mirandabootini); if(!lstrcmpiA(szUse,"no")) return; GetPrivateProfileStringA("AutoExec","Safe","CLC Icons CLUI CList SkinSounds",szSafeSections,sizeof(szSafeSections),mirandabootini); GetPrivateProfileStringA("AutoExec","Unsafe","ICQ MSN",szUnsafeSections,sizeof(szUnsafeSections),mirandabootini); GetPrivateProfileStringA("AutoExec","Warn","notsafe",szSecurity,sizeof(szSecurity),mirandabootini); GetPrivateProfileStringA("AutoExec","OverrideSecurityFilename","",szOverrideSecurityFilename,sizeof(szOverrideSecurityFilename),mirandabootini); GetModuleFileNameA(GetModuleHandle(NULL),szMirandaDir,sizeof(szMirandaDir)); str2=strrchr(szMirandaDir,'\\'); if(str2!=NULL) *str2=0; _chdir(szMirandaDir); GetPrivateProfileStringA("AutoExec","Glob","autoexec_*.ini",szFindPath,sizeof(szFindPath),mirandabootini); ExpandEnvironmentStringsA(szFindPath,szExpandedFindPath,sizeof(szExpandedFindPath)); hFind=FindFirstFileA(szExpandedFindPath,&fd); if(hFind==INVALID_HANDLE_VALUE) return; str2=strrchr(szExpandedFindPath,'\\'); if(str2==NULL) str2=szExpandedFindPath; else str2++; *str2='\0'; szSection[0]='\0'; do { lstrcpyA(szIniPath,szExpandedFindPath); lstrcatA(szIniPath,fd.cFileName); if(!lstrcmpiA(szUse,"prompt") && lstrcmpiA(fd.cFileName,szOverrideSecurityFilename)) { int result=DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_INSTALLINI),NULL,InstallIniDlgProc,(LPARAM)szIniPath); if(result==IDC_NOTOALL) break; if(result==IDCANCEL) continue; } fp=fopen(szIniPath,"rt"); while(!feof(fp)) { if(fgets(szLine,sizeof(szLine),fp)==NULL) break; lineLength=lstrlenA(szLine); while(lineLength && szLine[lineLength-1]<=' ') szLine[--lineLength]='\0'; if(szLine[0]==';' || szLine[0]<=' ') continue; if(szLine[0]=='[') { char *szEnd=strchr(szLine+1,']'); if(szEnd==NULL) continue; if(szLine[1]=='!') szSection[0]='\0'; else { lstrcpynA(szSection,szLine+1,min(sizeof(szSection),szEnd-szLine)); if(!lstrcmpiA(szSecurity,"none")) warnThisSection=0; else if(!lstrcmpiA(szSecurity,"notsafe")) warnThisSection=!IsInSpaceSeparatedList(szSection,szSafeSections); else if(!lstrcmpiA(szSecurity,"onlyunsafe")) warnThisSection=IsInSpaceSeparatedList(szSection,szUnsafeSections); else warnThisSection=1; if(!lstrcmpiA(fd.cFileName,szOverrideSecurityFilename)) warnThisSection=0; } } else { char *szValue; char szName[128]; struct warnSettingChangeInfo_t warnInfo; if(szSection[0]=='\0') continue; szValue=strchr(szLine,'='); if(szValue==NULL) continue; lstrcpynA(szName,szLine,min(sizeof(szName),szValue-szLine+1)); szValue++; warnInfo.szIniPath=szIniPath; warnInfo.szName=szName; warnInfo.szSafeSections=szSafeSections; warnInfo.szSection=szSection; warnInfo.szUnsafeSections=szUnsafeSections; warnInfo.szValue=szValue; warnInfo.warnNoMore=0; warnInfo.cancel=0; if(!warnThisSection || IDNO!=DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_WARNINICHANGE),NULL,WarnIniChangeDlgProc,(LPARAM)&warnInfo)) { if(warnInfo.cancel) break; if(warnInfo.warnNoMore) warnThisSection=0; switch(szValue[0]) { case 'b': case 'B': DBWriteContactSettingByte(NULL,szSection,szName,(BYTE)strtol(szValue+1,NULL,0)); break; case 'w': case 'W': DBWriteContactSettingWord(NULL,szSection,szName,(WORD)strtol(szValue+1,NULL,0)); break; case 'd': case 'D': DBWriteContactSettingDword(NULL,szSection,szName,(DWORD)strtoul(szValue+1,NULL,0)); break; case 'l': case 'L': DBDeleteContactSetting(NULL,szSection,szName); break; case 's': case 'S': DBWriteContactSettingString(NULL,szSection,szName,szValue+1); break; case 'u': case 'U': DBWriteContactSettingStringUtf(NULL,szSection,szName,szValue+1); break; case 'n': case 'N': { PBYTE buf; int len; char *pszValue,*pszEnd; DBCONTACTWRITESETTING cws; buf=(PBYTE)mir_alloc(lstrlenA(szValue+1)); for(len=0,pszValue=szValue+1;;len++) { buf[len]=(BYTE)strtol(pszValue,&pszEnd,0x10); if(pszValue==pszEnd) break; pszValue=pszEnd; } cws.szModule=szSection; cws.szSetting=szName; cws.value.type=DBVT_BLOB; cws.value.pbVal=buf; cws.value.cpbVal=len; CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)(HANDLE)NULL,(LPARAM)&cws); mir_free(buf); } break; default: if(ServiceExists(MS_LANGPACK_TRANSLATESTRING)) MessageBox(NULL,TranslateT("Invalid setting type. The first character of every value must be b, w, d, l, s or n."),TranslateT("Install Database Settings"),MB_OK); else MessageBoxA(NULL,"Invalid setting type. The first character of every value must be b, w, d, l, s or n.","Install Database Settings",MB_OK); break; } } } } fclose(fp); if(!lstrcmpiA(fd.cFileName,szOverrideSecurityFilename)) DeleteFileA(szIniPath); else { char szOnCompletion[8]; GetPrivateProfileStringA("AutoExec","OnCompletion","recycle",szOnCompletion,sizeof(szOnCompletion),mirandabootini); if(!lstrcmpiA(szOnCompletion,"delete")) DeleteFileA(szIniPath); else if(!lstrcmpiA(szOnCompletion,"recycle")) { SHFILEOPSTRUCTA shfo={0}; shfo.wFunc=FO_DELETE; shfo.pFrom=szIniPath; szIniPath[lstrlenA(szIniPath)+1]='\0'; shfo.fFlags=FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT; SHFileOperationA(&shfo); } else if(!lstrcmpiA(szOnCompletion,"rename")) { char szRenamePrefix[MAX_PATH]; char szNewPath[MAX_PATH]; GetPrivateProfileStringA("AutoExec","RenamePrefix","done_",szRenamePrefix,sizeof(szRenamePrefix),mirandabootini); lstrcpyA(szNewPath,szExpandedFindPath); lstrcatA(szNewPath,szRenamePrefix); lstrcatA(szNewPath,fd.cFileName); MoveFileA(szIniPath,szNewPath); } else if(!lstrcmpiA(szOnCompletion,"ask")) DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_INIIMPORTDONE),NULL,IniImportDoneDlgProc,(LPARAM)szIniPath); } } while(FindNextFileA(hFind,&fd)); FindClose(hFind);}