1 /**************************************************************************/
3 /* Julian Lewis 21st Sept 2006 */
4 /**************************************************************************/
11 #include <sys/ioctl.h>
12 #include <sys/types.h>
14 #include <errno.h> /* Error numbers */
23 /**************************************************************************/
24 /* Code section from here on */
25 /**************************************************************************/
27 /* Print news on startup if not zero */
32 #define CMD_BUF_SIZE 128
34 static char history
[HISTORIES
][CMD_BUF_SIZE
];
35 static char *cmdbuf
= &(history
[0][0]);
36 static int cmdindx
= 0;
37 static char prompt
[32];
38 static char *pname
= NULL
;
44 #include "PrintAtoms.h"
50 /**************************************************************************/
51 /* Prompt and do commands in a loop */
52 /**************************************************************************/
54 int main(int argc
,char *argv
[]) {
58 char tmpb
[CMD_BUF_SIZE
];
62 printf("%s: Compiled %s %s\n",pname
,__DATE__
,__TIME__
);
66 printf("\nWARNING: Could not open driver");
69 printf("Driver opened OK: Using MTT module: 1\n\n");
76 bzero((void *) host
,49);
81 cmdbuf
= &(history
[cmdindx
][0]);
82 if (strlen(cmdbuf
)) printf("{%s} ",cmdbuf
);
85 if (mtt
) sprintf(prompt
,"%s:Mtt[%02d]",host
,cmdindx
+1);
86 else sprintf(prompt
,"%s:NoDriver:Mtt[%02d]",host
,cmdindx
+1);
89 bzero((void *) tmpb
,CMD_BUF_SIZE
);
90 if (fgets(tmpb
,CMD_BUF_SIZE
,stdin
)==NULL
) exit(1);
91 if ((i
= strlen(tmpb
)) == 0) continue;
97 ep
= cp
; cmdindx
= strtoul(++cp
,&ep
,0) -1;
98 if (cmdindx
>= HISTORIES
) cmdindx
= 0;
99 cmdbuf
= &(history
[cmdindx
][0]);
101 } else if (*cp
== '.') {
102 printf("Execute:%s\n",cmdbuf
); fflush(stdout
);
103 } else if ((*cp
== '\n') || (*cp
== '\0')) {
105 if (cmdindx
>= HISTORIES
) { printf("\n"); cmdindx
= 0; }
106 cmdbuf
= &(history
[cmdindx
][0]);
108 } else if (*cp
== '?') {
109 printf("History:\n");
110 printf("\t!<1..24> Goto command\n");
111 printf("\tCR Goto next command\n");
112 printf("\t. Execute current command\n");
113 printf("\this Show command history\n");
116 cmdindx
++; if (cmdindx
>= HISTORIES
) { printf("\n"); cmdindx
= 0; }
119 bzero((void *) val_bufs
,sizeof(val_bufs
));