Captains-LOG.c

Well, just so I don’t forget if I frag it later heres the write process of my logging program (still working on).

It’s pretty simple, just get input till we get a return char, then write it into the file and append a newline. The only bugger is that the input has to fit into a char array of 256, any attempts to modify this to what is needed has returned junk pointer warnings in realloc at run time. I’m still a newb whose trying to learn the standard library and more so simple code is probably good.

if ((rflag < 1) && (tflag < 1) && (fflag < 1)) {
char str[256]; /* this is enough space for our needs */
fscanf(stdin, " %[^n]", str);
fprintf(fp, str);
fputc('n', fp);
fclose(fp);
}

I figure one or two lines of text is what is most likly to be written to file, so str is big enough yet small enough for right now.

Un till I have the time, chance, and enegry to learn how to handle reading the file and printing it out to screen in a head/tail like fashion. I’m just having a system() call to invoke head or tail as needed on the file. /usr/src/bin/ cat, head, and tail are my current points of study for methods. Cat looks the easiest to follow but means I have to work on it when I have time to consintrate on the flow of the program.

This is also a test to see if the html pre tags work the way I’m hopping they do, since I don’t know allot of html to start with. It’s just never interested me very much [xhtml/css/php/e.t.c.]