modules: remove support for module unload and refcount.
[m4/ericb.git] / modules / modtest.c
blob385049b41d634023f43d9c0be06d05ecfa7587a3
1 /* GNU m4 -- A simple macro processor
2 Copyright (C) 1999-2001, 2003-2004, 2006-2008, 2010, 2013 Free
3 Software Foundation, Inc.
5 This file is part of GNU M4.
7 GNU M4 is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU M4 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <config.h>
23 /* Build using only the exported interfaces, unless NDEBUG is set, in
24 which case use private symbols to speed things up as much as possible. */
25 #ifndef NDEBUG
26 # include <m4/m4module.h>
27 #else
28 # include "m4private.h"
29 #endif
31 /* Rename exported symbols for dlpreload()ing. */
32 #define m4_builtin_table modtest_LTX_m4_builtin_table
33 #define m4_macro_table modtest_LTX_m4_macro_table
35 #define export_test modtest_LTX_export_test
37 extern bool export_test (const char *foo);
39 /* function macros blind side minargs maxargs */
40 #define builtin_functions \
41 BUILTIN (test, false, false, false, 0, 0)
43 #define BUILTIN(handler, macros, blind, side, min, max) M4BUILTIN (handler)
44 builtin_functions
45 #undef BUILTIN
47 const m4_builtin m4_builtin_table[] =
49 #define BUILTIN(handler, macros, blind, side, min, max) \
50 M4BUILTIN_ENTRY (handler, #handler, macros, blind, side, min, max)
52 builtin_functions
53 #undef BUILTIN
55 { NULL, NULL, 0, 0, 0 },
58 const m4_macro m4_macro_table[] =
60 /* name text min max */
61 { "__test__", "`modtest'", 0, 0 },
62 { "onearg", "$1", 1, 1 },
63 { "manyargs", "$@", 0, SIZE_MAX },
64 { NULL, NULL, 0, 0 },
69 /**
70 * modtest()
71 **/
72 M4INIT_HANDLER (modtest)
74 const char *s = "Test module loaded.\n";
76 /* Don't depend on OBS so that the traces are the same when used
77 directly, or via a frozen file. */
78 fputs (s, stderr);
82 /**
83 * test()
84 **/
85 M4BUILTIN_HANDLER (test)
87 const char *s = "Test module called.";
89 assert (obs != 0);
90 obstack_grow (obs, s, strlen(s));
94 /**
95 * export_test()
96 **/
97 bool
98 export_test (const char *foo)
100 if (foo)
101 xfprintf (stderr, "%s\n", foo);
102 return (bool) (foo != 0);