Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /********************************* executes the command from TCL **************************/ |
| 2 | /* this takes the arglist passed in by TCL and converts it to a |
||
| 3 | VERTICAL command structure */ |
||
| 4 | #include "cmdexec.h" |
||
| 5 | #include "cmdlog.h" |
||
| 6 | #include "cmdparse.h" |
||
| 7 | #include "cmdutil.h" |
||
| 8 | #include "expression.h" |
||
| 9 | #include "generic.h" |
||
| 10 | |||
| 11 | #include <ctype.h> |
||
| 12 | #include <stdlib.h> |
||
| 13 | #include <string.h> |
||
| 14 | #include <tcl.h> |
||
| 15 | /* used for dynamic string allocation/deallocation code |
||
| 16 | * used here for command keywords May 2 2000 */ |
||
| 17 | #include "lx_support.h" |
||
| 18 | #include "vertcl_main.h" |
||
| 19 | |||
| 20 | int ET_COMMAND_vertical (ET_TCLARGS) |
||
| 21 | { |
||
| 22 | FILE *f; |
||
| 23 | struct CommandStruct Cmd; |
||
| 24 | int i, Status; |
||
| 25 | char *p; |
||
| 26 | |||
| 27 | Cmd.Text = NULL; /* place the command in the command structure */ |
||
| 28 | Cmd.NumberCommands = argc - 1; |
||
| 29 | Cmd.CurrentCommand = 0; |
||
| 30 | |||
| 31 | f = fopen ("Varg.txt", "w"); |
||
| 32 | |||
| 33 | for (i = 0; i < argc - 1 && i < WORDSINLINE; i++) |
||
| 34 | { |
||
| 35 | Cmd.Words[i] = strdup (argv[i + 1]); |
||
| 36 | fprintf (f, "%02d : %s\n", i, Cmd.Words[i]); |
||
| 37 | } |
||
| 38 | if (Cmd.NumberCommands == 0 || Cmd.Words[0][0] == '-' || Cmd.Words[0][0] == '#') |
||
| 39 | return (TCL_OK); /* comment or a null string */ |
||
| 40 | |||
| 41 | Status = TopMenu (&Cmd); /* pass the command through the top-level menu */ |
||
| 42 | switch (Status) |
||
| 43 | { |
||
| 44 | case UNKNOWNCMD: |
||
| 45 | Status = TCL_ERROR; |
||
| 46 | Log (LOG_ERROR, "# Unknown command:"); |
||
| 47 | break; |
||
| 48 | case NARGS: |
||
| 49 | Status = TCL_ERROR; |
||
| 50 | Log (LOG_ERROR, "# Too few parameters:"); |
||
| 51 | break; |
||
| 52 | case FAILED: |
||
| 53 | Status = TCL_ERROR; |
||
| 54 | Log (LOG_ERROR, "# Could not execute command:"); |
||
| 55 | break; |
||
| 56 | default: |
||
| 57 | Status = TCL_OK; |
||
| 58 | }; |
||
| 59 | if (Status != TCL_OK) |
||
| 60 | { |
||
| 61 | /* for (i=0; i < Cmd.NumberCommands; i++) */ /* display offending command |
||
| 62 | */ |
||
| 63 | /* Et_ResultF(interp," %s", Cmd.Words[i]);*/ |
||
| 64 | Et_ResultF (interp, "vertical command %s\n", Cmd.Words[1]); |
||
| 65 | }; |
||
| 66 | |||
| 67 | for (i = 0; i < argc - 1; i++) |
||
| 68 | free (Cmd.Words[i]); |
||
| 69 | |||
| 70 | return (Status); |
||
| 71 | } |
||
| 72 | |||
| 73 | /* |
||
| 74 | ** Main routine for UNIX programs. If the user has supplied |
||
| 75 | ** their own main() routine in a C module, then the ET_HAVE_MAIN |
||
| 76 | ** macro will be set to 1 and this code will be skipped. |
||
| 77 | */ |
||
| 78 | int main (int argc, char **argv) |
||
| 79 | { |
||
| 80 | /* VERTICAL SPECIFIC INITIALISATION */ |
||
| 81 | InitErrorLog (); |
||
| 82 | InitialiseData (); |
||
| 83 | ExecuteString ( |
||
| 84 | "echo running \\$(VERTICAL_INIT) file name = $(VERTICAL_INIT) ", argc, argv); |
||
| 85 | ExecuteString ("do $(VERTICAL_INIT) ", argc, argv); |
||
| 86 | |||
| 87 | #if ET_AUTO_FORK |
||
| 88 | int rc = fork (); |
||
| 89 | if (rc < 0) |
||
| 90 | { |
||
| 91 | perror ("can't fork"); |
||
| 92 | exit (1); |
||
| 93 | } |
||
| 94 | if (rc > 0) |
||
| 95 | return 0; |
||
| 96 | close (0); |
||
| 97 | open ("/dev/null", O_RDONLY); |
||
| 98 | close (1); |
||
| 99 | open ("/dev/null", O_WRONLY); |
||
| 100 | #endif |
||
| 101 | return Et_Init (argc, argv) != TCL_OK; |
||
| 102 | } |