Difference between revisions of "Source:SLASH'EM 0.0.7E7F2/dlb.h"
Jump to navigation
Jump to search
m (Automated source code upload) |
Kernigh bot (talk | contribs) m (SLASH'EM 0.0.7E7F2/dlb.h moved to Source:SLASH'EM 0.0.7E7F2/dlb.h: Robot: moved page) |
(No difference)
|
Latest revision as of 17:42, 7 March 2008
Below is the full text to dlb.h from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/dlb.h#line123]], for example.
The latest source code for vanilla NetHack is at Source code.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* SCCS Id: @(#)dlb.h 3.4 1997/07/29 */ 2. /* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef DLB_H 6. #define DLB_H 7. /* definitions for data library */ 8. 9. #ifdef DLB 10. 11. /* implementations */ 12. #ifdef MAC 13. # define DLBRSRC /* use Mac resources */ 14. #else 15. # define DLBLIB /* use a set of external files */ 16. #endif 17. 18. #ifdef DLBLIB 19. /* directory structure in memory */ 20. typedef struct dlb_directory { 21. char *fname; /* file name as seen from calling code */ 22. long foffset; /* offset in lib file to start of this file */ 23. long fsize; /* file size */ 24. char handling; /* how to handle the file (compression, etc) */ 25. } libdir; 26. 27. /* information about each open library */ 28. typedef struct dlb_library { 29. FILE *fdata; /* opened data file */ 30. long fmark; /* current file mark */ 31. libdir *dir; /* directory of library file */ 32. char *sspace; /* pointer to string space */ 33. long nentries; /* # of files in directory */ 34. long rev; /* dlb file revision */ 35. long strsize; /* dlb file string size */ 36. } library; 37. 38. /* library definitions */ 39. # ifndef DLBFILE 40. # define DLBFILE "nhshare" /* shareable library */ 41. # define DLBAREA FILE_AREA_SHARE 42. # define DLBFILE2 "nhushare" /* unshareable library */ 43. # define DLBAREA2 FILE_AREA_UNSHARE 44. # endif 45. # ifndef FILENAME_CMP 46. # define FILENAME_CMP strcmp /* case sensitive */ 47. # endif 48. 49. #endif /* DLBLIB */ 50. 51. 52. typedef struct dlb_handle { 53. FILE *fp; /* pointer to an external file, use if non-null */ 54. #ifdef DLBLIB 55. library *lib; /* pointer to library structure */ 56. long start; /* offset of start of file */ 57. long size; /* size of file */ 58. long mark; /* current file marker */ 59. #endif 60. #ifdef DLBRSRC 61. int fd; /* HandleFile file descriptor */ 62. #endif 63. } dlb; 64. 65. #if defined(ULTRIX_PROTO) && !defined(__STDC__) 66. /* buggy old Ultrix compiler wants this for the (*dlb_fread_proc) 67. and (*dlb_fgets_proc) prototypes in struct dlb_procs (dlb.c); 68. we'll use it in all the declarations for consistency */ 69. #define DLB_P struct dlb_handle * 70. #else 71. #define DLB_P dlb * 72. #endif 73. 74. boolean NDECL(dlb_init); 75. void NDECL(dlb_cleanup); 76. 77. #ifndef FILE_AREAS 78. dlb *FDECL(dlb_fopen, (const char *,const char *)); 79. #else 80. dlb *FDECL(dlb_fopen_area, (const char *,const char *,const char *)); 81. #endif 82. int FDECL(dlb_fclose, (DLB_P)); 83. int FDECL(dlb_fread, (char *,int,int,DLB_P)); 84. int FDECL(dlb_fseek, (DLB_P,long,int)); 85. char *FDECL(dlb_fgets, (char *,int,DLB_P)); 86. int FDECL(dlb_fgetc, (DLB_P)); 87. long FDECL(dlb_ftell, (DLB_P)); 88. 89. 90. /* Resource DLB entry points */ 91. #ifdef DLBRSRC 92. boolean rsrc_dlb_init(void); 93. void rsrc_dlb_cleanup(void); 94. boolean rsrc_dlb_fopen(dlb *dp, const char *name, const char *mode); 95. int rsrc_dlb_fclose(dlb *dp); 96. int rsrc_dlb_fread(char *buf, int size, int quan, dlb *dp); 97. int rsrc_dlb_fseek(dlb *dp, long pos, int whence); 98. char *rsrc_dlb_fgets(char *buf, int len, dlb *dp); 99. int rsrc_dlb_fgetc(dlb *dp); 100. long rsrc_dlb_ftell(dlb *dp); 101. #endif 102. 103. 104. #else /* DLB */ 105. 106. # define dlb FILE 107. 108. # define dlb_init() 109. # define dlb_cleanup() 110. 111. #ifndef FILE_AREAS 112. # define dlb_fopen fopen 113. #else 114. # define dlb_fopen_area(a,b,c) fopen_datafile_area(a,b,c,FALSE) 115. /* TODO: someone more knowledgable make this better */ 116. #endif 117. # define dlb_fclose fclose 118. # define dlb_fread fread 119. # define dlb_fseek fseek 120. # define dlb_fgets fgets 121. # define dlb_fgetc fgetc 122. # define dlb_ftell ftell 123. 124. #endif /* DLB */ 125. 126. 127. /* various other I/O stuff we don't want to replicate everywhere */ 128. 129. #ifndef SEEK_SET 130. # define SEEK_SET 0 131. #endif 132. #ifndef SEEK_CUR 133. # define SEEK_CUR 1 134. #endif 135. #ifndef SEEK_END 136. # define SEEK_END 2 137. #endif 138. 139. #define RDTMODE "r" 140. #if (defined(MSDOS) || defined(WIN32) || defined(TOS) || defined(OS2)) && defined(DLB) 141. #define WRTMODE "w+b" 142. #else 143. #define WRTMODE "w+" 144. #endif 145. #if (defined(MICRO) && !defined(AMIGA)) || defined(THINK_C) || defined(__MWERKS__) || defined(WIN32) 146. # define RDBMODE "rb" 147. # define WRBMODE "w+b" 148. #else 149. # define RDBMODE "r" 150. # define WRBMODE "w+" 151. #endif 152. 153. #endif /* DLB_H */