int enumDB_SkinObjectsForEditorProc(const char *szSetting,LPARAM lParam) { if (wildcmp((char *)szSetting,gl_Mask,0)||wildcmp((char *)szSetting,"$*",0)) { char * value; char *desc; char *descKey; descKey=mir_strdup(szSetting); descKey[0]='%'; value= ModernGetStringA(NULL,SKIN,szSetting); desc= ModernGetStringA(NULL,SKIN,descKey); if (wildcmp(value,"?lyph*",0)) { OPT_OBJECT_DATA * a=(OPT_OBJECT_DATA*)mir_alloc(sizeof(OPT_OBJECT_DATA)); a->szPath=desc; a->szName=mir_strdup(szSetting); a->szValue=value; a->szTempValue=NULL; TreeAddObject(gl_Dlg,gl_controlID,a); } else { if (value) mir_free_and_nill(value); if (desc) mir_free_and_nill(desc); } mir_free_and_nill(descKey); } return 0; }
/* * Find ANODE by name & type * * Returns match type in *pisapp: * TRUE if name matches application name * FALSE if name matches data name */ ANODE *app_afind_by_name(WORD atype, BYTE *pspec, BYTE *pname, WORD *pisapp) { ANODE *pa; WORD match; BYTE pathname[MAXPATHLEN]; strcpy(pathname,pspec); /* build full pathname */ strcpy(filename_start(pathname),pname); for (pa = G.g_ahead; pa; pa = pa->a_next) { if ((pa->a_type == atype) && !(pa->a_flags & AF_ISDESK)) { if (wildcmp(pa->a_pdata, pname)) { *pisapp = FALSE; return pa; } if ((pa->a_pappl[0] == '*') || (pa->a_pappl[0] == '?')) match = wildcmp(pa->a_pappl, pname); else match = !strcmp(pa->a_pappl, pathname); if (match) { *pisapp = TRUE; return pa; } } } return NULL; }
bool UPolyItem::match(const char * wildname) { const char * p1; bool result; int n; // if (true) { result = wildcmp(wildname, name); } else { p1 = strchr(wildname, '*'); if (p1 != NULL) { n = p1 - wildname; if ((unsigned int)n <= strlen(name)) result = strncasecmp(name, wildname, n) == 0; else result = false; } else result = isA(wildname); } return result; }
void* AddTempGroup(HWND hwnd, ClcData *dat, const TCHAR *szName) { int i = 0; int f = 0; DWORD groupFlags; if (wildcmp(_T2A(szName), "-@-HIDDEN-GROUP-@-")) return NULL; for (i = 1;; i++) { TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) break; if (!mir_tstrcmpi(szGroupName, szName)) f = 1; } if (f) return NULL; char buf[20]; _itoa_s(i - 1, buf, 10); TCHAR b2[255]; mir_sntprintf(b2, _T("#%s"), szName); b2[0] = 1 | GROUPF_EXPANDED; db_set_ws(NULL, "CListGroups", buf, b2); pcli->pfnGetGroupName(i, &groupFlags); return cli_AddGroup(hwnd, dat, szName, groupFlags, i, 0); }
bool BundleCompiler::compile_all(const char* platform) { for (u32 i = 0; i < vector::size(_files); ++i) { const char* filename = _files[i].c_str(); bool ignore = false; for (u32 gg = 0; gg < vector::size(_globs); ++gg) { const char* glob = _globs[gg].c_str(); if (wildcmp(glob, filename)) { ignore = true; break; } } const char* type = path::extension(filename); if (ignore || type == NULL) continue; char name[256]; const u32 size = u32(type - filename - 1); strncpy(name, filename, size); name[size] = '\0'; if (!compile(type, name, platform)) return false; } return true; }
bool KeepDropSwitch::getFlag(const std::string& astring) const { bool flag = true; for(const auto& cmdline : m_commandlines) { std::vector<std::string> words = split(cmdline, ' '); if(words.size()!=2) { std::ostringstream msg; msg << "malformed command string : " << cmdline; throw std::invalid_argument(msg.str()); } std::string cmd = words[0]; std::string pattern = words[1]; Cmd theCmd = UNKNOWN; if(cmd == "keep") theCmd = KEEP; else if (cmd == "drop") theCmd = DROP; else { std::ostringstream msg; msg << "malformed command in line: " << std::endl; msg << cmdline << std::endl; msg << "should be keep or drop, lower case" << std::endl; throw std::invalid_argument(msg.str()); } bool match = wildcmp(pattern.c_str(), astring.c_str()); if(not match) continue; else if (theCmd == KEEP) flag = true; else flag = false; } return flag; }
static DOMAIN_PIECE *find_host_piece(DOMAIN_LEVEL *level_ptr,int flags, char *host_piece,char *user) { DOMAIN_PIECE *ptr; DOMAIN_PIECE *piece_ptr; int index; index = *host_piece&(MAX_PIECE_LIST-1); piece_ptr = level_ptr->piece_list[index]; for(ptr=piece_ptr;ptr;ptr=ptr->next_piece) { if(!wildcmp(ptr->host_piece,host_piece) && (ptr->flags & flags)) { return(ptr); } } index = '*'&(MAX_PIECE_LIST-1); piece_ptr = level_ptr->piece_list[index]; for(ptr=piece_ptr;ptr;ptr=ptr->next_piece) { if( ((ptr->host_piece[0] == '*') && (ptr->host_piece[1] == '\0')) && (ptr->flags & flags)) { return(ptr); } } return((DOMAIN_PIECE *)NULL); }
void* AddTempGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { int i = 0; int f = 0; DWORD groupFlags; if (wildcmp(_T2A(szName), "-@-HIDDEN-GROUP-@-")) return NULL; for (i = 1;; i++) { TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) break; if (!mir_tstrcmpi(szGroupName, szName)) f = 1; } if (!f) { char buf[20]; TCHAR b2[255]; void * res = NULL; mir_snprintf(buf, SIZEOF(buf), "%d", (i - 1)); mir_sntprintf(b2, SIZEOF(b2), _T("#%s"), szName); b2[0] = 1 | GROUPF_EXPANDED; db_set_ws(NULL, "CListGroups", buf, b2); pcli->pfnGetGroupName(i, &groupFlags); res = cli_AddGroup(hwnd, dat, szName, groupFlags, i, 0); return res; } return NULL; }
int searchRecursive(LPSTR lpszPath, char **filter, int nFilts, int cnt, mxArray *structOut, const char *defaultPath) { int ii, passes; WIN32_FIND_DATA WFD; HANDLE hSearch; CHAR szFilePath[MAX_PATH + 1]; char defaultPathNew[MAX_PATH + 1]; PathCombine(szFilePath, lpszPath, "*"); hSearch = FindFirstFile(szFilePath,&WFD); do { if(strcmp(WFD.cFileName,"..") && strcmp(WFD.cFileName,".")) { if(WFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { PathCombine(szFilePath, lpszPath, WFD.cFileName); PathCombine(defaultPathNew,defaultPath,WFD.cFileName); cnt = searchRecursive(szFilePath, filter, nFilts, cnt, structOut, &defaultPathNew); } } passes = 0; for (ii = 0; ii < nFilts; ii++) { if (wildcmp(filter[ii],WFD.cFileName)){ passes = 1; break; } } if (passes){ addResultsEntry(WFD, cnt, structOut, defaultPath); cnt++; } } while (FindNextFile(hSearch,&WFD)); FindClose(hSearch); return(cnt); }
bool account_table::wildcmp(char *first, char * second) { if(*first == '\0' && *second == '\0') return true; // If we reach at the end of both strings, we are done if(*first == '?' && *second == '\0') return false; if(*first == '*' && *second == '\0' && *(first+1) == '*') return wildcmp(first+1,second); if(*first == '*' && *(first+1) != '\0' && *second == '\0') return false; /********************************************************************* * If the first string contains '?', or current characters of both * * strings match * *********************************************************************/ if (*first == '?' || *first == *second) return wildcmp(first+1, second+1); /********************************************************************* * If there is *, then there are two possibilities * * a) We consider current character of second string * * b) We ignore current character of second string. * *********************************************************************/ if (*first == '*') return wildcmp(first+1, second) || wildcmp(first, second+1); return false; }
WORD x_wildcmp( BYTE *source, BYTE *dest ) { if ( *source ) { if ( *scasb( source, '*' ) ) return( wildcmp( source, g_name( dest ) ) ); else return( strcmp( source, dest ) ); } return( FALSE ); }
size_t FileList::wild_search(std::string search, size_t start) const { search = strLower(search); std::string temp; for (size_t i = start+1; i < files.size(); i++) { temp = strLower(files[i]); if (wildcmp(search.c_str(), temp.c_str())) return i; } return -1; //invalid }
static int FSGZIP_EnumerateFiles (void *handle, char *match, int (*func)(char *, int, void *), void *parm) { gzipfile_t *gzip = handle; if (wildcmp(match, gzip->file.name)) { if (!func(gzip->file.name, gzip->file.filelen, parm)) return false; } return true; }
const char * find_next() { entry = readdir(dp); if (entry == NULL) return NULL; else { const char * name = make_find_res(entry->d_name); if ( wildcmp(find_pattern, name) ) { return name; } else return find_next(); } };
void BankUMap::findAccount(const string& reg_exp) { RecommendId vec; vec.clear(); for (UMap::iterator it = umap.begin(); it != umap.end(); ++it) { if (wildcmp(reg_exp.c_str(), (it->first).c_str()) && (it->first) != current_login_user) vec.push_back(it->first); } if ((int)vec.size() > 0) { sort(vec.begin(), vec.end()); cout << vec[0]; for (int i = 1; i < (int)vec.size(); ++i) cout << "," << vec[i]; } cout << "\n"; }
APP * app_icon( REG BYTE *name, WORD type, WORD *icon ) /* looking for same type */ /* icon number */ { REG APP *app; app = applist; *icon = 4; /* default icon index */ while( app ) { if ( type != -1 ) /* match the type */ { if ( app->a_type == type ) { if ( wildcmp( app->a_doc, name ) ) { *icon = app->a_dicon; break; } } } else { if ( app->a_type != FOLDER ) /* skip this */ { if ( x_wildcmp( app->a_name, name ) ) { *icon = app->a_icon; break; } if ( ( app->a_type == ICONS ) || ( app->a_type == TEXT ) ) { if ( x_wildcmp( app->a_doc, name ) ) { *icon = app->a_dicon; break; } } } } app = (APP *)app->a_next; /* JTT - (APP *) */ }/* while */ return( app ); }
static int FSPAK_EnumerateFiles (void *handle, char *match, int (*func)(char *, int, void *), void *parm) { pack_t *pak = handle; int num; for (num = 0; num<(int)pak->numfiles; num++) { if (wildcmp(match, pak->files[num].name)) { if (!func(pak->files[num].name, pak->files[num].filelen, parm)) return false; } } return true; }
bool RosoutTextFilter::filterString(const std::string& str) const { bool match = false; if (use_regex_) { if (regex_valid_) { match = boost::regex_match(str, regex_); } } else { std::string lower_str = boost::algorithm::to_lower_copy(str); std::string lower_text = "*" + boost::algorithm::to_lower_copy(text_) + "*"; match = wildcmp(lower_text.c_str(), lower_str.c_str()); } return match; }
BOOTIL_EXPORT int FindFiles( String::List* files, String::List* folders, const BString& strFind, bool bUpUpFolders ) { BString dirName = strdup( strFind.c_str() ); dirName = dirname( (char*)dirName.c_str() ); BString findName = strdup( strFind.c_str() ); findName = basename( (char*)findName.c_str() ); DIR *dp; dirent *dirp; int iFiles = 0; if ( (dp = opendir(dirName.c_str())) == NULL ) return 0; while ( (dirp = readdir(dp)) != NULL ) { BString name(dirp->d_name); BString fullName = dirName + "/" + name; if ( wildcmp(findName.c_str(), name.c_str()) ) { if ( Bootil::File::IsFolder(fullName) && folders ) { if ( bUpUpFolders || (name != "." && name != "..") ) { folders->push_back( fullName ); iFiles++; } } else if ( files ) { files->push_back( fullName ); iFiles++; } } } closedir(dp); return iFiles; }
static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector<cv::String>& result, bool recursive) { DIR *dir; struct dirent *ent; if ((dir = opendir (directory.c_str())) != 0) { /* find all the files and directories within directory */ try { while ((ent = readdir (dir)) != 0) { const char* name = ent->d_name; if((name[0] == 0) || (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0)) continue; cv::String path = directory + native_separator + name; if (isDir(path, dir)) { if (recursive) glob_rec(path, wildchart, result, recursive); } else { if (wildchart.empty() || wildcmp(name, wildchart.c_str())) result.push_back(path); } } } catch (...) { closedir(dir); throw; } closedir(dir); } else CV_Error(CV_StsObjectNotFound, cv::format("could not open directory: %s", directory.c_str())); }
void * AddTempGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers) { int i=0; int f=0; TCHAR * szGroupName; DWORD groupFlags; #ifdef UNICODE char *mbuf=mir_u2a((TCHAR *)szName); #else char *mbuf=mir_strdup((char *)szName); #endif if (wildcmp(mbuf,"-@-HIDDEN-GROUP-@-",0)) { mir_free_and_nill(mbuf); return NULL; } mir_free_and_nill(mbuf); for(i=1;;i++) { szGroupName = pcli->pfnGetGroupName(i,&groupFlags); if(szGroupName==NULL) break; if (!mir_tstrcmpi(szGroupName,szName)) f=1; } if (!f) { char buf[20]; TCHAR b2[255]; void * res=NULL; mir_snprintf(buf,SIZEOF(buf),"%d",(i-1)); mir_sntprintf(b2,SIZEOF(b2),_T("#%s"),szName); b2[0]=1|GROUPF_EXPANDED; ModernWriteSettingTString(NULL,"CListGroups",buf,b2); pcli->pfnGetGroupName(i,&groupFlags); res=cli_AddGroup(hwnd,dat,szName,groupFlags,i,0); return res; } return NULL; }
int search(LPSTR lpszPath, char **filter, int nFilts, int cnt, mxArray *structOut, char *defaultPath) { int ii, passes; WIN32_FIND_DATA WFD; HANDLE hSearch; CHAR szFilePath[MAX_PATH + 1]; PathCombine(szFilePath, lpszPath, "*"); hSearch = FindFirstFile(szFilePath,&WFD); do { passes = 0; for (ii = 0; ii < nFilts; ii++) { if (wildcmp(filter[ii],WFD.cFileName)){ passes = 1; break; } } if (passes){ addResultsEntry(WFD, cnt, structOut, defaultPath); cnt++; } } while (FindNextFile(hSearch,&WFD)); FindClose(hSearch); return(cnt); }
void BankRBTree::findAccount(const string& reg_exp){ RecommendId vec; vec.clear(); //construct traverser rb_traverser bank_traverser; rb_t_init(&bank_traverser, rb_tree); //traverse all rb_tree DataNode* res = (DataNode*)rb_t_first(&bank_traverser, rb_tree); while(res != NULL){ if (wildcmp(reg_exp.c_str(), (*(res->first)).c_str()) && (*(res->first)) != current_login_user){ vec.push_back(*(res->first)); cout << (*(res->first)) << "\n"; } res = (DataNode*)rb_t_next(&bank_traverser); } if (vec.size() > 0) { sort(vec.begin(), vec.end()); cout << vec[0]; for (int i = 1; i < vec.size(); ++i) cout << "," << vec[i]; } cout << "\n"; }
static WORD fs_active(BYTE *ppath, BYTE *pspec, WORD *pcount) { WORD ret; LONG thefile, fs_index, temp; register WORD i, j, gap; BYTE *fname, allpath[LEN_ZPATH+1]; gsx_mfset(ad_hgmice); thefile = 0L; fs_index = 0L; strcpy(allpath, ppath); /* 'allpath' gets all files */ fname = fs_back(allpath,NULL); strcpy(fname+1,"*.*"); dos_sdta((LONG)D.g_dta); ret = dos_sfirst(allpath, F_SUBDIR); while ( ret ) { /* if it is a real file */ /* or directory then */ /* save it and set */ /* first byte to tell */ /* which */ if (D.g_dta[30] != '.') { D.g_dta[29] = (D.g_dta[21] & F_SUBDIR) ? 0x07 : ' '; if ( (D.g_dta[29] == 0x07) || (wildcmp(pspec, &D.g_dta[30])) ) { fs_index = fs_add(thefile, fs_index); thefile++; } } ret = dos_snext(); if (thefile >= nm_files) { ret = FALSE; sound(TRUE, 660, 4); } } *pcount = thefile; /* sort files using shell*/ /* sort on page 108 of */ /* K&R C Prog. Lang. */ for(gap = thefile/2; gap > 0; gap /= 2) { for(i = gap; i < thefile; i++) { for (j = i-gap; j >= 0; j -= gap) { if ( fs_comp(ad_fsnames+g_fslist[j],ad_fsnames+g_fslist[j+gap]) <= 0 ) break; temp = g_fslist[j]; g_fslist[j] = g_fslist[j+gap]; g_fslist[j+gap] = temp; } } } gsx_mfset( ad_armice ); return(TRUE); }
int anetSSLGenericConnect( char* err, char* addr, int port, int flags, anetSSLConnection* sslctn, char* certFilePath, char* certDirPath, char* checkCommonName ) { sslctn->sd = -1; sslctn->ctx = NULL; sslctn->ssl = NULL; sslctn->bio = NULL; sslctn->conn_str = NULL; // Set up a SSL_CTX object, which will tell our BIO object how to do its work SSL_CTX* ctx = SSL_CTX_new(TLSv1_1_client_method()); sslctn->ctx = ctx; // Create a SSL object pointer, which our BIO object will provide. SSL* ssl; // Create our BIO object for SSL connections. BIO* bio = BIO_new_ssl_connect(ctx); sslctn->bio = bio; // Failure? if (bio == NULL) { char errorbuf[1024]; ERR_error_string(1024,errorbuf); anetSetError(err, "SSL Error: Error creating BIO: %s\n", errorbuf); // We need to free up the SSL_CTX before we leave. anetCleanupSSL( sslctn ); return ANET_ERR; } // Makes ssl point to bio's SSL object. BIO_get_ssl(bio, &ssl); sslctn->ssl = ssl; // Set the SSL to automatically retry on failure. SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); char* connect_str = (char *)calloc( 1, strlen( addr ) + 10 ); sprintf( connect_str, "%s:%d", addr, port ); sslctn->conn_str = connect_str; // We're connection to to the redis server at IP:port. BIO_set_conn_hostname(bio, connect_str); SSL_CTX_load_verify_locations(ctx, certFilePath, certDirPath); // Same as before, try to connect. if (BIO_do_connect(bio) <= 0) { char errorbuf[1024]; ERR_error_string(1024,errorbuf); anetSetError(err, "SSL Error: Failed to connect: %s\n", errorbuf); anetCleanupSSL( sslctn ); return ANET_ERR; } // Now we need to do the SSL handshake, so we can communicate. if (BIO_do_handshake(bio) <= 0) { char errorbuf[1024]; ERR_error_string(1024,errorbuf); anetSetError(err, "SSL Error: handshake failure: %s\n", errorbuf); anetCleanupSSL( sslctn ); return ANET_ERR; } long verify_result = SSL_get_verify_result(ssl); if( verify_result == X509_V_OK) { X509* peerCertificate = SSL_get_peer_certificate(ssl); char commonName [512]; X509_NAME * name = X509_get_subject_name(peerCertificate); X509_NAME_get_text_by_NID(name, NID_commonName, commonName, 512); if( checkCommonName != NULL && strlen( checkCommonName ) > 0 ) { if(wildcmp(commonName, checkCommonName, strlen(checkCommonName)) == 0) { anetSetError(err, "SSL Error: Error validating peer common name: %s\n", commonName); anetCleanupSSL( sslctn ); return ANET_ERR; } } } else { char errorbuf[1024]; ERR_error_string(1024,errorbuf); anetSetError(err, "SSL Error: Error retrieving peer certificate: %s\n", errorbuf); anetCleanupSSL( sslctn ); return ANET_ERR; } int s = BIO_get_fd( bio, NULL ); if (flags & ANET_CONNECT_NONBLOCK) { if (anetNonBlock(err,s) != ANET_OK) return ANET_ERR; } return s; }
void FileList::GetList(const std::string &dir, const std::string &filter) { unsigned int numFiles = 0; files.resize(50); // good starting number #if defined(_WIN32) // ------------------------------ // Windows Implementation // ------------------------------ WIN32_FIND_DATA FoundFile; memset((char*)&FoundFile, 0, sizeof(WIN32_FIND_DATA)); HANDLE DirHandle; std::string SearchPattern = dir + "\\" + filter ; DirHandle = FindFirstFile(SearchPattern.c_str(), &FoundFile); if(DirHandle != INVALID_HANDLE_VALUE) { do { if (!(FoundFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && std::string(FoundFile.cFileName) != "") { if (numFiles >= files.size()) files.resize(files.size()*2); files[numFiles] = FoundFile.cFileName; numFiles++; } } while (FindNextFile(DirHandle, &FoundFile)); FindClose(DirHandle); } #else // ------------------------------ // Linux Implementation // ------------------------------ DIR* mydir; mydir = opendir(dir.c_str()); dirent *curfile; std::string lfilter(filter.size(), '\0'); std::transform(filter.begin(), filter.end(), lfilter.begin(), tolower); std::string dname; if (mydir) { while ((curfile = readdir(mydir)) != NULL) { dname = curfile->d_name; std::transform(dname.begin(), dname.end(), dname.begin(), tolower); if (wildcmp(lfilter.c_str(), dname.c_str())) { if (numFiles >= files.size()) files.resize(files.size()*2); files[numFiles] = curfile->d_name; numFiles++; } } closedir(mydir); } #endif listeddir = dir; files.resize(numFiles); }
int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm) { HANDLE r; WIN32_FIND_DATA fd; char apath[MAX_OSPATH]; char apath2[MAX_OSPATH]; char file[MAX_OSPATH]; char *s; int go; if (!gpath) return 0; snprintf(apath, sizeof(apath), "%s/%s", gpath, match); for (s = apath+strlen(apath)-1; s> apath; s--) { if (*s == '/') break; } *s = '\0'; // This is what we ask windows for. snprintf(file, sizeof(file), "%s/*.*", apath); // We need to make apath contain the path in match but not gpath strlcpy(apath2, match, sizeof(apath)); match = s+1; for (s = apath2+strlen(apath2)-1; s> apath2; s--) { if (*s == '/') break; } *s = '\0'; if (s != apath2) strlcat (apath2, "/", sizeof (apath2)); r = FindFirstFile(file, &fd); if (r==(HANDLE)-1) return 1; go = true; do { if (*fd.cFileName == '.'); // Don't ever find files with a name starting with '.' else if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //is a directory { if (wildcmp(match, fd.cFileName)) { snprintf(file, sizeof(file), "%s%s/", apath2, fd.cFileName); go = func(file, fd.nFileSizeLow, parm); } } else { if (wildcmp(match, fd.cFileName)) { snprintf(file, sizeof(file), "%s%s", apath2, fd.cFileName); go = func(file, fd.nFileSizeLow, parm); } } } while(FindNextFile(r, &fd) && go); FindClose(r); return go; }
int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm) { DIR *dir, *dir2; char apath[MAX_OSPATH]; char file[MAX_OSPATH]; char truepath[MAX_OSPATH]; char *s; struct dirent *ent; //printf("path = %s\n", gpath); //printf("match = %s\n", match); if (!gpath) gpath = ""; *apath = '\0'; strncpy(apath, match, sizeof(apath)); for (s = apath+strlen(apath)-1; s >= apath; s--) { if (*s == '/') { s[1] = '\0'; match += s - apath+1; break; } } if (s < apath) //didn't find a '/' *apath = '\0'; snprintf(truepath, sizeof(truepath), "%s/%s", gpath, apath); //printf("truepath = %s\n", truepath); //printf("gamepath = %s\n", gpath); //printf("apppath = %s\n", apath); //printf("match = %s\n", match); dir = opendir(truepath); if (!dir) { Con_DPrintf("Failed to open dir %s\n", truepath); return true; } do { ent = readdir(dir); if (!ent) break; if (*ent->d_name != '.') if (wildcmp(match, ent->d_name)) { snprintf(file, sizeof(file), "%s/%s", truepath, ent->d_name); //would use stat, but it breaks on fat32. if ((dir2 = opendir(file))) { closedir(dir2); snprintf(file, sizeof(file), "%s%s/", apath, ent->d_name); //printf("is directory = %s\n", file); } else { snprintf(file, sizeof(file), "%s%s", apath, ent->d_name); //printf("file = %s\n", file); } if (!func(file, -2, parm)) { closedir(dir); return false; } } } while(1); closedir(dir); return true; }
INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) { PCheckProcParam pcpp = (PCheckProcParam)wParam; if (!pcpp) return TRUE; PMO_IntMenuItem timi = MO_GetIntMenuItem(pcpp->MenuItemHandle); if (!timi) return TRUE; StatusMenuExecParam *smep = (StatusMenuExecParam*)pcpp->MenuItemOwnerData; if (smep && !smep->status && smep->custom) { if (wildcmp(smep->svc, "*XStatus*")) { int XStatus; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_MASK_STATUS; cs.status = &XStatus; if (CallProtoServiceInt(NULL, smep->proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0) XStatus = 0; char buf[255]; mir_snprintf(buf, SIZEOF(buf), "*XStatus%d", XStatus); bool check = wildcmp(smep->svc, buf) != 0; bool reset = wildcmp(smep->svc, "*XStatus0") != 0; if (check) timi->mi.flags |= CMIF_CHECKED; else timi->mi.flags &= ~CMIF_CHECKED; if (reset || check) { PMO_IntMenuItem timiParent = MO_GetIntMenuItem(timi->mi.root); if (timiParent) { CLISTMENUITEM mi2 = { sizeof(mi2) }; mi2.flags = CMIM_NAME | CMIF_TCHAR; mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status")); timiParent = MO_GetIntMenuItem(timi->mi.root); MenuItemData it = { 0 }; if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) { MENUITEMINFO mi = { 0 }; TCHAR d[100]; GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION); mi.cbSize = sizeof(mi); mi.fMask = MIIM_STRING | MIIM_STATE; if (timi->iconId != -1) { mi.fMask |= MIIM_BITMAP; if (IsWinVerVistaPlus() && IsThemeActive()) { if (timi->hBmp == NULL) timi->hBmp = ConvertIconToBitmap(NULL, timi->parent->m_hMenuIcons, timi->iconId); mi.hbmpItem = timi->hBmp; } else mi.hbmpItem = HBMMENU_CALLBACK; } mi.fState |= (check && !reset ? MFS_CHECKED : MFS_UNCHECKED); mi.dwTypeData = mi2.ptszName; SetMenuItemInfo(it.OwnerMenu, it.position, TRUE, &mi); } Menu_ModifyItem(timi->mi.root, &mi2); timiParent->iconId = timi->iconId; if (timiParent->hBmp) DeleteObject(timiParent->hBmp); timiParent->hBmp = NULL; } } } } else if (smep && smep->status && !smep->custom) { int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL, smep->proto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(NULL); if (smep->status == curProtoStatus) timi->mi.flags |= CMIF_CHECKED; else timi->mi.flags &= ~CMIF_CHECKED; } else if ((!smep || smep->proto) && timi->mi.pszName) { int curProtoStatus = 0; BOOL IconNeedDestroy = FALSE; char* prot; if (smep) prot = smep->proto; else { char *prn = mir_u2a(timi->mi.ptszName); prot = NEWSTR_ALLOCA(prn); if (prn) mir_free(prn); } if (Proto_GetAccount(prot) == NULL) return TRUE; if ((curProtoStatus = CallProtoServiceInt(NULL, prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND) curProtoStatus = 0; if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE) timi->mi.hIcon = LoadSkinProtoIcon(prot, curProtoStatus); else { timi->mi.hIcon = (HICON)CallProtoServiceInt(NULL, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND) timi->mi.hIcon = NULL; else IconNeedDestroy = TRUE; } if (timi->mi.hIcon) { timi->mi.flags |= CMIM_ICON; MO_ModifyMenuItem(timi, &timi->mi); if (IconNeedDestroy) { DestroyIcon(timi->mi.hIcon); timi->mi.hIcon = NULL; } else IcoLib_ReleaseIcon(timi->mi.hIcon, 0); } } return TRUE; }
void FindThreadSingle(FindThreadSingleArg *arg) { TCHAR host[100]; char str[100]; SOCKET sock; if (arg->list->GetItemText(arg->i, 0, host, 100) == 0) { ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } if (arg->wildcard && (!wildcmp(arg->wildstr, host))) { ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } ::PostMessage(arg->hWnd, WM_USER+1, arg->i, TRUE); if (arg->fast) { if (ConnectToMPDquick(host, arg->port, arg->phrase, &sock) != 0) { ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } } else { if (ConnectToMPD(host, arg->port, arg->phrase, &sock) != 0) { ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } } if (WriteString(sock, "version") == SOCKET_ERROR) { printf("WriteString failed after attempting passphrase authentication: %d\n", WSAGetLastError());fflush(stdout); easy_closesocket(sock); ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } if (!ReadString(sock, str)) { ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); delete arg; return; } WriteString(sock, "done"); easy_closesocket(sock); if (mpd_version_string_to_int(str) == 0) ::PostMessage(arg->hWnd, WM_USER+1, arg->i, FALSE); else ::PostMessage(arg->hWnd, WM_USER+2, arg->i, TRUE); delete arg; }