> I just found that the Newlib library as included in the gcc-ia16 
> toolchain does happen to implement fmemopen( ) (and several other POSIX 
> functions as well).
> 
> However, Open Watcom's C library does not have this function.
> 
> I suppose, if a `FILE *' is not absolutely needed, then one can use 
> strchr( ), strcspn( ), etc. to slice the input up into separate lines, 
> without writing a lot of code.
> 
> Thank you!

Whether you use fmemopen() later or roll your own text digestion code,
you should make sure to terminate the text read in with a NUL character
so that it's a standard C string, otherwise the string functions will
run amok.

char *buffer = malloc(size + 1);
status = read_data(file, buffer, size);
if (status == GOOD) {
        buffer[size] = '\0';
        process_buffer(buffer);
} else {
        ...
}

I would digest the text into an internal representation just after the
file is read, but that's just me.

Ken



_______________________________________________
Freedos-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to