#include #include #include #include #include #include "icmd.h" /* should be enough */ #define CMD_LINE_MAX 1024 #define CMD_PATH_MAX 4096 int die(char *s) { perror(s); exit(-1); } int main(int argc, char **argv) { char line[CMD_LINE_MAX]; char cwd[CMD_PATH_MAX]; char *pline = line; int ret; for (;;) { /* todo: does it really fail? */ if (getcwd(cwd, sizeof(cwd)) == NULL) die("getcwd()"); printf("[%s] ", cwd); fgets(line, sizeof(line), stdin); ret = call_icmds(line); if (ret == INT_MAX) puts("no such internal command, going on..."); else if (ret == 0) puts("internal command succeded!"); else puts("internal command succeded!"); } return 0; }