txtfile.h 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef TXTFILE_H
  13. #define TXTFILE_H
  14. #define FILE_BUFFER_SIZE 2024
  15. /* file status */
  16. enum {
  17. TEXT_FILE_NONE,
  18. TEXT_FILE_READING,
  19. TEXT_FILE_WRITING,
  20. TEXT_FILE_DONE
  21. };
  22. typedef struct TEXTFILE {
  23. FILE *file;
  24. char *fbCurrent;
  25. int fbSize;
  26. int fbStatus;
  27. char fileBuffer[FILE_BUFFER_SIZE + 1];
  28. } TEXTFILE;
  29. enum {
  30. TEXT_OPEN_FOR_READ,
  31. TEXT_OPEN_FOR_WRITE
  32. };
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. TEXTFILE * OpenTextFile(char *filename, int access);
  37. void CloseTextFile(TEXTFILE *txtfile);
  38. int ReadTextLine(TEXTFILE *txtfile, char *linebuf);
  39. #ifdef CPLUSPLUS
  40. };
  41. #endif
  42. #endif