home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-28  |  5.8 KB  |  194 lines

  1. /*
  2.  * @(#)stdio.h, xdLibs, SozobonX
  3.  *
  4.  *         Standard i/o include file
  5.  *
  6.  * some int returning functions are not declarated here, but this will
  7.  * be changed soon. -jerry-
  8.  * last change:
  9.  *  -VS: 1995/08/18
  10.  */
  11.  
  12. #ifndef _STDIO_H
  13. #define _STDIO_H
  14.  
  15. #ifndef _STDLIB_H
  16. #include <stdlib.h>
  17. #endif /* _STDLIB_H */
  18.  
  19. #ifndef _STDARG_H
  20. # include <stdarg.h>
  21. #endif /* _STDARG_H */
  22.  
  23. /*
  24.  *    CONSTANTS:
  25.  */
  26. #define _NFILE        (32)        /* maximum number of open streams */
  27. #define FOPEN_MAX    _NFILE        /* ANSI equivalent (replaces _NFILE) */
  28. #define FILENAME_MAX    (128)        /* maximum filename size */
  29. #define BUFSIZ        (1024)        /* default buffer size */
  30. #define EOF     (-1)            /* end-of-file indicator */
  31. #define EOS     '\0'            /* end-of-string indicator */
  32.  
  33. #ifndef FALSE
  34. #pragma echo  "you shouldn't manipulate standard header files"
  35. #define FALSE        (0)         /* boolean false */
  36. #define TRUE        (1)        /* boolean true */
  37. #endif
  38.  
  39. #ifndef ERROR
  40. #define ERROR        (-1)        /* general error condition */
  41. #endif
  42.  
  43. /* lseek() origins */
  44. #define SEEK_SET    0        /* from beginning of file */
  45. #define SEEK_CUR    1        /* from current location */
  46. #define SEEK_END    2        /* from end of file */
  47.  
  48. /* cfg_ch() control flags */
  49. #define _CIOB        0x01        /* use bios rather than gemdos */
  50. #define _CIOCH        0x02        /* return only 8-bit values */
  51. #define _CIOVT        0x04        /* process vt52 escape codes */
  52.  
  53. /* FILE structure flags */
  54. #define _IOREAD     0x0001        /* file may be read from */
  55. #define _IOWRT        0x0002        /* file may be written to */
  56. #define _IOBIN        0x0004        /* file is in "binary" mode */
  57. #define _IODEV        0x0008        /* file is a character device */
  58. #define _IOR        0x0020        /* last i/o was read */
  59. #define _IOW        0x0040        /* last i/o was write */
  60. #define    _IORW        0x0080        /* file is open for update (r+w) */
  61. #define _IOFBF        0x0100        /* i/o is fully buffered */
  62. #define _IOLBF        0x0200        /* i/o is line buffered */
  63. #define _IONBF        0x0400        /* i/o is not buffered */
  64. #define _IOMYBF        0x0800        /* standard buffer */
  65. #define _IOEOF        0x1000        /* EOF has been reached */
  66. #define _IOERR        0x4000        /* an error has occured */
  67.  
  68. typedef struct                /* FILE structure */
  69.     {
  70.     int         _cnt;        /* # of bytes in buffer */
  71.     unsigned char    *_ptr;        /* current buffer pointer */
  72.     unsigned char    *_base;     /* base of file buffer */
  73.     unsigned int    _flag;        /* file status flags */
  74.     int         _file;        /* file handle */
  75.     int         _bsiz;        /* buffer size */
  76.     unsigned char    _ch;        /* tiny buffer, for "unbuffered" i/o */
  77.     }
  78.     FILE;
  79.  
  80. #define L_tmpnam    128
  81. #define TMP_MAX     1000
  82.  
  83. extern    void    _exit();
  84.  
  85. extern    FILE    _iob[];
  86. extern    char *    tmpnam    (char *);
  87.  
  88. extern    FILE *    fopen    (const char *filename, const char *mode);
  89. extern    FILE *    freopen    (const char *filename, const char *mode, FILE *stream);
  90.  
  91. extern    int    remove(char *name);
  92. extern    int    rename(char *name, char* newname);
  93.  
  94. extern    int    fclose(FILE *stream);
  95. extern    int    fflush(FILE *stream);
  96.  
  97. extern    void    setbuf(FILE *fp, void *buf);
  98. extern    int    setvbuf(FILE *fp, void *bp, int bmode, size_t size);
  99.  
  100. extern    size_t    fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
  101. extern    size_t    fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  102.  
  103. extern    FILE *    fdopen(int h, char *mode);
  104. extern  FILE *    fopenp(char *filename, char *mode, char *path);
  105. extern    int    fgetpos(FILE *stream, fpos_t *pos);
  106. extern    int    fseek(FILE *stream, long int offset, int whence);
  107. extern    int    fsetpos(FILE *stream, const fpos_t *pos);
  108. extern    long    ftell(FILE *fp), fsize();
  109. extern    void    rewind(FILE *fp);
  110.  
  111. #ifdef __SRC__
  112. extern    int    fscanf  (FILE *fp, const char *fmt, char *s);
  113. extern    int    scanf   (const char *fmt, char *s);
  114. extern    int    sscanf  (char *buf, const char *fmt, int);
  115. #else /* not __SRC__ */
  116. extern    int    fscanf  (FILE *fp, const char *, ...);
  117. extern    int    scanf   (const char *fmt, ...);
  118. extern    int     sscanf  (char *buf, const char *fmt, ...);
  119. #endif /* not __SRC__ */
  120.  
  121. extern    int    fprintf    (FILE *fp, const char *, ...);
  122. extern    int    printf    (const char *, ...);
  123. extern    int    sprintf    (char *, const char *, ...);
  124.  
  125. extern    int     vfprintf (FILE *, const char *, va_list);
  126. extern    int     vprintf     (const char *, va_list);
  127. extern    int     vsprintf (char *, const char *, va_list);
  128. #ifndef _POSIX_SOURCE
  129. extern    int    vscanf  (const char *, va_list);
  130. extern    int    vfscanf (FILE *, const char *, va_list);
  131. extern    int    vsscanf    (const char *, const char *, va_list);
  132. #endif /* _POSIX_SOURCE */
  133.  
  134. extern    int    fgetc    (FILE *stream);
  135. extern    int    fungetc    (char c, FILE *stream);
  136. extern    char    *fgets    (char *str, int cnt, FILE *stream);
  137. extern    char    *gets    (char *str);
  138. extern    int    fputc    (int c, FILE *stream);
  139. extern    int    fputs    (const char *, FILE *stream);
  140. extern    int    puts    (const char *str);
  141.  
  142. /* standard streams */
  143. #define stdin    (&_iob[0])
  144. #define stdout    (&_iob[1])
  145. #define stderr    (&_iob[2])
  146. #define stdprn    (&_iob[3])
  147. #define stdaux    (&_iob[4])
  148.  
  149. /* error handling    */
  150.     /* as stream macros */
  151. #define clearerr(fp)    ((void) ((fp)->_flag &= ~(_IOERR|_IOEOF)))
  152. #define feof(fp)        ((fp)->_flag & _IOEOF)
  153. #define ferror(fp)        ((fp)->_flag & _IOERR)
  154. #define fpending(fp)    ((fp)->_cnt)
  155.  
  156. extern void perror (const char *msg);
  157. extern void perrorf (const char *msg);    /* extended perror func    */
  158.  
  159. /* aliases */
  160. #define getc            fgetc
  161. #define ungetc            fungetc
  162. #define putc            fputc
  163. #define getchar()        fgetc(stdin)
  164. #define ungetchar(c)        fungetc((c),stdin)
  165. #define putchar(c)        fputc((c),stdout)
  166.  
  167.  
  168.     /* here follow some non standard extensions    */
  169.  
  170. extern    short    getw(FILE *fp);
  171. extern    long    getl(FILE *fp);
  172. extern    short    putw(short arg, FILE *fp);
  173. extern    long    putl(long arg, FILE *fp);
  174.  
  175. #define fexists         exists
  176. #define exists(f)        !access(f,0x00)
  177.  
  178. /* a macro for mixing streams and low level I/O,
  179.  * using it may cause some problems !!
  180.  */
  181. #define fileno(fp)    ((fp)->_file)
  182.  
  183.     /* functions similiar to fgetc(), fputc() for std types    */
  184. extern    short    fgetw(FILE *fp);
  185. extern    long    fgetl(FILE *fp);
  186. extern    float    fgetf(FILE *fp);
  187. extern    double    fgetd(FILE *fp);
  188. extern    short    fputw(short n, FILE *fp);
  189. extern    long    fputl(long n, FILE *fp);
  190. extern    float    fputf(float n, FILE *fp);
  191. extern    double    fputd(double n, FILE *fp);
  192.  
  193. #endif     /* _STDIO_H    */
  194.