Files
bshell/bshell/main.c
T

39 lines
727 B
C

#include "file.h"
#include "line-ed/line-ed.h"
#include <stdio.h>
int main(int argc, const char **argv)
{
printf("B Shell " BSHELL_VERSION "\n");
struct line_source *linesrc = NULL;
enum bshell_status status = BSHELL_SUCCESS;
if (argc > 1) {
struct file *file = NULL;
status = file_open(argv[1], &file);
linesrc = &file->f_base;
} else {
struct line_ed *ed = line_ed_create();
linesrc = line_ed_to_line_source(ed);
}
fx_stringstream *linebuf = fx_stringstream_create();
while (1) {
enum bshell_status status
= line_source_readline(linesrc, linebuf);
if (status != BSHELL_SUCCESS) {
break;
}
printf("%s", fx_stringstream_ptr(linebuf));
fx_stringstream_reset(linebuf);
}
return 0;
}