-/*-----------------------------------------------------------------*/
-/* my_system - will call a program with arguments */
-/*-----------------------------------------------------------------*/
-
-
-
-
-//char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
-char *try_dir[] =
-{NULL, NULL}; /* First entry may be overwritten, so use two. */
-
-
-int
-my_system (const char *cmd)
-{
- int argsStart, e, i = 0;
- char *cmdLine = NULL;
-
- argsStart = strstr (cmd, " ") - cmd;
-
- // try to find the command in predefined path's
- while (try_dir[i])
- {
- cmdLine = (char *) Safe_malloc (strlen (try_dir[i]) + strlen (cmd) + 10);
- strcpy (cmdLine, try_dir[i]); // the path
-
- strcat (cmdLine, DIR_SEPARATOR_STRING);
- strncat (cmdLine, cmd, argsStart); // the command
-
-#if NATIVE_WIN32
- strcat (cmdLine, ".exe");
-#endif
-
- if (access (cmdLine, X_OK) == 0)
- {
- // the arguments
- strcat (cmdLine, cmd + argsStart);
- break;
- }
- free (cmdLine);
- cmdLine = NULL;
- i++;
- }
-
- if (verboseExec)
- {
- printf ("+ %s\n", cmdLine ? cmdLine : cmd);
- }
-
- if (cmdLine)
- {
- // command found in predefined path
- e = system (cmdLine);
- free (cmdLine);
- }
- else
- {
- // trust on $PATH
- e = system (cmd);
- }
- return e;
-}
-
-