home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / include / util / fob.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-22  |  2.4 KB  |  64 lines

  1. typedef struct fob_t {
  2.     FILE * fp;        /* if not NULL, use stdio.h functions */
  3.         int read_byte_swap;     /* if true, swap after read */
  4.         int write_byte_swap;    /* if true, swap after write */
  5.     int length;        /* #bytes read or written */
  6.     char * buf;        /* allocated buffer pointer */
  7.     char * buf_swap;        /* if the write operation requries byte*/
  8.                             /* swapping, it's done here */
  9.     int bufsize;        /* allocated buffer size */
  10.     char * pos;        /* current position in buffer */
  11. } FOB;
  12.  
  13.  
  14. #define FOB_BUF_GRAN    8192
  15. #define FOBPNULL    ( (FOB *) NULL )
  16.  
  17. #if defined(__STDC__) || defined(__GNUC__) || defined(sgi)
  18. #define PROTO(ARGS)    ARGS
  19. #else
  20. #define PROTO(ARGS)    ()
  21. #endif
  22.  
  23. FOB * fob_create PROTO((FILE *fp)) ;
  24. int fob_destroy PROTO((FOB *fobp)) ;
  25. int fob_fflush PROTO((FOB *fobp)) ;
  26. int fob_create2 PROTO((FILE *fpin, FILE *fpout, FOB **fobpin, FOB **fobpout)) ;
  27. int fob_destroy2 PROTO((FOB *fobpin, FOB *fobpout)) ;
  28. void fob_read_byte_swap PROTO((FOB *f)) ;
  29. void fob_write_byte_swap PROTO((FOB *f)) ;
  30. void fob_read_byte_natural PROTO((FOB *f));
  31. void fob_write_byte_natural PROTO((FOB *f));
  32. void fob_bufinit PROTO((FOB *f, char *buf, int len)) ;
  33. void fob_rewind PROTO((FOB *f)) ;
  34. int fob_ftell PROTO((FOB *f)) ;
  35. int fob_is_fp PROTO((FOB *f)) ;
  36. int fob_flush_to_fp PROTO((FOB *f, FILE *fp)) ;
  37. int fob_bufcleanup PROTO((FOB *f, char **buf, int *len)) ;
  38. int fob_bufput PROTO((FOB *fobp, char *p, int len)) ;
  39. int fob_bufget PROTO((FOB *fobp, char *p, int len)) ;
  40. void buffer_swap_bytes PROTO((char *mem, int blen)) ;
  41. void copy_buffer_swap_bytes PROTO((char *to, char *from, int blen)) ;
  42. int fob_fread PROTO((char *p, int size, int nitems, FOB *fobp)) ;
  43. int fob_fwrite PROTO((char *p, int size, int nitems, FOB *fobp)) ;
  44. int fob_putc PROTO((char c, FOB *fobp)) ;
  45. int fob_getc PROTO((FOB *fobp)) ;
  46. int fob_getw PROTO((FOB *fobp)) ;
  47. int fob_ferror PROTO((FOB *fobp)) ;
  48. int fob_feof PROTO((FOB *fobp)) ;
  49. int fob_fseek PROTO((FOB *f, long len, int offset));
  50. int fob_fclose PROTO((FOB *fob));
  51. FOB *fob_fopen PROTO((char *name, char *mode));
  52.  
  53. /*
  54.  * lseek & access args
  55.  *
  56.  * SEEK_* have to track L_* in sys/file.h & SEEK_* in 5include/stdio.h
  57.  * ?_OK have to track ?_OK in sys/file.h
  58.  */
  59. #ifndef SEEK_SET
  60. #define SEEK_SET        0       /* Set file pointer to "offset" */
  61. #define SEEK_CUR        1       /* Set file pointer to current plus "offset" */
  62. #define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
  63. #endif
  64.