add support for input command str
[glg-sh.git] / input.c
blobe3ca8fefebd7f60cde771ec8800786cbabe244d8
1 #include <stdbool.h>
2 #include <string.h>
4 #include "input.h"
6 #define CMDSTR 0
7 #define INTERACTIVE 1
9 static int input_type;
11 static char *cmdstr;
12 static int cmdstrlen = 0;
15 void input_set_cmdstr(char *str)
17 input_type = CMDSTR;
18 cmdstr = str;
19 cmdstrlen = strlen(cmdstr);
22 int input_get_next_char(void)
24 int c;
26 if(cmdstrlen == 0) {
27 c = -1;
28 } else {
29 c = *(cmdstr++);
30 cmdstrlen--;
32 return c;