MTNSVR *getinfo() { MTNSVR *s; MTNSVR *members = NULL; MTNSVR *svrlist = NULL; svrlist = mtn_info(mtn); for(s=svrlist;s;s=s->next){ if(is_execute(s)){ members = pushsvr(members, s); } } clrsvr(svrlist); return(members); }
static void exe_n_cwd_tab_completion(char *command, int type) { DIR *dir; struct dirent *next; char dirbuf[BUFSIZ]; struct stat st; char *path1[1]; char **paths = path1; int npaths; int i; char *found; char *pfind = strrchr(command, '/'); path1[0] = "."; if (pfind == NULL) { /* no dir, if flags==EXE_ONLY - get paths, else "." */ npaths = path_parse(&paths, type); pfind = command; } else { /* with dir */ /* save for change */ strcpy(dirbuf, command); /* set dir only */ dirbuf[(pfind - command) + 1] = 0; #ifdef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION if (dirbuf[0] == '~') /* ~/... or ~user/... */ username_tab_completion(dirbuf, dirbuf); #endif /* "strip" dirname in command */ pfind++; paths[0] = dirbuf; npaths = 1; /* only 1 dir */ } for (i = 0; i < npaths; i++) { dir = opendir(paths[i]); if (!dir) /* Don't print an error */ continue; while ((next = readdir(dir)) != NULL) { char *str_found = next->d_name; int add_chr = 0; /* matched ? */ if (strncmp(str_found, pfind, strlen(pfind))) continue; /* not see .name without .match */ if (*str_found == '.' && *pfind == 0) { if (*paths[i] == '/' && paths[i][1] == 0 && str_found[1] == 0) str_found = ""; /* only "/" */ else continue; } found = concat_path_file(paths[i], str_found); /* hmm, remover in progress? */ if (stat(found, &st) < 0) goto cont; /* find with dirs ? */ if (paths[i] != dirbuf) strcpy(found, next->d_name); /* only name */ if (S_ISDIR(st.st_mode)) { /* name is directory */ char *e = found + strlen(found) - 1; add_chr = '/'; if(*e == '/') *e = '\0'; } else { /* not put found file if search only dirs for cd */ if (type == FIND_DIR_ONLY) goto cont; if (type == FIND_FILE_ONLY || (type == FIND_EXE_ONLY && is_execute(&st))) add_chr = ' '; } /* Add it to the list */ add_match(found, add_chr); continue; cont: free(found); } closedir(dir); } if (paths != path1) { free(paths[0]); /* allocated memory only in first member */ free(paths); } }