/tags/rel-2.0.1/Source/DOH/doh.h

# · C++ Header · 446 lines · 318 code · 65 blank · 63 comment · 0 complexity · 1c02e31b008db1d5ca47168736825533 MD5 · raw file

  1. /* -----------------------------------------------------------------------------
  2. * This file is part of SWIG, which is licensed as a whole under version 3
  3. * (or any later version) of the GNU General Public License. Some additional
  4. * terms also apply to certain portions of SWIG. The full details of the SWIG
  5. * license and copyrights can be found in the LICENSE and COPYRIGHT files
  6. * included with the SWIG source code as distributed by the SWIG developers
  7. * and at http://www.swig.org/legal.html.
  8. *
  9. * doh.h
  10. *
  11. * This file describes of the externally visible functions in DOH.
  12. * ----------------------------------------------------------------------------- */
  13. #ifndef _DOH_H
  14. #define _DOH_H
  15. #ifndef MACSWIG
  16. #include "swigconfig.h"
  17. #endif
  18. #include <stdio.h>
  19. #include <stdarg.h>
  20. /* Set the namespace prefix for DOH API functions. This can be used to control
  21. visibility of the functions in libraries */
  22. /* Set this macro if you want to change DOH linkage. You would do this if you
  23. wanted to hide DOH in a library using a different set of names. Note: simply
  24. change "Doh" to a new name. */
  25. /*
  26. #define DOH_NAMESPACE(x) Doh ## x
  27. */
  28. #ifdef DOH_NAMESPACE
  29. /* Namespace control. These macros define all of the public API names in DOH */
  30. #define DohCheck DOH_NAMESPACE(Check)
  31. #define DohIntern DOH_NAMESPACE(Intern)
  32. #define DohDelete DOH_NAMESPACE(Delete)
  33. #define DohCopy DOH_NAMESPACE(Copy)
  34. #define DohClear DOH_NAMESPACE(Clear)
  35. #define DohStr DOH_NAMESPACE(Str)
  36. #define DohData DOH_NAMESPACE(Data)
  37. #define DohDump DOH_NAMESPACE(Dump)
  38. #define DohLen DOH_NAMESPACE(Len)
  39. #define DohHashval DOH_NAMESPACE(Hashval)
  40. #define DohCmp DOH_NAMESPACE(Cmp)
  41. #define DohEqual DOH_NAMESPACE(Equal)
  42. #define DohIncref DOH_NAMESPACE(Incref)
  43. #define DohCheckattr DOH_NAMESPACE(Checkattr)
  44. #define DohSetattr DOH_NAMESPACE(Setattr)
  45. #define DohDelattr DOH_NAMESPACE(Delattr)
  46. #define DohKeys DOH_NAMESPACE(Keys)
  47. #define DohGetInt DOH_NAMESPACE(GetInt)
  48. #define DohGetDouble DOH_NAMESPACE(GetDouble)
  49. #define DohGetChar DOH_NAMESPACE(GetChar)
  50. #define DohSetChar DOH_NAMESPACE(SetChar)
  51. #define DohSetInt DOH_NAMESPACE(SetInt)
  52. #define DohSetDouble DOH_NAMESPACE(SetDouble)
  53. #define DohSetVoid DOH_NAMESPACE(SetVoid)
  54. #define DohGetVoid DOH_NAMESPACE(GetVoid)
  55. #define DohGetitem DOH_NAMESPACE(Getitem)
  56. #define DohSetitem DOH_NAMESPACE(Setitem)
  57. #define DohDelitem DOH_NAMESPACE(Delitem)
  58. #define DohInsertitem DOH_NAMESPACE(Insertitem)
  59. #define DohDelslice DOH_NAMESPACE(Delslice)
  60. #define DohWrite DOH_NAMESPACE(Write)
  61. #define DohRead DOH_NAMESPACE(Read)
  62. #define DohSeek DOH_NAMESPACE(Seek)
  63. #define DohTell DOH_NAMESPACE(Tell)
  64. #define DohGetc DOH_NAMESPACE(Getc)
  65. #define DohPutc DOH_NAMESPACE(Putc)
  66. #define DohUngetc DOH_NAMESPACE(Ungetc)
  67. #define DohGetline DOH_NAMESPACE(Getline)
  68. #define DohSetline DOH_NAMESPACE(Setline)
  69. #define DohGetfile DOH_NAMESPACE(Getfile)
  70. #define DohSetfile DOH_NAMESPACE(Setfile)
  71. #define DohReplace DOH_NAMESPACE(Replace)
  72. #define DohChop DOH_NAMESPACE(Chop)
  73. #define DohGetmeta DOH_NAMESPACE(Getmeta)
  74. #define DohSetmeta DOH_NAMESPACE(Setmeta)
  75. #define DohDelmeta DOH_NAMESPACE(Delmeta)
  76. #define DohEncoding DOH_NAMESPACE(Encoding)
  77. #define DohPrintf DOH_NAMESPACE(Printf)
  78. #define DohvPrintf DOH_NAMESPACE(vPrintf)
  79. #define DohPrintv DOH_NAMESPACE(Printv)
  80. #define DohReadline DOH_NAMESPACE(Readline)
  81. #define DohIsMapping DOH_NAMESPACE(IsMapping)
  82. #define DohIsSequence DOH_NAMESPACE(IsSequence)
  83. #define DohIsString DOH_NAMESPACE(IsString)
  84. #define DohIsFile DOH_NAMESPACE(IsFile)
  85. #define DohNewString DOH_NAMESPACE(NewString)
  86. #define DohNewStringEmpty DOH_NAMESPACE(NewStringEmpty)
  87. #define DohNewStringWithSize DOH_NAMESPACE(NewStringWithSize)
  88. #define DohNewStringf DOH_NAMESPACE(NewStringf)
  89. #define DohStrcmp DOH_NAMESPACE(Strcmp)
  90. #define DohStrncmp DOH_NAMESPACE(Strncmp)
  91. #define DohStrstr DOH_NAMESPACE(Strstr)
  92. #define DohStrchr DOH_NAMESPACE(Strchr)
  93. #define DohNewFile DOH_NAMESPACE(NewFile)
  94. #define DohNewFileFromFile DOH_NAMESPACE(NewFileFromFile)
  95. #define DohNewFileFromFd DOH_NAMESPACE(NewFileFromFd)
  96. #define DohFileErrorDisplay DOH_NAMESPACE(FileErrorDisplay)
  97. #define DohClose DOH_NAMESPACE(Close)
  98. #define DohCopyto DOH_NAMESPACE(Copyto)
  99. #define DohNewList DOH_NAMESPACE(NewList)
  100. #define DohNewHash DOH_NAMESPACE(NewHash)
  101. #define DohNewVoid DOH_NAMESPACE(NewVoid)
  102. #define DohSplit DOH_NAMESPACE(Split)
  103. #define DohSplitLines DOH_NAMESPACE(SplitLines)
  104. #define DohNone DOH_NAMESPACE(None)
  105. #define DohCall DOH_NAMESPACE(Call)
  106. #define DohObjMalloc DOH_NAMESPACE(ObjMalloc)
  107. #define DohObjFree DOH_NAMESPACE(ObjFree)
  108. #define DohMemoryDebug DOH_NAMESPACE(MemoryDebug)
  109. #define DohStringType DOH_NAMESPACE(StringType)
  110. #define DohListType DOH_NAMESPACE(ListType)
  111. #define DohHashType DOH_NAMESPACE(HashType)
  112. #define DohFileType DOH_NAMESPACE(FileType)
  113. #define DohVoidType DOH_NAMESPACE(VoidType)
  114. #define DohIterator DOH_NAMESPACE(Iterator)
  115. #define DohFirst DOH_NAMESPACE(First)
  116. #define DohNext DOH_NAMESPACE(Next)
  117. #endif
  118. #define DOH_MAJOR_VERSION 0
  119. #define DOH_MINOR_VERSION 1
  120. typedef void DOH;
  121. /*
  122. * With dynamic typing, all DOH objects are technically of type 'void *'.
  123. * However, to clarify the reading of source code, the following symbolic
  124. * names are used.
  125. */
  126. #define DOHString DOH
  127. #define DOHList DOH
  128. #define DOHHash DOH
  129. #define DOHFile DOH
  130. #define DOHVoid DOH
  131. #define DOHString_or_char DOH
  132. #define DOHObj_or_char DOH
  133. typedef const DOHString_or_char * const_String_or_char_ptr;
  134. typedef const DOHString_or_char * DOHconst_String_or_char_ptr;
  135. #define DOH_BEGIN -1
  136. #define DOH_END -2
  137. #define DOH_CUR -3
  138. #define DOH_CURRENT -3
  139. /* Iterator objects */
  140. typedef struct {
  141. void *key; /* Current key (if any) */
  142. void *item; /* Current item */
  143. void *object; /* Object being iterated over */
  144. void *_current; /* Internal use */
  145. int _index; /* Internal use */
  146. } DohIterator;
  147. /* Memory management */
  148. #ifndef DohMalloc
  149. #define DohMalloc malloc
  150. #endif
  151. #ifndef DohRealloc
  152. #define DohRealloc realloc
  153. #endif
  154. #ifndef DohFree
  155. #define DohFree free
  156. #endif
  157. extern int DohCheck(const DOH *ptr); /* Check if a DOH object */
  158. extern void DohIntern(DOH *); /* Intern an object */
  159. /* Basic object methods. Common to most objects */
  160. extern void DohDelete(DOH *obj); /* Delete an object */
  161. extern DOH *DohCopy(const DOH *obj);
  162. extern void DohClear(DOH *obj);
  163. extern DOHString *DohStr(const DOH *obj);
  164. extern void *DohData(const DOH *obj);
  165. extern int DohDump(const DOH *obj, DOHFile * out);
  166. extern int DohLen(const DOH *obj);
  167. extern int DohHashval(const DOH *obj);
  168. extern int DohCmp(const DOH *obj1, const DOH *obj2);
  169. extern int DohEqual(const DOH *obj1, const DOH *obj2);
  170. extern void DohIncref(DOH *obj);
  171. /* Mapping methods */
  172. extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name);
  173. extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char * value);
  174. extern int DohDelattr(DOH *obj, const DOHString_or_char *name);
  175. extern int DohCheckattr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *value);
  176. extern DOH *DohKeys(DOH *obj);
  177. extern int DohGetInt(DOH *obj, const DOHString_or_char *name);
  178. extern void DohSetInt(DOH *obj, const DOHString_or_char *name, int);
  179. extern double DohGetDouble(DOH *obj, const DOHString_or_char *name);
  180. extern void DohSetDouble(DOH *obj, const DOHString_or_char *name, double);
  181. extern char *DohGetChar(DOH *obj, const DOHString_or_char *name);
  182. extern void DohSetChar(DOH *obj, const DOH *name, char *value);
  183. extern void *DohGetFlagAttr(DOH *obj, const DOHString_or_char *name);
  184. extern int DohGetFlag(DOH *obj, const DOHString_or_char *name);
  185. extern void DohSetFlagAttr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *attr);
  186. extern void DohSetFlag(DOH *obj, const DOHString_or_char *name);
  187. extern void *DohGetVoid(DOH *obj, const DOHString_or_char *name);
  188. extern void DohSetVoid(DOH *obj, const DOHString_or_char *name, void *value);
  189. /* Sequence methods */
  190. extern DOH *DohGetitem(DOH *obj, int index);
  191. extern int DohSetitem(DOH *obj, int index, const DOHObj_or_char * value);
  192. extern int DohDelitem(DOH *obj, int index);
  193. extern int DohInsertitem(DOH *obj, int index, const DOHObj_or_char * value);
  194. extern int DohDelslice(DOH *obj, int sindex, int eindex);
  195. /* File methods */
  196. extern int DohWrite(DOHFile * obj, const void *buffer, int length);
  197. extern int DohRead(DOHFile * obj, void *buffer, int length);
  198. extern int DohSeek(DOHFile * obj, long offset, int whence);
  199. extern long DohTell(DOHFile * obj);
  200. extern int DohGetc(DOHFile * obj);
  201. extern int DohPutc(int ch, DOHFile * obj);
  202. extern int DohUngetc(int ch, DOHFile * obj);
  203. /* Iterators */
  204. extern DohIterator DohFirst(DOH *obj);
  205. extern DohIterator DohNext(DohIterator x);
  206. /* Positional */
  207. extern int DohGetline(const DOH *obj);
  208. extern void DohSetline(DOH *obj, int line);
  209. extern DOH *DohGetfile(const DOH *obj);
  210. extern void DohSetfile(DOH *obj, DOH *file);
  211. /* String Methods */
  212. extern int DohReplace(DOHString * src, const DOHString_or_char *token, const DOHString_or_char *rep, int flags);
  213. extern void DohChop(DOHString * src);
  214. /* Meta-variables */
  215. extern DOH *DohGetmeta(DOH *, const DOH *);
  216. extern int DohSetmeta(DOH *, const DOH *, const DOH *value);
  217. extern int DohDelmeta(DOH *, const DOH *);
  218. /* Utility functions */
  219. extern void DohEncoding(char *name, DOH *(*fn) (DOH *s));
  220. extern int DohPrintf(DOHFile * obj, const char *format, ...);
  221. extern int DohvPrintf(DOHFile * obj, const char *format, va_list ap);
  222. extern int DohPrintv(DOHFile * obj, ...);
  223. extern DOH *DohReadline(DOHFile * in);
  224. /* Miscellaneous */
  225. extern int DohIsMapping(const DOH *obj);
  226. extern int DohIsSequence(const DOH *obj);
  227. extern int DohIsString(const DOH *obj);
  228. extern int DohIsFile(const DOH *obj);
  229. extern void DohSetMaxHashExpand(int count);
  230. extern int DohGetMaxHashExpand(void);
  231. extern void DohSetmark(DOH *obj, int x);
  232. extern int DohGetmark(DOH *obj);
  233. /* -----------------------------------------------------------------------------
  234. * Strings.
  235. * ----------------------------------------------------------------------------- */
  236. extern DOHString *DohNewStringEmpty(void);
  237. extern DOHString *DohNewString(const DOH *c);
  238. extern DOHString *DohNewStringWithSize(const DOH *c, int len);
  239. extern DOHString *DohNewStringf(const DOH *fmt, ...);
  240. extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
  241. extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
  242. extern char *DohStrstr(const DOHString_or_char *s1, const DOHString_or_char *s2);
  243. extern char *DohStrchr(const DOHString_or_char *s1, int ch);
  244. /* String replacement flags */
  245. #define DOH_REPLACE_ANY 0x01
  246. #define DOH_REPLACE_NOQUOTE 0x02
  247. #define DOH_REPLACE_ID 0x04
  248. #define DOH_REPLACE_FIRST 0x08
  249. #define DOH_REPLACE_ID_BEGIN 0x10
  250. #define DOH_REPLACE_ID_END 0x20
  251. #define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY)
  252. #define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID)
  253. /* -----------------------------------------------------------------------------
  254. * Files
  255. * ----------------------------------------------------------------------------- */
  256. extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
  257. extern DOHFile *DohNewFileFromFile(FILE *f);
  258. extern DOHFile *DohNewFileFromFd(int fd);
  259. extern void DohFileErrorDisplay(DOHString * filename);
  260. extern int DohClose(DOH *file);
  261. extern int DohCopyto(DOHFile * input, DOHFile * output);
  262. /* -----------------------------------------------------------------------------
  263. * List
  264. * ----------------------------------------------------------------------------- */
  265. extern DOHList *DohNewList(void);
  266. extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *));
  267. /* -----------------------------------------------------------------------------
  268. * Hash
  269. * ----------------------------------------------------------------------------- */
  270. extern DOHHash *DohNewHash(void);
  271. /* -----------------------------------------------------------------------------
  272. * Void
  273. * ----------------------------------------------------------------------------- */
  274. extern DOHVoid *DohNewVoid(void *ptr, void (*del) (void *));
  275. extern DOHList *DohSplit(DOHFile * input, char ch, int nsplits);
  276. extern DOHList *DohSplitLines(DOHFile * input);
  277. extern DOH *DohNone;
  278. extern void DohMemoryDebug(void);
  279. #ifndef DOH_LONG_NAMES
  280. /* Macros to invoke the above functions. Includes the location of
  281. the caller to simplify debugging if something goes wrong */
  282. #define Delete DohDelete
  283. #define Copy DohCopy
  284. #define Clear DohClear
  285. #define Str DohStr
  286. #define Dump DohDump
  287. #define Getattr DohGetattr
  288. #define Setattr DohSetattr
  289. #define Delattr DohDelattr
  290. #define Checkattr DohCheckattr
  291. #define Hashval DohHashval
  292. #define Getitem DohGetitem
  293. #define Setitem DohSetitem
  294. #define Delitem DohDelitem
  295. #define Insert DohInsertitem
  296. #define Delslice DohDelslice
  297. #define Append(s,x) DohInsertitem(s,DOH_END,x)
  298. #define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
  299. #define Len DohLen
  300. #define Data DohData
  301. #define Char (char *) Data
  302. #define Cmp DohCmp
  303. #define Equal DohEqual
  304. #define Setline DohSetline
  305. #define Getline DohGetline
  306. #define Setfile DohSetfile
  307. #define Getfile DohGetfile
  308. #define Write DohWrite
  309. #define Read DohRead
  310. #define Seek DohSeek
  311. #define Tell DohTell
  312. #define Printf DohPrintf
  313. #define Printv DohPrintv
  314. #define Getc DohGetc
  315. #define Putc DohPutc
  316. #define Ungetc DohUngetc
  317. /* #define StringPutc DohStringPutc */
  318. /* #define StringGetc DohStringGetc */
  319. /* #define StringUngetc DohStringUngetc */
  320. /* #define StringAppend Append */
  321. /* #define StringLen DohStringLen */
  322. /* #define StringChar DohStringChar */
  323. /* #define StringEqual DohStringEqual */
  324. #define Close DohClose
  325. #define vPrintf DohvPrintf
  326. #define GetInt DohGetInt
  327. #define GetDouble DohGetDouble
  328. #define GetChar DohGetChar
  329. #define GetVoid DohGetVoid
  330. #define GetFlagAttr DohGetFlagAttr
  331. #define GetFlag DohGetFlag
  332. #define SetInt DohSetInt
  333. #define SetDouble DohSetDouble
  334. #define SetChar DohSetattr
  335. #define SetVoid DohSetVoid
  336. #define SetFlagAttr DohSetFlagAttr
  337. #define SetFlag DohSetFlag
  338. #define UnsetFlag(o,n) DohSetFlagAttr(o,n,NULL)
  339. #define ClearFlag(o,n) DohSetFlagAttr(o,n,"")
  340. #define Readline DohReadline
  341. #define Replace DohReplace
  342. #define Chop DohChop
  343. #define Getmeta DohGetmeta
  344. #define Setmeta DohSetmeta
  345. #define Delmeta DohDelmeta
  346. #define NewString DohNewString
  347. #define NewStringEmpty DohNewStringEmpty
  348. #define NewStringWithSize DohNewStringWithSize
  349. #define NewStringf DohNewStringf
  350. #define NewHash DohNewHash
  351. #define NewList DohNewList
  352. #define NewFile DohNewFile
  353. #define NewFileFromFile DohNewFileFromFile
  354. #define NewFileFromFd DohNewFileFromFd
  355. #define FileErrorDisplay DohFileErrorDisplay
  356. #define Close DohClose
  357. #define NewVoid DohNewVoid
  358. #define Keys DohKeys
  359. #define Strcmp DohStrcmp
  360. #define Strncmp DohStrncmp
  361. #define Strstr DohStrstr
  362. #define Strchr DohStrchr
  363. #define Copyto DohCopyto
  364. #define Split DohSplit
  365. #define SplitLines DohSplitLines
  366. #define Setmark DohSetmark
  367. #define Getmark DohGetmark
  368. #define SetMaxHashExpand DohSetMaxHashExpand
  369. #define GetMaxHashExpand DohGetMaxHashExpand
  370. #define None DohNone
  371. #define Call DohCall
  372. #define First DohFirst
  373. #define Next DohNext
  374. #define Iterator DohIterator
  375. #define SortList DohSortList
  376. #endif
  377. #ifdef NIL
  378. #undef NIL
  379. #endif
  380. #define NIL (char *) NULL
  381. #endif /* DOH_H */