1/* Author: Makarius 2 3Main Isabelle application executable. 4*/ 5 6#include <stdlib.h> 7#include <stdio.h> 8#include <string.h> 9#include <sys/types.h> 10#include <unistd.h> 11 12 13static void fail(const char *msg) 14{ 15 fprintf(stderr, "%s\n", msg); 16 exit(2); 17} 18 19 20int main(int argc, char *argv[]) 21{ 22 char **cmd_line = NULL; 23 int i = 0; 24 25 cmd_line = malloc(sizeof(char *) * (argc + 1)); 26 if (cmd_line == NULL) fail("Failed to allocate command line"); 27 28 cmd_line[0] = malloc(strlen(argv[0]) + 5); 29 if (cmd_line[0] == NULL) fail("Failed to allocate command line"); 30 31 strcpy(cmd_line[0], argv[0]); 32 strcat(cmd_line[0], ".run"); 33 34 for (i = 1; i < argc; i++) cmd_line[i] = argv[i]; 35 36 cmd_line[argc] = NULL; 37 38 execvp(cmd_line[0], cmd_line); 39 fail("Failed to execute application script"); 40} 41 42