Debian Codegraph @

gc/tools/if_mach.c

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