rendered paste bodyvoid editreadfile (struct options *options, list_ref list, char *filetoberead)
{
FILE* input = fopen(filetoberead, "r");
char stdinline[1024];
int stdincount = 0;
if(input == NULL) return;
for(;; ++stdincount) {
char *linepos = fgets (stdinline, sizeof stdinline, input);
if (linepos == NULL) break;
if(linepos == EOF) break;
linepos = strchr (stdinline, '\n');
if (linepos == NULL || stdinline[0] == '\0') {
badline (stdincount, stdinline);
}else {
*linepos = '\0';
switch (stdinline[0]) {
case '$': f_dollar(list);
STUBPRINTF ("stdin[%d]: $\n", stdincount); break;
case '*': f_star(list);
STUBPRINTF ("stdin[%d]: *\n", stdincount); break;
case '.': f_dot(list);
STUBPRINTF ("stdin[%d]: .\n", stdincount); break;
case '0': f_zero(list);
STUBPRINTF ("stdin[%d]: 0\n", stdincount); break;
case '>': f_GT(list);
STUBPRINTF ("stdin[%d]: >\n", stdincount); break;
case '@': debugdump_list (list); break;
case 'a': f_a(stdinline, list);
STUBPRINTF ("stdin[%d]: a\n", stdincount); break;
case 'd': f_d(list);
STUBPRINTF ("stdin[%d]: d\n", stdincount); break;
case 'i': f_i(stdinline,list);
STUBPRINTF ("stdin[%d]: i\n", stdincount);
break;
case 'r': STUBPRINTF ("stdin[%d]: r\n", stdincount); break;
case 'w': STUBPRINTF ("stdin[%d]: w\n", stdincount); break;
default : badline (stdincount, stdinline);
};
};
};
}
int main (int argc, char **argv) {
struct options options;
list_ref list = NULL;
int argi = 0;
bzero (&options, sizeof options);
set_progname (argv[0]);
scanoptions (&options, argc, argv);
argi = 1;
list = new_list();
for (argi=options.optend; argi < argc; ++argi) {
editreadfile(&options, list, argv[argi]);
}
editfile (&options, list);
free_list (list); list = NULL;
return get_exitcode();
}