PageRenderTime 59ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/src/wml_backend/p2_mp4h/src/mp4h.h

https://bitbucket.org/shlomif/website-meta-language
C Header | 745 lines | 510 code | 130 blank | 105 comment | 42 complexity | b2eb1186605c98a7553ed91a7d9a8f2a MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.0
  1. /* mp4h -- A macro processor for HTML documents
  2. Copyright 2000-2002, Denis Barbier
  3. All rights reserved.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is a work based on GNU m4 version 1.4n. Below is the
  9. original copyright.
  10. */
  11. /* GNU m4 -- A simple macro processor
  12. Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2, or (at your option)
  16. any later version.
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21. You should have received a copy of the GNU General Public License
  22. along with this program; if not, write to the Free Software
  23. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #ifndef MP4H_H
  26. #define MP4H_H
  27. #ifdef HAVE_CONFIG_H
  28. # include <config.h>
  29. #endif
  30. #include <sys/types.h>
  31. # define voidstar void *
  32. #include <stdio.h>
  33. #include <ctype.h>
  34. #include "obstack.h"
  35. /* An ANSI string.h and pre-ANSI memory.h might conflict. */
  36. #if defined (HAVE_STRING_H) || defined (STDC_HEADERS)
  37. # include <string.h>
  38. # if !defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
  39. # include <memory.h>
  40. # endif
  41. /* This is for obstack code -- should live in obstack.h. */
  42. # ifndef bcopy
  43. # define bcopy(S, D, N) memcpy ((D), (S), (N))
  44. # endif
  45. #else
  46. # include <strings.h>
  47. # ifndef memcpy
  48. # define memcpy(D, S, N) bcopy((S), (D), (N))
  49. # endif
  50. # ifndef strchr
  51. # define strchr(S, C) index ((S), (C))
  52. # endif
  53. # ifndef strrchr
  54. # define strrchr(S, C) rindex ((S), (C))
  55. # endif
  56. # ifndef bcopy
  57. void bcopy ();
  58. # endif
  59. #endif
  60. #ifdef STDC_HEADERS
  61. # include <stdlib.h>
  62. #else /* not STDC_HEADERS */
  63. voidstar malloc ();
  64. voidstar realloc ();
  65. char *getenv ();
  66. double atof ();
  67. long strtol ();
  68. #endif /* STDC_HEADERS */
  69. /* Some systems do not define EXIT_*, even with STDC_HEADERS. */
  70. #ifndef EXIT_SUCCESS
  71. # define EXIT_SUCCESS 0
  72. #endif
  73. #ifndef EXIT_FAILURE
  74. # define EXIT_FAILURE 1
  75. #endif
  76. #include <errno.h>
  77. #ifndef errno
  78. extern int errno;
  79. #endif
  80. #ifdef HAVE_UNISTD_H
  81. # include <unistd.h>
  82. #endif
  83. /* If FALSE is defined, we presume TRUE is defined too. In this case,
  84. merely typedef boolean as being int. Or else, define these all. */
  85. #ifndef FALSE
  86. # define FALSE 0
  87. # define TRUE 1
  88. #endif
  89. typedef int boolean;
  90. char *mktemp ();
  91. #ifndef __P
  92. # ifdef PROTOTYPES
  93. # define __P(Args) Args
  94. # else
  95. # define __P(Args) ()
  96. # endif
  97. #endif
  98. #if HAVE_LOCALE_H
  99. # include <locale.h>
  100. #else
  101. # define setlocale(Category, Locale)
  102. #endif
  103. #ifdef ENABLE_NLS
  104. #include <libintl.h>
  105. #define _(Text) gettext ((Text))
  106. #else
  107. #define _(Text) (Text)
  108. #endif
  109. /* Last character of a string. */
  110. #define LAST_CHAR(Text) *(Text + strlen (Text) - 1)
  111. /* Various declarations. */
  112. struct _string
  113. {
  114. char *string; /* characters of the string */
  115. size_t length; /* length of the string */
  116. };
  117. typedef struct _string STRING;
  118. /* Those must come first. */
  119. typedef void builtin_func ();
  120. /* Various different token types. */
  121. enum _token_type
  122. {
  123. TOKEN_EOF, /* end of file */
  124. TOKEN_NONE, /* discardable token */
  125. TOKEN_STRING, /* a string */
  126. TOKEN_QUOTED, /* a quoted string */
  127. TOKEN_QUOTE, /* begin delimiter of a quoted string
  128. to expand */
  129. TOKEN_BGROUP, /* begin group */
  130. TOKEN_EGROUP, /* end group */
  131. TOKEN_SPACE, /* whitespace */
  132. TOKEN_WORD, /* an identifier */
  133. TOKEN_ENTITY, /* an entity */
  134. TOKEN_SIMPLE, /* a single character */
  135. TOKEN_MACDEF /* a macros definition (see "defn") */
  136. };
  137. typedef enum _token_type token_type;
  138. /* The data for a token, a macro argument, and a macro definition. */
  139. enum _token_data_type
  140. {
  141. TOKEN_VOID,
  142. TOKEN_TEXT,
  143. TOKEN_FUNC
  144. };
  145. typedef enum _token_data_type token_data_type;
  146. struct _token_data
  147. {
  148. token_data_type type;
  149. union
  150. {
  151. struct
  152. {
  153. char *text;
  154. }
  155. u_t;
  156. struct
  157. {
  158. builtin_func *func;
  159. boolean traced;
  160. }
  161. u_f;
  162. }
  163. u;
  164. };
  165. typedef struct _token_data token_data;
  166. /* Memory allocation. */
  167. voidstar xmalloc __P ((size_t));
  168. voidstar xcalloc __P ((size_t, size_t));
  169. voidstar xrealloc __P ((voidstar , size_t));
  170. void xfree __P ((voidstar));
  171. char *xstrdup __P ((const char *));
  172. #define obstack_chunk_alloc xmalloc
  173. #define obstack_chunk_free xfree
  174. /* Other library routines. */
  175. void error __P ((int, int, const char *, ...));
  176. /* File: mp4h.c --- global definitions. */
  177. /* Option flags. */
  178. extern int interactive; /* -e */
  179. extern int sync_output; /* -s */
  180. extern int debug_level; /* -d */
  181. extern int hash_table_size; /* -H */
  182. extern int max_debug_argument_length; /* -l */
  183. extern int suppress_warnings; /* -Q */
  184. extern int warning_status; /* -E */
  185. extern int nesting_limit; /* -L */
  186. extern int frozen_dump; /* -F */
  187. /* Error handling. */
  188. #define MP4HERROR(Arglist) (error Arglist)
  189. /* File: debug.c --- debugging and tracing function. */
  190. extern FILE *debug;
  191. /* The value of debug_level is a bitmask of the following. */
  192. /* a: show arglist in trace output */
  193. #define DEBUG_TRACE_ARGS 1
  194. /* e: show expansion in trace output */
  195. #define DEBUG_TRACE_EXPANSION 2
  196. /* t: trace all macros -- overrides trace{on,off} */
  197. #define DEBUG_TRACE_ALL 8
  198. /* l: add line numbers to trace output */
  199. #define DEBUG_TRACE_LINE 16
  200. /* f: add file name to trace output */
  201. #define DEBUG_TRACE_FILE 32
  202. /* p: trace path search of include files */
  203. #define DEBUG_TRACE_PATH 64
  204. /* c: show macro call before args collection */
  205. #define DEBUG_TRACE_CALL 128
  206. /* i: trace changes of input files */
  207. #define DEBUG_TRACE_INPUT 256
  208. /* x: add call id to trace output */
  209. #define DEBUG_TRACE_CALLID 512
  210. /* m: trace module loading */
  211. #define DEBUG_TRACE_MODULES 1024
  212. /* V: very verbose -- print everything */
  213. #define DEBUG_TRACE_VERBOSE 1023
  214. /* default flags -- equiv: ae */
  215. #define DEBUG_TRACE_DEFAULT 3
  216. #define DEBUG_PRINT1(Fmt, Arg1) \
  217. do \
  218. { \
  219. if (debug != NULL) \
  220. fprintf (debug, Fmt, Arg1); \
  221. } \
  222. while (0)
  223. #define DEBUG_PRINT3(Fmt, Arg1, Arg2, Arg3) \
  224. do \
  225. { \
  226. if (debug != NULL) \
  227. fprintf (debug, Fmt, Arg1, Arg2, Arg3); \
  228. } \
  229. while (0)
  230. #define DEBUG_MESSAGE(Fmt) \
  231. do \
  232. { \
  233. if (debug != NULL) \
  234. { \
  235. debug_message_prefix (); \
  236. fprintf (debug, Fmt); \
  237. putc ('\n', debug); \
  238. } \
  239. } \
  240. while (0)
  241. #define DEBUG_MESSAGE1(Fmt, Arg1) \
  242. do \
  243. { \
  244. if (debug != NULL) \
  245. { \
  246. debug_message_prefix (); \
  247. fprintf (debug, Fmt, Arg1); \
  248. putc ('\n', debug); \
  249. } \
  250. } \
  251. while (0)
  252. #define DEBUG_MESSAGE2(Fmt, Arg1, Arg2) \
  253. do \
  254. { \
  255. if (debug != NULL) \
  256. { \
  257. debug_message_prefix (); \
  258. fprintf (debug, Fmt, Arg1, Arg2); \
  259. putc ('\n', debug); \
  260. } \
  261. } \
  262. while (0)
  263. void debug_init __P ((void));
  264. void debug_deallocate __P ((void));
  265. int debug_decode __P ((const char *));
  266. void debug_flush_files __P ((void));
  267. boolean debug_set_output __P ((const char *));
  268. void debug_message_prefix __P ((void));
  269. void trace_prepre __P ((const char *, int));
  270. void trace_pre __P ((const char *, int, int, token_data **));
  271. void trace_post __P ((const char *, int, int, token_data **, const char *));
  272. /* File: input.c --- lexical definitions. */
  273. #define TOKEN_DATA_TYPE(Td) ((Td)->type)
  274. #define TOKEN_DATA_TEXT(Td) ((Td)->u.u_t.text)
  275. #define TOKEN_DATA_FUNC(Td) ((Td)->u.u_f.func)
  276. #define TOKEN_DATA_FUNC_TRACED(Td) ((Td)->u.u_f.traced)
  277. /* The status of processing. */
  278. #define READ_NORMAL (1 << 0) /* normal expansion of macros */
  279. #define READ_ATTRIBUTE (1 << 1) /* when reading macro arguments */
  280. #define READ_ATTR_QUOT (1 << 2) /* like READ_ATTRIBUTE, but quotes
  281. are preserved */
  282. #define READ_ATTR_VERB (1 << 3) /* inside macros with attributes=verbatim */
  283. #define READ_ATTR_ASIS (1 << 4) /* attributes are read without any
  284. modification, main difference with READ_ATTR_VERB is that quotes
  285. and backslashes are not removed and are part of this attribute */
  286. #define READ_BODY (1 << 5) /* when reading body function */
  287. /* Flags which determine how expansion is done */
  288. #define EXP_NO_HTMLTAG (1 << 0) /* do not parse unknown tags */
  289. #define EXP_DFT_SIMPLE (1 << 1) /* HTML tags are simple */
  290. #define EXP_STAR_COMPLEX (1 << 2) /* HTML tags whose last char is an asterisk
  291. are by default simple tags, they become
  292. complex when this flag is set. */
  293. #define EXP_UNM_BREAK (1 << 3) /* An unmatched end tag closes all previous
  294. unmatched begin tags. */
  295. #define EXP_STD_BSLASH (1 << 4) /* By default, only 'n', 'r', 't', '"' and
  296. '\\' are escaped. When this flag is
  297. set, backslashes are interpreted as in
  298. printf. */
  299. #define EXP_REMOVE_TRAILING_SLASH \
  300. (1 << 5) /* Remove trailing slash in simple tag attributes */
  301. #define EXP_LEAVE_TRAILING_STAR \
  302. (1 << 6) /* Do not remove trailing slash in simple tag attributes */
  303. #define EXP_LEAVE_LEADING_STAR \
  304. (1 << 7) /* Do not remove trailing slash in simple tag attributes */
  305. #define EXP_NOSPACE_BSLASH \
  306. (1 << 8) /* Do not add space before trailing slash in simple tag attributes */
  307. #define EXP_NOWARN_NEST (1 << 10) /* Suppress warning about bad nested tags */
  308. #define EXP_NOWARN_SLASH (1 << 11) /* Suppress warning about missing trailing slash */
  309. extern int exp_flags;
  310. typedef int read_type;
  311. void input_init __P ((void));
  312. void input_deallocate __P ((void));
  313. void syntax_init __P ((void));
  314. int peek_input __P ((void));
  315. token_type next_token __P ((token_data *, read_type, boolean));
  316. void skip_line __P ((void));
  317. void skip_buffer __P ((void));
  318. void input_close __P ((void));
  319. /* push back input */
  320. void push_file __P ((FILE *, const char *));
  321. void push_macro __P ((builtin_func *, boolean));
  322. void push_single __P ((int));
  323. struct obstack *push_string_init __P ((void));
  324. const char *push_string_finish __P ((read_type));
  325. void push_wrapup __P ((const char *));
  326. boolean pop_wrapup __P ((void));
  327. void unget_string __P ((char *));
  328. /* read a file verbatim */
  329. void read_file_verbatim __P ((struct obstack *));
  330. /* current input file, and line */
  331. extern char *current_file;
  332. extern int current_line;
  333. extern char **array_current_file;
  334. extern int *array_current_line;
  335. #define CURRENT_FILE_LINE \
  336. (expansion_level == 0 ? current_file : \
  337. array_current_file[expansion_level]), \
  338. (expansion_level == 0 ? current_line : \
  339. array_current_line[expansion_level])
  340. /* Begin and end quote */
  341. extern STRING lquote, rquote;
  342. /* Eof-of-line comment */
  343. extern STRING eolcomm;
  344. /* Special characters used for grouping */
  345. #define CHAR_LQUOTE '\1'
  346. #define CHAR_RQUOTE '\2'
  347. #define CHAR_BGROUP '\3'
  348. #define CHAR_EGROUP '\4'
  349. /* Some characters are replaced during input/output phases */
  350. #define CHAR_QUOTE '\5'
  351. #define CHAR_SLASH '\6'
  352. /* Default eof-of-line comment */
  353. #define DEF_EOLCOMM ";;;"
  354. /* Default quotes */
  355. #define DEF_LQUOTE "<@["
  356. #define DEF_RQUOTE "]@>"
  357. /* Syntax table definitions. */
  358. /* Please read the comment at the top of input.c for details */
  359. extern unsigned short syntax_table[256];
  360. /* These are simple values, not bit masks. There is no overlap. */
  361. #define SYNTAX_OTHER (0x0000)
  362. #define SYNTAX_IGNORE (0x0001)
  363. #define SYNTAX_SPACE (0x0002)
  364. #define SYNTAX_GROUP (0x0009)
  365. /* These are values to be assigned to syntax table entries, but they are
  366. used as bit masks with IS_ALNUM.*/
  367. #define SYNTAX_ALPHA (0x0010)
  368. #define SYNTAX_NUM (0x0020)
  369. #define SYNTAX_ALNUM (SYNTAX_ALPHA|SYNTAX_NUM)
  370. /* These bits define the syntax code of a character */
  371. #define SYNTAX_VALUE (0x00FF)
  372. #define SYNTAX_MASKS (0xFF00)
  373. #define IS_OTHER(ch) ((syntax_table[(int)(ch)]&SYNTAX_VALUE) == SYNTAX_OTHER)
  374. #define IS_IGNORE(ch) ((syntax_table[(int)(ch)]) == SYNTAX_IGNORE)
  375. #define IS_SPACE(ch) ((syntax_table[(int)(ch)]&SYNTAX_VALUE) == SYNTAX_SPACE)
  376. #define IS_ALPHA(ch) ((syntax_table[(int)(ch)]&SYNTAX_VALUE) == SYNTAX_ALPHA)
  377. #define IS_NUM(ch) ((syntax_table[(int)(ch)]&SYNTAX_VALUE) == SYNTAX_NUM)
  378. #define IS_ALNUM(ch) ((((syntax_table[(int)(ch)]) & SYNTAX_ALNUM) != 0) \
  379. || ch == ':' || ch == '-')
  380. #define IS_BGROUP(ch) (ch == CHAR_BGROUP)
  381. #define IS_EGROUP(ch) (ch == CHAR_EGROUP)
  382. #define IS_LQUOTE(ch) (ch == CHAR_LQUOTE)
  383. #define IS_RQUOTE(ch) (ch == CHAR_RQUOTE)
  384. #define IS_GROUP(ch) ((syntax_table[(int)(ch)]&SYNTAX_VALUE) == SYNTAX_GROUP)
  385. #define IS_SLASH(ch) (ch == CHAR_SLASH || ch == '/')
  386. #define IS_TAG(ch) (ch == '<')
  387. #define IS_CLOSE(ch) (ch == '>')
  388. #define IS_ENTITY(ch) (ch == '&')
  389. void set_syntax __P ((int, const char *));
  390. void set_syntax_internal __P ((int, int));
  391. void unset_syntax_attribute __P ((int, int));
  392. /* File: output.c --- output functions. */
  393. extern int current_diversion;
  394. extern int output_current_line;
  395. void output_init __P ((void));
  396. void output_deallocate __P ((void));
  397. void shipout_text __P ((struct obstack *, char *));
  398. void make_diversion __P ((int));
  399. void insert_diversion __P ((int));
  400. void insert_file __P ((FILE *));
  401. void freeze_diversions __P ((FILE *));
  402. void remove_special_chars __P ((char *, boolean));
  403. /* File symtab.c --- symbol table definitions. */
  404. /* Default case sensitiveness */
  405. #define CASELESS_DEFAULT 3
  406. /* Operation modes for lookup_symbol (). */
  407. enum _symbol_lookup
  408. {
  409. SYMBOL_LOOKUP,
  410. SYMBOL_INSERT,
  411. SYMBOL_DELETE
  412. };
  413. /* Symbol table entry. */
  414. struct _symbol
  415. {
  416. struct _symbol *next;
  417. boolean traced;
  418. boolean container;
  419. boolean expand_args;
  420. char *name;
  421. char *hook_begin;
  422. char *hook_end;
  423. token_data data;
  424. };
  425. #define SYMBOL_NEXT(S) ((S)->next)
  426. #define SYMBOL_TRACED(S) ((S)->traced)
  427. #define SYMBOL_CONTAINER(S) ((S)->container)
  428. #define SYMBOL_EXPAND_ARGS(S) ((S)->expand_args)
  429. #define SYMBOL_NAME(S) ((S)->name)
  430. #define SYMBOL_HOOK_BEGIN(S) ((S)->hook_begin)
  431. #define SYMBOL_HOOK_END(S) ((S)->hook_end)
  432. #define SYMBOL_TYPE(S) (TOKEN_DATA_TYPE (&(S)->data))
  433. #define SYMBOL_TEXT(S) (TOKEN_DATA_TEXT (&(S)->data))
  434. #define SYMBOL_FUNC(S) (TOKEN_DATA_FUNC (&(S)->data))
  435. typedef enum _symbol_lookup symbol_lookup;
  436. typedef struct _symbol symbol;
  437. typedef void hack_symbol ();
  438. #define HASHMAX 509 /* default, overridden by -Hsize */
  439. extern symbol **sym_tab;
  440. extern symbol **var_tab;
  441. extern symbol **file_tab;
  442. extern symbol **symtab;
  443. void symtab_init __P ((void));
  444. void symtab_deallocate __P ((void));
  445. void caseless_init __P ((int));
  446. symbol *lookup_symbol __P ((const char *, symbol_lookup));
  447. symbol *lookup_entity __P ((const char *, symbol_lookup));
  448. symbol *lookup_variable __P ((const char *, symbol_lookup));
  449. symbol *lookup_file __P ((const char *, symbol_lookup));
  450. void hack_all_symbols __P ((hack_symbol *, const char *));
  451. /* File: macro.c --- macro expansion. */
  452. void expand_input __P ((void));
  453. void call_macro __P ((symbol *, struct obstack *, int, token_data **, read_type));
  454. boolean get_attribute (struct obstack *obs, token_data *argp);
  455. extern int expansion_level;
  456. /* File: builtin.c --- builtins. */
  457. enum _encoding_type
  458. {
  459. ENCODING_8BIT, /* 1-byte char */
  460. ENCODING_UTF8 /* UTF-8 */
  461. };
  462. typedef enum _encoding_type encoding_type;
  463. struct _builtin
  464. {
  465. const char *name;
  466. boolean container;
  467. boolean expand_args;
  468. builtin_func *func;
  469. };
  470. typedef struct _builtin builtin;
  471. extern boolean visible_quotes;
  472. /* Used to disable risky functions. */
  473. extern int safety_level;
  474. /* Document encoding */
  475. extern encoding_type document_encoding;
  476. void locale_init __P ((int, char *));
  477. void pcre_init __P ((void));
  478. void pcre_deallocate __P ((void));
  479. void initialize_builtin __P ((symbol *));
  480. void builtin_init __P ((void));
  481. void builtin_deallocate __P ((void));
  482. void clear_tag_attr __P ((void));
  483. void define_builtin __P ((const char *, const builtin *, boolean));
  484. void break_init __P ((void));
  485. void break_deallocate __P ((void));
  486. void define_user_macro __P ((const char *, char *, symbol_lookup,
  487. boolean, boolean, boolean));
  488. void undivert_all __P ((void));
  489. void expand_user_macro __P ((struct obstack *, symbol *, int, token_data **,
  490. read_type));
  491. const builtin *find_builtin_by_addr __P ((builtin_func *));
  492. const builtin *find_builtin_by_name __P ((const char *));
  493. void install_builtin_table __P ((builtin *));
  494. /* File: devel.c --- global functions for writing builtins and modules. */
  495. boolean bad_argc __P ((token_data *, int, int, int));
  496. boolean numeric_arg __P ((token_data *, const char *, boolean, int *));
  497. void shipout_int __P ((struct obstack *, int));
  498. void shipout_long __P ((struct obstack *, long));
  499. void shipout_string __P ((struct obstack *, const char *, int));
  500. void dump_args __P ((struct obstack *, int, token_data **, const char *));
  501. const char * predefined_attribute __P ((const char *, int *, token_data **, boolean));
  502. /* File: path.c --- path search for include files. */
  503. void include_init __P ((void));
  504. void include_env_init __P ((void));
  505. void include_deallocate __P ((void));
  506. void add_include_directory __P ((const char *));
  507. FILE *path_search __P ((const char *, char **));
  508. /* These are for other search paths */
  509. struct search_path
  510. {
  511. struct search_path *next; /* next directory to search */
  512. const char *dir; /* directory */
  513. int len;
  514. };
  515. typedef struct search_path search_path;
  516. struct search_path_info
  517. {
  518. search_path *list; /* the list of path directories */
  519. search_path *list_end; /* the end of same */
  520. search_path *sys; /* system path directories */
  521. search_path *sys_end; /* the end of same */
  522. int max_length; /* length of longest directory name */
  523. };
  524. /* File: eval.c --- expression evaluation. */
  525. boolean evaluate __P ((struct obstack *obs,
  526. const char *, const int radix, int min));
  527. #ifdef WITH_GMP
  528. boolean mp_evaluate __P ((struct obstack *obs,
  529. const char *, const int radix, int min));
  530. #endif /* WITH_GMP */
  531. /* File: format.c --- printf like formatting. */
  532. void format __P ((struct obstack *, int, token_data **));
  533. /* File: freeze.c --- frozen state files. */
  534. void produce_frozen_state __P ((const char *));
  535. void reload_frozen_state __P ((const char *));
  536. /* File: module.c --- dynamic modules */
  537. #if defined(WITH_MODULES) || defined(MP4H_MODULE)
  538. typedef void module_init_t __P ((struct obstack *));
  539. typedef void module_finish_t __P ((void));
  540. typedef voidstar module_func __P ((const char *));
  541. void module_init __P ((void));
  542. void library_load __P ((const char *, struct obstack *));
  543. void module_load __P ((const char *, struct obstack *));
  544. void module_unload_all __P ((void));
  545. #endif
  546. /* Debugging the memory allocator. */
  547. #ifdef WITH_DMALLOC
  548. # define DMALLOC_FUNC_CHECK
  549. # include <dmalloc.h>
  550. #endif
  551. /* Other debug stuff. */
  552. #ifdef DEBUG
  553. # define DEBUG_INPUT
  554. # define DEBUG_MACRO
  555. # define DEBUG_SYM
  556. # define DEBUG_INCL
  557. #endif
  558. /* Stuff for compiling builtins and loadable modules. */
  559. #ifdef MP4H_MODULE
  560. #define MP4H_BUILTIN_ARGS struct obstack *obs, int argc, token_data **argv, \
  561. read_type expansion
  562. #define MP4H_BUILTIN_PROTO struct obstack *, int, token_data **, read_type
  563. #define MP4H_BUILTIN_RECUR obs, argc, argv, expansion
  564. #define DECLARE(name) \
  565. static void name __P ((MP4H_BUILTIN_PROTO))
  566. #define ARG(i) (i<argc ? TOKEN_DATA_TEXT (argv[i]) : "")
  567. #define ARGBODY (TOKEN_DATA_TEXT (argv[argc]))
  568. enum _mathop_type
  569. {
  570. MATHOP_ADD, /* addition */
  571. MATHOP_SUB, /* substraction */
  572. MATHOP_MUL, /* multiplication */
  573. MATHOP_DIV, /* division */
  574. MATHOP_MIN, /* minimum */
  575. MATHOP_MAX, /* maximum */
  576. MATHOP_MOD /* modulus */
  577. };
  578. enum _mathrel_type
  579. {
  580. MATHREL_GT,
  581. MATHREL_LT,
  582. MATHREL_EQ,
  583. MATHREL_NEQ
  584. };
  585. typedef enum _mathop_type mathop_type;
  586. typedef enum _mathrel_type mathrel_type;
  587. typedef struct var_stack var_stack;
  588. struct var_stack
  589. {
  590. var_stack *prev;
  591. char *text;
  592. };
  593. #endif
  594. #endif /* MP4H_H */