Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last change of Tesh2
[simgrid.git] / tools / tesh2 / src / is_cmd.c
index fd46515..528bc50 100644 (file)
@@ -2,20 +2,6 @@
 
 #include <explode.h>
 
-#ifdef WIN32
-static int is_w32_binary(const char* cmd)
-{
-       DWORD binary_type;
-
-       GetBinaryType(cmd, &binary_type);
-
-       if(SCS_32BIT_BINARY == binary_type || SCS_64BIT_BINARY == binary_type || SCS_64BIT_BINARY == binary_type)
-               return 1;
-
-       return 0;
-}
-#endif
-
 int
 is_cmd(char** path, char** builtin, const char* p)
 {
@@ -26,12 +12,12 @@ is_cmd(char** path, char** builtin, const char* p)
        struct stat stat_buff = {0};
        char command[PATH_MAX + 1] = {0};
        char buff[PATH_MAX + 1] = {0};
-       
-       size_t len = strlen(p);
-       
+       size_t len;
+
        if(!p)
                return EINVAL;
        
+       len = strlen(p);
        while(i < len)
        {
                if(p[i] != ' ' && p[i] != '\t' && p[i] != '>')
@@ -42,6 +28,7 @@ is_cmd(char** path, char** builtin, const char* p)
                i++;
        }
        
+       
        /* check first if it's a shell buitin */
        
        if(builtin)
@@ -59,34 +46,26 @@ is_cmd(char** path, char** builtin, const char* p)
                {
                        for (i = 0; path[i] != NULL; i++)
                        {
+                               
                                sprintf(buff,"%s/%s",path[i], command);
                                
                                if(!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode))
                                {
-                                       #ifdef WIN32
-                                       if(is_w32_binary(buff))
-                                               yes = 1;
-                                               break;
-                                       #else
+                                       
                                        if(!access(buff, X_OK))
                                        {
                                                yes = 1;
                                                break;
                                        }
-                                       #endif
                                }
                        }
                }
        }
        else
        {
-               #ifdef WIN32
-               if(is_w32_binary(command))
-                       yes = 1;                        
-               #else
+               
                if(!access(command, X_OK))
                        yes = 1;
-               #endif
        }
                
        return yes ? 0 : ECMDNOTFOUND;