#include
#include
int main(int argc, char** argv)
{
FILE* handle = NULL;
if (argc == 2)
handle = fopen(argv[1], "r"); // r+b // read-write binary
else
handle = stdin;
if (handle == NULL)
return 1; // Could not open file
printf("/$ ");
int c = 0;
char command_line[255];
char command_char[2];
command_line[0] = 0;
while(!feof(handle))
{
c = fgetc(handle);
//fputc(c, stdout);
if (c != 0)
{
//printf("%d ", c);
command_char[0] = c;
command_char[1] = 0;
strcat(command_line, command_char);
}
if (c == '\n')
{
//printf("%s", command_line);
system(command_line);
printf("/$ ");
command_line[0] = 0;
}
}
fclose(handle);
return 0;
}
//fflush(stdout);
//FILE* handle = tmpfile();
//(c = fgetc(handle)) != EOF
20700cookie-checkC Simple parsing