Debian Codegraph @

tools/if_mach.c

raw
1 /* Conditionally execute a command based on machine and OS from gcconfig.h */
2
3 # define NOT_GCBUILD
4 # include "private/gc_priv.h"
5 # include <stdio.h>
6 # include <string.h>
7 # include <unistd.h>
8
9 #ifdef __cplusplus
10 # define EXECV_ARGV_T char**
11 #else
12 /* The 2nd argument of execvp() prototype may be either char**, or */
13 /* char* const*, or const char* const*. */
14 # define EXECV_ARGV_T void*
15 #endif
16
17 int main(int argc, char **argv)
18 {
19 if (argc < 4) goto Usage;
20 if (strcmp(MACH_TYPE, argv[1]) != 0) return(0);
21 if (strlen(OS_TYPE) > 0 && strlen(argv[2]) > 0
22 && strcmp(OS_TYPE, argv[2]) != 0) return(0);
23 fprintf(stderr, "^^^^Starting command^^^^\n");
24 fflush(stdout);
25 execvp(TRUSTED_STRING(argv[3]), (EXECV_ARGV_T)(argv + 3));
26 perror("Couldn't execute");
27
28 Usage:
29 fprintf(stderr, "Usage: %s mach_type os_type command\n", argv[0]);
30 fprintf(stderr, "Currently mach_type = %s, os_type = %s\n",
31 MACH_TYPE, OS_TYPE);
32 return(1);
33 }