Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.2 KiB

  1. /* File: D:\WACKER\tdll\file_io.h (Created: 26-Jan-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 1 $
  7. * $Date: 10/05/98 12:40p $
  8. */
  9. /*
  10. * This stuff is a replacement for some sort of buffered file I/O.
  11. *
  12. * It is directly modeled after (read lifted from) the "stdio.h" stuff.
  13. */
  14. #if !defined(EOF)
  15. #define EOF (-1)
  16. #endif
  17. #define _FIO_IOEOF 0x0001
  18. #define _FIO_IOERR 0x0002
  19. #define _FIO_BSIZE 512
  20. #define _FIO_MAGIC 0x1234A587
  21. struct _fileio_buf {
  22. long _fio_magic;
  23. char *_fio_ptr;
  24. int _fio_cnt;
  25. char *_fio_base;
  26. int _fio_flag;
  27. int _file; /* Not used, replaced with the following */
  28. HANDLE _fio_handle;
  29. int _fio_mode;
  30. int _fio_charbuf;
  31. int _fio_bufsiz;
  32. char *_fio_tmpfname;
  33. };
  34. typedef struct _fileio_buf ST_IOBUF;
  35. /* Macro definitions */
  36. #define fio_feof(_stream) ((_stream)->_fio_flag & _FIO_IOEOF)
  37. #define fio_ferror(_stream) ((_stream)->_fio_flag & _FIO_IOERR)
  38. #define fio_errclr(_stream) ((_stream)->_fio_flag = 0)
  39. #define _fileno(_stream) ((_stream)->_file)
  40. #define fio_gethandle(_stream) ((_stream)->_fio_handle)
  41. #define fio_getc(_s) (--(_s)->_fio_cnt >= 0 \
  42. ? 0xff & *(_s)->_fio_ptr++ : _fio_fill_buf(_s))
  43. /* TODO: make this work better */
  44. #define fio_ungetc(_c,_s) (*(--(_s)->_fio_ptr) = (char)_c);((_s)->_fio_cnt++)
  45. #define fio_putc(_c,_s) (--(_s)->_fio_cnt >= 0 \
  46. ? 0xff & (*(_s)->_fio_ptr++ = (char)(_c)) : _fio_flush_buf((_c),(_s)))
  47. int _fio_fill_buf(ST_IOBUF *);
  48. int _fio_flush_buf(int, ST_IOBUF *);
  49. /* mode flags for fio_open, may be or'd together */
  50. #define FIO_CREATE 0x0001
  51. #define FIO_READ 0x0002
  52. #define FIO_WRITE 0x0004
  53. /* append means just reposition at the end of the file after open */
  54. #define FIO_APPEND 0x0008
  55. ST_IOBUF *fio_open(char *, int);
  56. int fio_close(ST_IOBUF *);
  57. #define FIO_SEEK_CUR 0x0001
  58. #define FIO_SEEK_END 0x0002
  59. #define FIO_SEEK_SET 0x0003
  60. int fio_seek(ST_IOBUF *, size_t, int);
  61. int fio_read(void *buffer, size_t size, size_t count, ST_IOBUF *pF);
  62. int fio_write(void *buffer, size_t size, size_t count, ST_IOBUF *pF);