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