Admin/Linux/Isabelle.c
changeset 54313 da2e6282a4f5
child 54314 8f7061babae4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Admin/Linux/Isabelle.c	Mon Oct 07 21:24:44 2013 +0200
     1.3 @@ -0,0 +1,39 @@
     1.4 +/*  Author:     Makarius
     1.5 +
     1.6 +Main Isabelle application executable.
     1.7 +*/
     1.8 +
     1.9 +#include <stdlib.h>
    1.10 +#include <stdio.h>
    1.11 +#include <string.h>
    1.12 +#include <sys/types.h>
    1.13 +#include <unistd.h>
    1.14 +
    1.15 +
    1.16 +static void fail(const char *msg)
    1.17 +{
    1.18 +  fprintf(stderr, "%s\n", msg);
    1.19 +  exit(2);
    1.20 +}
    1.21 +
    1.22 +
    1.23 +int main(int argc, char *argv[])
    1.24 +{
    1.25 +  char **cmd_line = NULL;
    1.26 +  int i = 0;
    1.27 +
    1.28 +  cmd_line = malloc(sizeof(char *) * argc);
    1.29 +  if (cmd_line == NULL) fail("Failed to allocate command line");
    1.30 +
    1.31 +  cmd_line[0] = malloc(strlen(argv[0]) + 5);
    1.32 +  if (cmd_line[0] == NULL) fail("Failed to allocate command line");
    1.33 +
    1.34 +  strcpy(cmd_line[0], argv[0]);
    1.35 +  strcat(cmd_line[0], ".run");
    1.36 +
    1.37 +  for (i = 1; i < argc; i++) cmd_line[i] = argv[i];
    1.38 +
    1.39 +  execvp(cmd_line[0], cmd_line);
    1.40 +  fail("Failed to execute application script");
    1.41 +}
    1.42 +