From: Michael Tremer Date: Thu, 1 Jul 2021 11:54:28 +0000 (+0000) Subject: parser: Make the parser private X-Git-Tag: 0.9.28~1137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=638abead063c7889d32c30fa30979bd7619f092c;p=pakfire.git parser: Make the parser private Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/parser.h b/src/libpakfire/include/pakfire/parser.h index 00fa74750..d33616659 100644 --- a/src/libpakfire/include/pakfire/parser.h +++ b/src/libpakfire/include/pakfire/parser.h @@ -21,6 +21,9 @@ #ifndef PAKFIRE_PARSER_H #define PAKFIRE_PARSER_H +#ifdef PAKFIRE_PRIVATE + +#include #include struct pakfire_parser; @@ -81,10 +84,6 @@ const char* pakfire_parser_error_get_filename(struct pakfire_parser_error* error int pakfire_parser_error_get_line(struct pakfire_parser_error* error); const char* pakfire_parser_error_get_message(struct pakfire_parser_error* error); -#ifdef PAKFIRE_PRIVATE - -#include - Pakfire pakfire_parser_get_pakfire(struct pakfire_parser* parser); struct pakfire_parser_declaration { diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index b665c776f..39ec9f29c 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -209,35 +209,6 @@ global: pakfire_packagelist_sort; pakfire_packagelist_unref; - # parser - pakfire_parser_append; - pakfire_parser_create; - pakfire_parser_create_child; - pakfire_parser_create_package; - pakfire_parser_dump; - pakfire_parser_expand; - pakfire_parser_get; - pakfire_parser_get_namespace; - pakfire_parser_get_parent; - pakfire_parser_get_split; - pakfire_parser_list_namespaces; - pakfire_parser_merge; - pakfire_parser_parse; - pakfire_parser_read; - pakfire_parser_read_file; - pakfire_parser_ref; - pakfire_parser_set; - pakfire_parser_set_namespace; - pakfire_parser_unref; - - # parser error - pakfire_parser_error_create; - pakfire_parser_error_get_filename; - pakfire_parser_error_get_line; - pakfire_parser_error_get_message; - pakfire_parser_error_ref; - pakfire_parser_error_unref; - # problem pakfire_problem_get_solutions; pakfire_problem_ref; diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index d261070df..15ab37491 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -35,7 +35,6 @@ #include #include #include -#include #include struct pakfire_parser { @@ -104,7 +103,7 @@ static int pakfire_parser_compile_regexes(struct pakfire_parser* parser) { return 0; } -PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_create(Pakfire pakfire, +struct pakfire_parser* pakfire_parser_create(Pakfire pakfire, struct pakfire_parser* parent, const char* namespace, int flags) { struct pakfire_parser* parser = calloc(1, sizeof(*parser)); if (parser) { @@ -125,11 +124,11 @@ PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_create(Pakfire pakfire, return parser; } -PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_create_child(struct pakfire_parser* parser, const char* namespace) { +struct pakfire_parser* pakfire_parser_create_child(struct pakfire_parser* parser, const char* namespace) { return pakfire_parser_create(parser->pakfire, parser, namespace, parser->flags); } -PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_ref(struct pakfire_parser* parser) { +struct pakfire_parser* pakfire_parser_ref(struct pakfire_parser* parser) { ++parser->nrefs; return parser; @@ -172,7 +171,7 @@ static void pakfire_parser_free(struct pakfire_parser* parser) { free(parser); } -PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser* parser) { +struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser* parser) { if (--parser->nrefs > 0) return parser; @@ -180,7 +179,7 @@ PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser return NULL; } -PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_get_parent(struct pakfire_parser* parser) { +struct pakfire_parser* pakfire_parser_get_parent(struct pakfire_parser* parser) { if (parser->parent) return pakfire_parser_ref(parser->parent); @@ -270,7 +269,7 @@ static struct pakfire_parser_declaration* pakfire_parser_find_declaration( return NULL; } -PAKFIRE_EXPORT int pakfire_parser_set(struct pakfire_parser* parser, +int pakfire_parser_set(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value, int flags) { if (!name) return -EINVAL; @@ -383,7 +382,7 @@ static const char* pakfire_parser_get_raw(struct pakfire_parser* parser, const c return NULL; } -PAKFIRE_EXPORT int pakfire_parser_append(struct pakfire_parser* parser, +int pakfire_parser_append(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value) { char* buffer = NULL; @@ -598,7 +597,7 @@ ERROR: return r; } -PAKFIRE_EXPORT char* pakfire_parser_expand(struct pakfire_parser* parser, +char* pakfire_parser_expand(struct pakfire_parser* parser, const char* namespace, const char* value) { // Return NULL when the value is NULL if (!value) @@ -638,7 +637,7 @@ ERROR: return NULL; } -PAKFIRE_EXPORT char* pakfire_parser_get(struct pakfire_parser* parser, const char* namespace, const char* name) { +char* pakfire_parser_get(struct pakfire_parser* parser, const char* namespace, const char* name) { const char* value = pakfire_parser_get_raw(parser, namespace, name); // Return NULL when nothing was found @@ -649,7 +648,7 @@ PAKFIRE_EXPORT char* pakfire_parser_get(struct pakfire_parser* parser, const cha return pakfire_parser_expand(parser, namespace, value); } -PAKFIRE_EXPORT char** pakfire_parser_get_split(struct pakfire_parser* parser, +char** pakfire_parser_get_split(struct pakfire_parser* parser, const char* namespace, const char* name, char delim) { char* value = pakfire_parser_get(parser, namespace, name); if (!value) @@ -662,7 +661,7 @@ PAKFIRE_EXPORT char** pakfire_parser_get_split(struct pakfire_parser* parser, return list; } -PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, +char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, const char* filter) { char** namespaces = NULL; unsigned int counter = 0; @@ -715,7 +714,7 @@ PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(struct pakfire_parser* pars return namespaces; } -PAKFIRE_EXPORT int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser* parser2) { +int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser* parser2) { DEBUG(parser1->pakfire, "Merging parsers %p and %p\n", parser1, parser2); char namespace[NAME_MAX*2+1]; @@ -750,7 +749,7 @@ PAKFIRE_EXPORT int pakfire_parser_merge(struct pakfire_parser* parser1, struct p return 0; } -PAKFIRE_EXPORT int pakfire_parser_read(struct pakfire_parser* parser, FILE* f, +int pakfire_parser_read(struct pakfire_parser* parser, FILE* f, struct pakfire_parser_error** error) { char* data; size_t len; @@ -767,7 +766,7 @@ PAKFIRE_EXPORT int pakfire_parser_read(struct pakfire_parser* parser, FILE* f, return r; } -PAKFIRE_EXPORT int pakfire_parser_read_file(struct pakfire_parser* parser, const char* path, +int pakfire_parser_read_file(struct pakfire_parser* parser, const char* path, struct pakfire_parser_error** error) { FILE* f = fopen(path, "r"); if (!f) @@ -779,12 +778,12 @@ PAKFIRE_EXPORT int pakfire_parser_read_file(struct pakfire_parser* parser, const return r; } -PAKFIRE_EXPORT int pakfire_parser_parse(struct pakfire_parser* parser, +int pakfire_parser_parse(struct pakfire_parser* parser, const char* data, size_t size, struct pakfire_parser_error** error) { return pakfire_parser_parse_data(parser, data, size, error); } -PAKFIRE_EXPORT char* pakfire_parser_dump(struct pakfire_parser* parser) { +char* pakfire_parser_dump(struct pakfire_parser* parser) { char buffer[NAME_MAX*2 + 1]; char* s = NULL; @@ -804,11 +803,11 @@ PAKFIRE_EXPORT char* pakfire_parser_dump(struct pakfire_parser* parser) { return s; } -PAKFIRE_EXPORT const char* pakfire_parser_get_namespace(struct pakfire_parser* parser) { +const char* pakfire_parser_get_namespace(struct pakfire_parser* parser) { return parser->namespace; } -PAKFIRE_EXPORT int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace) { +int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace) { if (parser->namespace) free(parser->namespace); @@ -867,7 +866,7 @@ ERROR: return NULL; } -PAKFIRE_EXPORT int pakfire_parser_create_package(struct pakfire_parser* parser, +int pakfire_parser_create_package(struct pakfire_parser* parser, struct pakfire_package** pkg, struct pakfire_repo* repo, const char* namespace, const char* default_arch) { int r = 1; @@ -1048,7 +1047,7 @@ struct pakfire_parser_error { char* message; }; -PAKFIRE_EXPORT int pakfire_parser_error_create(struct pakfire_parser_error** error, +int pakfire_parser_error_create(struct pakfire_parser_error** error, struct pakfire_parser* parser, const char* filename, int line, const char* message) { struct pakfire_parser_error* e = calloc(1, sizeof(*e)); if (!e) @@ -1073,7 +1072,7 @@ PAKFIRE_EXPORT int pakfire_parser_error_create(struct pakfire_parser_error** err return 0; } -PAKFIRE_EXPORT struct pakfire_parser_error* pakfire_parser_error_ref( +struct pakfire_parser_error* pakfire_parser_error_ref( struct pakfire_parser_error* error) { ++error->nrefs; @@ -1092,7 +1091,7 @@ static void pakfire_parser_error_free(struct pakfire_parser_error* error) { free(error); } -PAKFIRE_EXPORT struct pakfire_parser_error* pakfire_parser_error_unref( +struct pakfire_parser_error* pakfire_parser_error_unref( struct pakfire_parser_error* error) { if (--error->nrefs > 0) return error; @@ -1102,16 +1101,16 @@ PAKFIRE_EXPORT struct pakfire_parser_error* pakfire_parser_error_unref( return NULL; } -PAKFIRE_EXPORT const char* pakfire_parser_error_get_filename( +const char* pakfire_parser_error_get_filename( struct pakfire_parser_error* error) { return error->filename; } -PAKFIRE_EXPORT int pakfire_parser_error_get_line(struct pakfire_parser_error* error) { +int pakfire_parser_error_get_line(struct pakfire_parser_error* error) { return error->line; } -PAKFIRE_EXPORT const char* pakfire_parser_error_get_message( +const char* pakfire_parser_error_get_message( struct pakfire_parser_error* error) { return error->message; }