/* LRL version of ANSI C header http://flash-gordon.me.uk/ansi.c.txt */ // Make the linkname of the current namespace blank, so identifiers here // are not namespace prefixed when linking (the default would be "c89_"). linkname ""; typedef FILE = private; typedef fpos_t = count; // XXX implementation dependent. how to do this? alias int EOF = -1; // actually implementation dependent // TODO enums, constants, etc // In C, this is just an int with #defines typedef whence_t = enum( /* implementation dependent. These are the GNU libc values */ SEEK_CUR = 1, SEEK_END = 2, SEEK_SET = 0, ); // XXX can these be replaced? (i.e. should they be var^) //var FILE^ stderr stdin stdout; // TODO implement this syntax var FILE^ stderr; var FILE^ stdin; var FILE^ stdout; // 4.9.4 Operations on files // XXX require a NULL-terminated string! int remove(char+> filename); int rename(char+> old, char+> new); var FILE own^? tmpfile(); char+> tmpnam(var char+>? s); // deprecated // 4.9.5 File access functions int fclose(var FILE own^ stream); int fflush(var FILE^? stream); var FILE own^? fopen(char+> filename, char+> mode); var FILE own^? freopen(char+> filename, char+> mode, var FILE^ stream); () setbuf(var FILE^ stream, byte own^? buf); int setvbuf(var FILE^ stream, byte own^? buf, int mode, count size); // 4.9.6 Formatted input/output functions // not necessarily safe! // TODO implement variadic arguments import int fprintf(var FILE^ stream, char+> format, ...*); import int fscanf(var FILE^ stream, char+> format, ...*); import int printf(char+> format, ...*); import int scanf(char+> format, ...*); import int sprintf(var char+> s, char+> format, ...*); import int sscanf(char+> s, char+> format, ...*); /*int vfprintf(var FILE^ stream, char+> format, va_list arg); int vprintf(char+> format, va_list arg); int vsprintf(var char+> s, char+> format, va_list arg); */ // 4.9.7 Character input/output functions // TODO size/null-termination constraints import int fgetc(var FILE^ stream); import var char+>? fgets(var char+> s, int n, var FILE^ stream); import int fputc(int c, var FILE^ stream); import int fputs(char+> s, var FILE^ stream); import int getc(var FILE^ stream); import int getchar(); import var char+>? gets(var char+> s); // deprecated import int putc(int c, var FILE^ stream); import int putchar(int c); import int puts(char+> s); import int ungetc(int c, var FILE^ stream); // 4.9.8 Direct input/output functions // TODO size constraint on T /*count fread[T](var T#[nmemb]^ ptr, count size, count nmemb, var FILE^ stream); count fwrite[T](T#[nmemb]^ ptr, count size, count nmemb, var FILE^ stream);*/ // 4.9.9 File positioning functions int fgetpos(var FILE^ stream, var fpos_t^ pos); int fseek(var FILE^ stream, long offset, whence_t whence); int fsetpos(var FILE^ stream, fpos_t^ pos); long ftell(var FILE^ stream); () rewind(var FILE^ stream); // 4.9.10 Error-handling functions () clearerr(var FILE^ stream); int feof(var FILE^ stream); int ferror(var FILE^ stream); () perror(char+>? s);