6 static int is_w32_binary(const char* cmd)
10 GetBinaryType(cmd, &binary_type);
12 if(SCS_32BIT_BINARY == binary_type || SCS_64BIT_BINARY == binary_type || SCS_64BIT_BINARY == binary_type)
20 is_cmd(char** path, char** builtin, const char* p)
26 struct stat stat_buff = {0};
27 char command[PATH_MAX + 1] = {0};
28 char buff[PATH_MAX + 1] = {0};
30 size_t len = strlen(p);
37 if(p[i] != ' ' && p[i] != '\t' && p[i] != '>')
45 /* check first if it's a shell buitin */
49 for(i = 0; builtin[i] != NULL; i++)
51 if(!strcmp(builtin[i], command))
56 if(stat(command, &stat_buff) || !S_ISREG(stat_buff.st_mode))
60 for (i = 0; path[i] != NULL; i++)
62 sprintf(buff,"%s/%s",path[i], command);
64 if(!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode))
67 if(is_w32_binary(buff))
71 if(!access(buff, X_OK))
84 if(is_w32_binary(command))
87 if(!access(command, X_OK))
92 return yes ? 0 : ECMDNOTFOUND;