FreeCalypso > hg > fc-sim-tools
view libcommon/script.c @ 97:9f1cc3174e45
grcard2-set-comp128: allow optional setting of upper 6 bits
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 05 May 2021 04:05:57 +0000 |
parents | b7ee2e85686b |
children |
line wrap: on
line source
/* * This module implements the exec command, which is our scripting facility. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> extern FILE *open_script_input_file(); cmd_exec(argc, argv) char **argv; { FILE *f; char linebuf[512], *cp; int lineno, retval = 0; f = open_script_input_file(argv[1]); if (!f) { perror(argv[1]); return(-1); } for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) { cp = index(linebuf, '\n'); if (!cp) { fprintf(stderr, "%s line %d: missing newline\n", argv[1], lineno); fclose(f); return(-1); } *cp = '\0'; retval = simtool_dispatch_cmd(linebuf, 1); if (retval) break; } fclose(f); return(retval); }