Admin/Linux/Isabelle.c
author paulson <lp15@cam.ac.uk>
Mon Oct 30 16:02:59 2017 +0000 (22 months ago)
changeset 66939 04678058308f
parent 54314 8f7061babae4
permissions -rw-r--r--
New results in topology, mostly from HOL Light's moretop.ml
     1 /*  Author:     Makarius
     2 
     3 Main 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 
    13 static void fail(const char *msg)
    14 {
    15   fprintf(stderr, "%s\n", msg);
    16   exit(2);
    17 }
    18 
    19 
    20 int 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