diff --git a/frontends/yasm/Makefile.inc b/frontends/yasm/Makefile.inc index 1e3134ea..05f3f169 100644 --- a/frontends/yasm/Makefile.inc +++ b/frontends/yasm/Makefile.inc @@ -42,8 +42,6 @@ yasm_SOURCES += \ src/main.c \ src/options.c \ src/options.h \ - src/objfmt.c \ - src/parser.c \ src/module.h \ src/module.c \ src/errwarn.c \ diff --git a/frontends/yasm/yasm-module.c b/frontends/yasm/yasm-module.c index 8b14a84f..f4ad1c59 100644 --- a/frontends/yasm/yasm-module.c +++ b/frontends/yasm/yasm-module.c @@ -30,6 +30,8 @@ #include "ltdl.h" #include "module.h" +#include "objfmt.h" +#include "parser.h" typedef struct module { @@ -40,6 +42,28 @@ typedef struct module { SLIST_HEAD(modulehead, module) modules = SLIST_HEAD_INITIALIZER(modules); +/* NULL-terminated list of all possibly available object format keywords. + * Could improve this a little by generating automatically at build-time. + */ +/*@-nullassign@*/ +const char *objfmts[] = { + "dbg", + "bin", + "coff", + NULL +}; +/*@=nullassign@*/ + +/* NULL-terminated list of all possibly available parser keywords. + * Could improve this a little by generating automatically at build-time. + */ +/*@-nullassign@*/ +const char *parsers[] = { + "nasm", + NULL +}; +/*@=nullassign@*/ + static /*@dependent@*/ /*@null@*/ module * load_module(const char *keyword) @@ -100,3 +124,31 @@ get_module_data(const char *keyword, const char *symbol) /* Find and return data pointer: NULL if it doesn't exist */ return lt_dlsym(m->handle, symbol); } + +void +list_objfmts(void (*printfunc) (const char *name, const char *keyword)) +{ + int i; + yasm_objfmt *of; + + /* Go through available list, and try to load each one */ + for (i = 0; objfmts[i]; i++) { + of = load_objfmt(objfmts[i]); + if (of) + printfunc(of->name, of->keyword); + } +} + +void +list_parsers(void (*printfunc) (const char *name, const char *keyword)) +{ + int i; + yasm_parser *p; + + /* Go through available list, and try to load each one */ + for (i = 0; parsers[i]; i++) { + p = load_parser(parsers[i]); + if (p) + printfunc(p->name, p->keyword); + } +} diff --git a/frontends/yasm/yasm-module.h b/frontends/yasm/yasm-module.h index 347b5ad2..35885013 100644 --- a/frontends/yasm/yasm-module.h +++ b/frontends/yasm/yasm-module.h @@ -38,4 +38,14 @@ void unload_modules(void); #define load_parser(keyword) get_module_data(keyword, "parser") #define load_preproc(keyword) get_module_data(keyword, "preproc") +/* Lists all available object formats. Calls printfunc with the name and + * keyword of each available format. + */ +void list_objfmts(void (*printfunc) (const char *name, const char *keyword)); + +/* Lists all available parsers. Calls printfunc with the name and keyword + * of each available parser. + */ +void list_parsers(void (*printfunc) (const char *name, const char *keyword)); + #endif diff --git a/libyasm/Makefile.inc b/libyasm/Makefile.inc index 1e3134ea..05f3f169 100644 --- a/libyasm/Makefile.inc +++ b/libyasm/Makefile.inc @@ -42,8 +42,6 @@ yasm_SOURCES += \ src/main.c \ src/options.c \ src/options.h \ - src/objfmt.c \ - src/parser.c \ src/module.h \ src/module.c \ src/errwarn.c \ diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h index af940311..aa691c64 100644 --- a/libyasm/objfmt.h +++ b/libyasm/objfmt.h @@ -123,13 +123,4 @@ struct yasm_objfmt { void (*bc_objfmt_data_print)(FILE *f, int indent_level, unsigned int type, const void *data); }; - -/* Generic functions for all object formats - implemented in src/objfmt.c */ - -/* Lists all available object formats. Calls printfunc with the name and - * keyword of each available format. - */ -void yasm_list_objfmts(void (*printfunc) (const char *name, - const char *keyword)); - #endif diff --git a/libyasm/parser.h b/libyasm/parser.h index fe86b630..24cbcd94 100644 --- a/libyasm/parser.h +++ b/libyasm/parser.h @@ -62,13 +62,4 @@ struct yasm_parser { (yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm, yasm_errwarn *we, FILE *f, const char *in_filename, int save_input); }; - -/* Generic functions for all parsers - implemented in src/parser.c */ - -/* Lists all available parsers. Calls printfunc with the name and keyword - * of each available parser. - */ -void yasm_list_parsers(void (*printfunc) (const char *name, - const char *keyword)); - #endif diff --git a/modules/Makefile.inc b/modules/Makefile.inc index 1e3134ea..05f3f169 100644 --- a/modules/Makefile.inc +++ b/modules/Makefile.inc @@ -42,8 +42,6 @@ yasm_SOURCES += \ src/main.c \ src/options.c \ src/options.h \ - src/objfmt.c \ - src/parser.c \ src/module.h \ src/module.c \ src/errwarn.c \ diff --git a/src/Makefile.inc b/src/Makefile.inc index 1e3134ea..05f3f169 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -42,8 +42,6 @@ yasm_SOURCES += \ src/main.c \ src/options.c \ src/options.h \ - src/objfmt.c \ - src/parser.c \ src/module.h \ src/module.c \ src/errwarn.c \ diff --git a/src/module.c b/src/module.c index 8b14a84f..f4ad1c59 100644 --- a/src/module.c +++ b/src/module.c @@ -30,6 +30,8 @@ #include "ltdl.h" #include "module.h" +#include "objfmt.h" +#include "parser.h" typedef struct module { @@ -40,6 +42,28 @@ typedef struct module { SLIST_HEAD(modulehead, module) modules = SLIST_HEAD_INITIALIZER(modules); +/* NULL-terminated list of all possibly available object format keywords. + * Could improve this a little by generating automatically at build-time. + */ +/*@-nullassign@*/ +const char *objfmts[] = { + "dbg", + "bin", + "coff", + NULL +}; +/*@=nullassign@*/ + +/* NULL-terminated list of all possibly available parser keywords. + * Could improve this a little by generating automatically at build-time. + */ +/*@-nullassign@*/ +const char *parsers[] = { + "nasm", + NULL +}; +/*@=nullassign@*/ + static /*@dependent@*/ /*@null@*/ module * load_module(const char *keyword) @@ -100,3 +124,31 @@ get_module_data(const char *keyword, const char *symbol) /* Find and return data pointer: NULL if it doesn't exist */ return lt_dlsym(m->handle, symbol); } + +void +list_objfmts(void (*printfunc) (const char *name, const char *keyword)) +{ + int i; + yasm_objfmt *of; + + /* Go through available list, and try to load each one */ + for (i = 0; objfmts[i]; i++) { + of = load_objfmt(objfmts[i]); + if (of) + printfunc(of->name, of->keyword); + } +} + +void +list_parsers(void (*printfunc) (const char *name, const char *keyword)) +{ + int i; + yasm_parser *p; + + /* Go through available list, and try to load each one */ + for (i = 0; parsers[i]; i++) { + p = load_parser(parsers[i]); + if (p) + printfunc(p->name, p->keyword); + } +} diff --git a/src/module.h b/src/module.h index 347b5ad2..35885013 100644 --- a/src/module.h +++ b/src/module.h @@ -38,4 +38,14 @@ void unload_modules(void); #define load_parser(keyword) get_module_data(keyword, "parser") #define load_preproc(keyword) get_module_data(keyword, "preproc") +/* Lists all available object formats. Calls printfunc with the name and + * keyword of each available format. + */ +void list_objfmts(void (*printfunc) (const char *name, const char *keyword)); + +/* Lists all available parsers. Calls printfunc with the name and keyword + * of each available parser. + */ +void list_parsers(void (*printfunc) (const char *name, const char *keyword)); + #endif diff --git a/src/objfmt.c b/src/objfmt.c deleted file mode 100644 index e6745c39..00000000 --- a/src/objfmt.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * YASM generic functions for all object formats - * - * Copyright (C) 2001 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "util.h" -/*@unused@*/ RCSID("$IdPath$"); - -#include "module.h" - -#include "objfmt.h" - - -/* NULL-terminated list of all possibly available object format keywords. - * Could improve this a little by generating automatically at build-time. - */ -/*@-nullassign@*/ -const char *objfmts[] = { - "dbg", - "bin", - "coff", - NULL -}; -/*@=nullassign@*/ - - -void -yasm_list_objfmts(void (*printfunc) (const char *name, const char *keyword)) -{ - int i; - yasm_objfmt *of; - - /* Go through available list, and try to load each one */ - for (i = 0; objfmts[i]; i++) { - of = load_objfmt(objfmts[i]); - if (of) - printfunc(of->name, of->keyword); - } -} diff --git a/src/objfmt.h b/src/objfmt.h index af940311..aa691c64 100644 --- a/src/objfmt.h +++ b/src/objfmt.h @@ -123,13 +123,4 @@ struct yasm_objfmt { void (*bc_objfmt_data_print)(FILE *f, int indent_level, unsigned int type, const void *data); }; - -/* Generic functions for all object formats - implemented in src/objfmt.c */ - -/* Lists all available object formats. Calls printfunc with the name and - * keyword of each available format. - */ -void yasm_list_objfmts(void (*printfunc) (const char *name, - const char *keyword)); - #endif diff --git a/src/parser.c b/src/parser.c deleted file mode 100644 index 7e8d7b3b..00000000 --- a/src/parser.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * YASM generic functions for all parsers - * - * Copyright (C) 2001 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "util.h" -/*@unused@*/ RCSID("$IdPath$"); - -#include "module.h" - -#include "parser.h" - - -/* NULL-terminated list of all possibly available parser keywords. - * Could improve this a little by generating automatically at build-time. - */ -/*@-nullassign@*/ -const char *parsers[] = { - "nasm", - NULL -}; -/*@=nullassign@*/ - - -void -yasm_list_parsers(void (*printfunc) (const char *name, const char *keyword)) -{ - int i; - yasm_parser *p; - - /* Go through available list, and try to load each one */ - for (i = 0; parsers[i]; i++) { - p = load_parser(parsers[i]); - if (p) - printfunc(p->name, p->keyword); - } -} diff --git a/src/parser.h b/src/parser.h index fe86b630..24cbcd94 100644 --- a/src/parser.h +++ b/src/parser.h @@ -62,13 +62,4 @@ struct yasm_parser { (yasm_preproc *pp, yasm_arch *a, yasm_objfmt *of, yasm_linemgr *lm, yasm_errwarn *we, FILE *f, const char *in_filename, int save_input); }; - -/* Generic functions for all parsers - implemented in src/parser.c */ - -/* Lists all available parsers. Calls printfunc with the name and keyword - * of each available parser. - */ -void yasm_list_parsers(void (*printfunc) (const char *name, - const char *keyword)); - #endif