From: Michael Tremer Date: Thu, 1 Jul 2021 11:46:28 +0000 (+0000) Subject: parser: Change type from PakfireParser to struct pakfire_parser X-Git-Tag: 0.9.28~1139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=657a5c7264ca9cf8c7992b7f18d2d421b79dd041;p=pakfire.git parser: Change type from PakfireParser to struct pakfire_parser Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/parser.c b/src/_pakfire/parser.c index e391f8e28..234f424d9 100644 --- a/src/_pakfire/parser.c +++ b/src/_pakfire/parser.c @@ -25,7 +25,7 @@ #include "pakfire.h" #include "parser.h" -static ParserObject* Parser_new_core(PyTypeObject* type, PakfireParser parser) { +static ParserObject* Parser_new_core(PyTypeObject* type, struct pakfire_parser* parser) { ParserObject* self = (ParserObject *)type->tp_alloc(type, 0); if (self) { self->parser = pakfire_parser_ref(parser); @@ -34,7 +34,7 @@ static ParserObject* Parser_new_core(PyTypeObject* type, PakfireParser parser) { return self; } -PyObject* new_parser(PakfireParser parser) { +PyObject* new_parser(struct pakfire_parser* parser) { ParserObject* p = Parser_new_core(&ParserType, parser); return (PyObject*)p; diff --git a/src/_pakfire/parser.h b/src/_pakfire/parser.h index 3636d12fd..e664bc4be 100644 --- a/src/_pakfire/parser.h +++ b/src/_pakfire/parser.h @@ -27,11 +27,11 @@ typedef struct { PyObject_HEAD - PakfireParser parser; + struct pakfire_parser* parser; } ParserObject; extern PyTypeObject ParserType; -PyObject* new_parser(PakfireParser parser); +PyObject* new_parser(struct pakfire_parser* parser); #endif /* PYTHON_PAKFIRE_PARSER_H */ diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index b4176725b..cf61f932f 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -70,7 +70,7 @@ struct _PakfireArchive { // metadata unsigned int format; - PakfireParser parser; + struct pakfire_parser* parser; PakfireFilelist filelist; diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 192f4ba12..d886dc8f4 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -348,7 +348,7 @@ static int append_to_array(const char*** array, const char* s) { return 0; } -static int pakfire_build_package_add_files(Pakfire pakfire, PakfireParser makefile, +static int pakfire_build_package_add_files(Pakfire pakfire, struct pakfire_parser* makefile, const char* buildroot, const char* namespace, struct pakfire_package* pkg, struct pakfire_packager* packager) { PakfireFilelist filelist = NULL; @@ -550,7 +550,7 @@ ERROR: return r; } -static int pakfire_build_package_add_scriptlets(Pakfire pakfire, PakfireParser makefile, +static int pakfire_build_package_add_scriptlets(Pakfire pakfire, struct pakfire_parser* makefile, const char* namespace, struct pakfire_package* pkg, struct pakfire_packager* packager) { char name[NAME_MAX]; int r; @@ -578,7 +578,7 @@ static int pakfire_build_package_add_scriptlets(Pakfire pakfire, PakfireParser m return 0; } -static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, +static int pakfire_build_package(Pakfire pakfire, struct pakfire_parser* makefile, const char* id, const char* buildroot, const char* namespace, const char* target) { struct pakfire_repo* repo = NULL; struct pakfire_package* pkg = NULL; @@ -663,7 +663,7 @@ ERROR: return r; } -static int pakfire_build_packages(Pakfire pakfire, PakfireParser makefile, +static int pakfire_build_packages(Pakfire pakfire, struct pakfire_parser* makefile, const char* id, const char* buildroot, const char* target) { DEBUG(pakfire, "Creating packages..."); int r = 1; @@ -700,7 +700,7 @@ ERROR: return r; } -static int pakfire_build_stage(Pakfire pakfire, PakfireParser makefile, const char* stage, +static int pakfire_build_stage(Pakfire pakfire, struct pakfire_parser* makefile, const char* stage, pakfire_execute_logging_callback logging_callback, void* data) { char template[1024]; @@ -774,7 +774,7 @@ static int pakfire_build_run_post_build_scripts(Pakfire pakfire, const char* bui static int pakfire_build_makefile(Pakfire pakfire, const char* path, const char* target, const char* id, int flags, pakfire_execute_logging_callback logging_callback, void* data) { - PakfireParser makefile = NULL; + struct pakfire_parser* makefile = NULL; char buildroot[PATH_MAX]; struct pakfire_parser_error* error = NULL; int r = 1; diff --git a/src/libpakfire/dist.c b/src/libpakfire/dist.c index 8948ce2b7..3459cd13d 100644 --- a/src/libpakfire/dist.c +++ b/src/libpakfire/dist.c @@ -45,7 +45,7 @@ #define PAKFIRE_MACROS_GLOB_PATTERN PAKFIRE_MACROS_DIR "/*.macro" static int pakfire_makefile_set_defaults(Pakfire pakfire, - PakfireParser parser, const char* path) { + struct pakfire_parser* parser, const char* path) { char buffer[1024]; int r; @@ -125,7 +125,7 @@ static int pakfire_makefile_set_defaults(Pakfire pakfire, return 0; } -int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, +int pakfire_read_makefile(struct pakfire_parser** parser, Pakfire pakfire, const char* path, struct pakfire_parser_error** error) { int r = 1; @@ -196,7 +196,7 @@ ERROR: } static int pakfire_dist_create_downloader_and_mirrorlist( - Pakfire pakfire, PakfireParser makefile, + Pakfire pakfire, struct pakfire_parser* makefile, struct pakfire_downloader** downloader, struct pakfire_mirrorlist** mirrorlist) { // Create the downloader int r = pakfire_downloader_create(downloader, pakfire); @@ -264,7 +264,7 @@ static int pakfire_dist_add_source(Pakfire pakfire, struct pakfire_packager* pac } static int pakfire_dist_add_sources(Pakfire pakfire, struct pakfire_packager* packager, - struct pakfire_package* pkg, PakfireParser makefile) { + struct pakfire_package* pkg, struct pakfire_parser* makefile) { // Fetch sources char** sources = pakfire_parser_get_split(makefile, NULL, "sources", ' '); @@ -367,7 +367,7 @@ ERROR: } PAKFIRE_EXPORT int pakfire_dist(Pakfire pakfire, const char* path, const char* target) { - PakfireParser makefile; + struct pakfire_parser* makefile; struct pakfire_parser_error* error = NULL; struct pakfire_packager* packager = NULL; diff --git a/src/libpakfire/include/pakfire/dist.h b/src/libpakfire/include/pakfire/dist.h index 431659cc1..db8fdc245 100644 --- a/src/libpakfire/include/pakfire/dist.h +++ b/src/libpakfire/include/pakfire/dist.h @@ -29,7 +29,7 @@ int pakfire_dist(Pakfire pakfire, const char* path, const char* target); #include -int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, +int pakfire_read_makefile(struct pakfire_parser** parser, Pakfire pakfire, const char* path, struct pakfire_parser_error** error); #endif diff --git a/src/libpakfire/include/pakfire/parser.h b/src/libpakfire/include/pakfire/parser.h index dd92d1750..00fa74750 100644 --- a/src/libpakfire/include/pakfire/parser.h +++ b/src/libpakfire/include/pakfire/parser.h @@ -23,7 +23,10 @@ #include +struct pakfire_parser; + #include +#include #include #include @@ -34,43 +37,43 @@ enum pakfire_parser_flags { struct pakfire_parser_error; -PakfireParser pakfire_parser_create(Pakfire pakfire, PakfireParser parser, +struct pakfire_parser* pakfire_parser_create(Pakfire pakfire, struct pakfire_parser* parser, const char* namespace, int flags); -PakfireParser pakfire_parser_create_child(PakfireParser parser, +struct pakfire_parser* pakfire_parser_create_child(struct pakfire_parser* parser, const char* namespace); -PakfireParser pakfire_parser_ref(PakfireParser parser); -PakfireParser pakfire_parser_unref(PakfireParser parser); -PakfireParser pakfire_parser_get_parent(PakfireParser parser); +struct pakfire_parser* pakfire_parser_ref(struct pakfire_parser* parser); +struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser* parser); +struct pakfire_parser* pakfire_parser_get_parent(struct pakfire_parser* parser); -int pakfire_parser_set(PakfireParser parser, +int pakfire_parser_set(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value, int flags); -int pakfire_parser_append(PakfireParser parser, +int pakfire_parser_append(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value); -char* pakfire_parser_expand(PakfireParser parser, const char* namespace, const char* value); -char* pakfire_parser_get(PakfireParser parser, const char* namespace, const char* name); -char** pakfire_parser_get_split(PakfireParser parser, +char* pakfire_parser_expand(struct pakfire_parser* parser, const char* namespace, const char* value); +char* pakfire_parser_get(struct pakfire_parser* parser, const char* namespace, const char* name); +char** pakfire_parser_get_split(struct pakfire_parser* parser, const char* namespace, const char* name, char delim); -char** pakfire_parser_list_namespaces(PakfireParser parser, const char* filter); +char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, const char* filter); -int pakfire_parser_merge(PakfireParser parser1, PakfireParser parser2); +int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser* parser2); -int pakfire_parser_read(PakfireParser parser, FILE* f, struct pakfire_parser_error** error); -int pakfire_parser_read_file(PakfireParser parser, const char* path, +int pakfire_parser_read(struct pakfire_parser* parser, FILE* f, struct pakfire_parser_error** error); +int pakfire_parser_read_file(struct pakfire_parser* parser, const char* path, struct pakfire_parser_error** error); -int pakfire_parser_parse(PakfireParser parser, const char* data, size_t size, +int pakfire_parser_parse(struct pakfire_parser* parser, const char* data, size_t size, struct pakfire_parser_error** error); -char* pakfire_parser_dump(PakfireParser parser); +char* pakfire_parser_dump(struct pakfire_parser* parser); -const char* pakfire_parser_get_namespace(PakfireParser parser); -int pakfire_parser_set_namespace(PakfireParser parser, const char* namespace); +const char* pakfire_parser_get_namespace(struct pakfire_parser* parser); +int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace); -int pakfire_parser_create_package(PakfireParser 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); // Errors int pakfire_parser_error_create(struct pakfire_parser_error** error, - PakfireParser parser, const char* filename, int line, const char* message); + struct pakfire_parser* parser, const char* filename, int line, const char* message); struct pakfire_parser_error* pakfire_parser_error_ref(struct pakfire_parser_error* error); struct pakfire_parser_error* pakfire_parser_error_unref(struct pakfire_parser_error* error); @@ -82,7 +85,7 @@ const char* pakfire_parser_error_get_message(struct pakfire_parser_error* error) #include -Pakfire pakfire_parser_get_pakfire(PakfireParser parser); +Pakfire pakfire_parser_get_pakfire(struct pakfire_parser* parser); struct pakfire_parser_declaration { char namespace[NAME_MAX]; @@ -96,12 +99,12 @@ struct pakfire_parser_declaration { }; int pakfire_parser_apply_declaration( - PakfireParser parser, struct pakfire_parser_declaration* declaration); + struct pakfire_parser* parser, struct pakfire_parser_declaration* declaration); -int pakfire_parser_parse_data(PakfireParser parent, const char* data, size_t len, +int pakfire_parser_parse_data(struct pakfire_parser* parent, const char* data, size_t len, struct pakfire_parser_error** error); -char** pakfire_parser_make_environ(PakfireParser parser); +char** pakfire_parser_make_environ(struct pakfire_parser* parser); #endif /* PAKFIRE_PRIVATE */ diff --git a/src/libpakfire/include/pakfire/types.h b/src/libpakfire/include/pakfire/types.h index 599a00e98..28b07102e 100644 --- a/src/libpakfire/include/pakfire/types.h +++ b/src/libpakfire/include/pakfire/types.h @@ -26,7 +26,6 @@ typedef struct _PakfireArchive* PakfireArchive; typedef struct _PakfireArchiveSignature* PakfireArchiveSignature; typedef struct _PakfireFilelist* PakfireFilelist; typedef struct _PakfireKey* PakfireKey; -typedef struct _PakfireParser* PakfireParser; typedef struct _PakfireSolution* PakfireSolution; #endif /* PAKFIRE_TYPES_H */ diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 7d1020b7e..d261070df 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -38,11 +38,11 @@ #include #include -struct _PakfireParser { +struct pakfire_parser { Pakfire pakfire; - struct _PakfireParser* parent; int nrefs; + struct pakfire_parser* parent; int flags; char* namespace; @@ -54,7 +54,7 @@ struct _PakfireParser { pcre2_code* regex_variable; }; -static int pakfire_parser_compile_regex(PakfireParser parser, pcre2_code** regex, +static int pakfire_parser_compile_regex(struct pakfire_parser* parser, pcre2_code** regex, const char* pattern) { int pcre2_errno; size_t pcre2_offset; @@ -82,7 +82,7 @@ static int pakfire_parser_compile_regex(PakfireParser parser, pcre2_code** regex return 0; } -static int pakfire_parser_compile_regexes(PakfireParser parser) { +static int pakfire_parser_compile_regexes(struct pakfire_parser* parser) { int r; // Commands @@ -104,9 +104,9 @@ static int pakfire_parser_compile_regexes(PakfireParser parser) { return 0; } -PAKFIRE_EXPORT PakfireParser pakfire_parser_create(Pakfire pakfire, - PakfireParser parent, const char* namespace, int flags) { - PakfireParser parser = calloc(1, sizeof(*parser)); +PAKFIRE_EXPORT 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) { parser->pakfire = pakfire_ref(pakfire); parser->nrefs = 1; @@ -125,21 +125,21 @@ PAKFIRE_EXPORT PakfireParser pakfire_parser_create(Pakfire pakfire, return parser; } -PAKFIRE_EXPORT PakfireParser pakfire_parser_create_child(PakfireParser parser, const char* namespace) { +PAKFIRE_EXPORT 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 PakfireParser pakfire_parser_ref(PakfireParser parser) { +PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_ref(struct pakfire_parser* parser) { ++parser->nrefs; return parser; } -Pakfire pakfire_parser_get_pakfire(PakfireParser parser) { +Pakfire pakfire_parser_get_pakfire(struct pakfire_parser* parser) { return pakfire_ref(parser->pakfire); } -static void pakfire_parser_free_declarations(PakfireParser parser) { +static void pakfire_parser_free_declarations(struct pakfire_parser* parser) { if (!parser->declarations) return; @@ -155,7 +155,7 @@ static void pakfire_parser_free_declarations(PakfireParser parser) { free(parser->declarations); } -static void pakfire_parser_free(PakfireParser parser) { +static void pakfire_parser_free(struct pakfire_parser* parser) { // Release regular expressions if (parser->regex_variable) pcre2_code_free(parser->regex_variable); @@ -172,7 +172,7 @@ static void pakfire_parser_free(PakfireParser parser) { free(parser); } -PAKFIRE_EXPORT PakfireParser pakfire_parser_unref(PakfireParser parser) { +PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser* parser) { if (--parser->nrefs > 0) return parser; @@ -180,7 +180,7 @@ PAKFIRE_EXPORT PakfireParser pakfire_parser_unref(PakfireParser parser) { return NULL; } -PAKFIRE_EXPORT PakfireParser pakfire_parser_get_parent(PakfireParser parser) { +PAKFIRE_EXPORT struct pakfire_parser* pakfire_parser_get_parent(struct pakfire_parser* parser) { if (parser->parent) return pakfire_parser_ref(parser->parent); @@ -188,7 +188,7 @@ PAKFIRE_EXPORT PakfireParser pakfire_parser_get_parent(PakfireParser parser) { } static struct pakfire_parser_declaration* pakfire_parser_get_declaration( - PakfireParser parser, const char* namespace, const char* name) { + struct pakfire_parser* parser, const char* namespace, const char* name) { if (!name) { errno = EINVAL; return NULL; @@ -222,7 +222,7 @@ static struct pakfire_parser_declaration* pakfire_parser_get_declaration( } static struct pakfire_parser_declaration* pakfire_parser_get_declaration_recursive( - PakfireParser parser, const char* namespace, const char* name) { + struct pakfire_parser* parser, const char* namespace, const char* name) { struct pakfire_parser_declaration* d = pakfire_parser_get_declaration( parser, namespace, name); if (d) @@ -245,7 +245,7 @@ static void pakfire_parser_strip_namespace(char** s) { } static struct pakfire_parser_declaration* pakfire_parser_find_declaration( - PakfireParser parser, const char* namespace, const char* name) { + struct pakfire_parser* parser, const char* namespace, const char* name) { struct pakfire_parser_declaration* d; char* n = NULL; @@ -270,7 +270,7 @@ static struct pakfire_parser_declaration* pakfire_parser_find_declaration( return NULL; } -PAKFIRE_EXPORT int pakfire_parser_set(PakfireParser parser, +PAKFIRE_EXPORT int pakfire_parser_set(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value, int flags) { if (!name) return -EINVAL; @@ -328,7 +328,7 @@ PAKFIRE_EXPORT int pakfire_parser_set(PakfireParser parser, return 0; } -int pakfire_parser_apply_declaration(PakfireParser parser, +int pakfire_parser_apply_declaration(struct pakfire_parser* parser, struct pakfire_parser_declaration* declaration) { if (declaration->flags & PAKFIRE_PARSER_DECLARATION_APPEND) return pakfire_parser_append(parser, declaration->namespace, declaration->name, declaration->value); @@ -337,7 +337,7 @@ int pakfire_parser_apply_declaration(PakfireParser parser, declaration->name, declaration->value, declaration->flags); } -static const char* pakfire_parser_find_template(PakfireParser parser, +static const char* pakfire_parser_find_template(struct pakfire_parser* parser, char* template, size_t size, const char* namespace) { DEBUG(parser->pakfire, "Looking up template in namespace '%s'\n", namespace); @@ -351,7 +351,7 @@ static const char* pakfire_parser_find_template(PakfireParser parser, return template; } -static const char* pakfire_parser_get_raw(PakfireParser parser, const char* namespace, const char* name) { +static const char* pakfire_parser_get_raw(struct pakfire_parser* parser, const char* namespace, const char* name) { struct pakfire_parser_declaration* d = NULL; // First, perform a simple lookup @@ -383,7 +383,7 @@ static const char* pakfire_parser_get_raw(PakfireParser parser, const char* name return NULL; } -PAKFIRE_EXPORT int pakfire_parser_append(PakfireParser parser, +PAKFIRE_EXPORT int pakfire_parser_append(struct pakfire_parser* parser, const char* namespace, const char* name, const char* value) { char* buffer = NULL; @@ -409,7 +409,7 @@ PAKFIRE_EXPORT int pakfire_parser_append(PakfireParser parser, return r; } -static int pakfire_parser_expand_commands(PakfireParser parser, char** buffer) { +static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char** buffer) { int r = 0; PCRE2_UCHAR* command = NULL; PCRE2_SIZE command_length; @@ -507,7 +507,7 @@ ERROR: return r; } -static int pakfire_parser_expand_variables(PakfireParser parser, +static int pakfire_parser_expand_variables(struct pakfire_parser* parser, const char* namespace, char** buffer) { int r = 0; PCRE2_UCHAR* variable = NULL; @@ -598,7 +598,7 @@ ERROR: return r; } -PAKFIRE_EXPORT char* pakfire_parser_expand(PakfireParser parser, +PAKFIRE_EXPORT 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 +638,7 @@ ERROR: return NULL; } -PAKFIRE_EXPORT char* pakfire_parser_get(PakfireParser parser, const char* namespace, const char* name) { +PAKFIRE_EXPORT 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 +649,7 @@ PAKFIRE_EXPORT char* pakfire_parser_get(PakfireParser parser, const char* namesp return pakfire_parser_expand(parser, namespace, value); } -PAKFIRE_EXPORT char** pakfire_parser_get_split(PakfireParser parser, +PAKFIRE_EXPORT 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 +662,7 @@ PAKFIRE_EXPORT char** pakfire_parser_get_split(PakfireParser parser, return list; } -PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(PakfireParser parser, +PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, const char* filter) { char** namespaces = NULL; unsigned int counter = 0; @@ -715,7 +715,7 @@ PAKFIRE_EXPORT char** pakfire_parser_list_namespaces(PakfireParser parser, return namespaces; } -PAKFIRE_EXPORT int pakfire_parser_merge(PakfireParser parser1, PakfireParser parser2) { +PAKFIRE_EXPORT 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 +750,7 @@ PAKFIRE_EXPORT int pakfire_parser_merge(PakfireParser parser1, PakfireParser par return 0; } -PAKFIRE_EXPORT int pakfire_parser_read(PakfireParser parser, FILE* f, +PAKFIRE_EXPORT int pakfire_parser_read(struct pakfire_parser* parser, FILE* f, struct pakfire_parser_error** error) { char* data; size_t len; @@ -767,7 +767,7 @@ PAKFIRE_EXPORT int pakfire_parser_read(PakfireParser parser, FILE* f, return r; } -PAKFIRE_EXPORT int pakfire_parser_read_file(PakfireParser parser, const char* path, +PAKFIRE_EXPORT 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 +779,12 @@ PAKFIRE_EXPORT int pakfire_parser_read_file(PakfireParser parser, const char* pa return r; } -PAKFIRE_EXPORT int pakfire_parser_parse(PakfireParser parser, +PAKFIRE_EXPORT 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(PakfireParser parser) { +PAKFIRE_EXPORT char* pakfire_parser_dump(struct pakfire_parser* parser) { char buffer[NAME_MAX*2 + 1]; char* s = NULL; @@ -804,11 +804,11 @@ PAKFIRE_EXPORT char* pakfire_parser_dump(PakfireParser parser) { return s; } -PAKFIRE_EXPORT const char* pakfire_parser_get_namespace(PakfireParser parser) { +PAKFIRE_EXPORT const char* pakfire_parser_get_namespace(struct pakfire_parser* parser) { return parser->namespace; } -PAKFIRE_EXPORT int pakfire_parser_set_namespace(PakfireParser parser, const char* namespace) { +PAKFIRE_EXPORT int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace) { if (parser->namespace) free(parser->namespace); @@ -822,7 +822,7 @@ PAKFIRE_EXPORT int pakfire_parser_set_namespace(PakfireParser parser, const char return 0; } -char** pakfire_parser_make_environ(PakfireParser parser) { +char** pakfire_parser_make_environ(struct pakfire_parser* parser) { char** envp = NULL; unsigned int num = 0; @@ -867,7 +867,7 @@ ERROR: return NULL; } -PAKFIRE_EXPORT int pakfire_parser_create_package(PakfireParser parser, +PAKFIRE_EXPORT 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; @@ -1040,7 +1040,7 @@ CLEANUP: // Error struct pakfire_parser_error { - PakfireParser parser; + struct pakfire_parser* parser; int nrefs; char* filename; @@ -1049,7 +1049,7 @@ struct pakfire_parser_error { }; PAKFIRE_EXPORT int pakfire_parser_error_create(struct pakfire_parser_error** error, - PakfireParser parser, const char* filename, int line, const char* message) { + struct pakfire_parser* parser, const char* filename, int line, const char* message) { struct pakfire_parser_error* e = calloc(1, sizeof(*e)); if (!e) return ENOMEM; diff --git a/src/libpakfire/parser/grammar.y b/src/libpakfire/parser/grammar.y index bb83b9445..f8801da0d 100644 --- a/src/libpakfire/parser/grammar.y +++ b/src/libpakfire/parser/grammar.y @@ -23,8 +23,8 @@ %parse-param {yyscan_t* scanner} {Pakfire pakfire} - {PakfireParser* parser} - {PakfireParser parent} + {struct pakfire_parser** parser} + {struct pakfire_parser* parent} {struct pakfire_parser_error** error} // Make the parser reentrant @@ -74,8 +74,8 @@ enum operator { OP_EQUALS = 0, }; -static void yyerror(yyscan_t* scanner, Pakfire pakfire, PakfireParser* parser, - PakfireParser parent, struct pakfire_parser_error** error, const char* s) { +static void yyerror(yyscan_t* scanner, Pakfire pakfire, struct pakfire_parser** parser, + struct pakfire_parser* parent, struct pakfire_parser_error** error, const char* s) { ERROR(pakfire, "Error (line %d): %s\n", num_lines, s); // Create a new error object @@ -87,8 +87,8 @@ static void yyerror(yyscan_t* scanner, Pakfire pakfire, PakfireParser* parser, } } -static PakfireParser make_if_stmt(Pakfire pakfire, const enum operator op, - const char* val1, const char* val2, PakfireParser if_block, PakfireParser else_block); +static struct pakfire_parser* make_if_stmt(Pakfire pakfire, const enum operator op, + const char* val1, const char* val2, struct pakfire_parser* if_block, struct pakfire_parser* else_block); static int pakfire_parser_new_declaration( struct pakfire_parser_declaration** declaration, const char* name, const char* value, int flags) { @@ -159,7 +159,7 @@ static void pakfire_parser_free_declaration(struct pakfire_parser_declaration* d %type line %union { - PakfireParser parser; + struct pakfire_parser* parser; char* string; struct pakfire_parser_declaration* declaration; } @@ -225,7 +225,7 @@ grammar : %empty block : T_INDENT grammar T_OUTDENT { // Reset the top parser - PakfireParser p = pakfire_parser_get_parent(*parser); + struct pakfire_parser* p = pakfire_parser_get_parent(*parser); pakfire_parser_unref(*parser); *parser = p; @@ -387,7 +387,7 @@ else_stmt : T_ELSE T_EOL block %% -int pakfire_parser_parse_data(PakfireParser parent, const char* data, size_t len, +int pakfire_parser_parse_data(struct pakfire_parser* parent, const char* data, size_t len, struct pakfire_parser_error** error) { Pakfire pakfire = pakfire_parser_get_pakfire(parent); yyscan_t scanner; @@ -404,7 +404,7 @@ int pakfire_parser_parse_data(PakfireParser parent, const char* data, size_t len yylex_init(&scanner); // Create a new sub-parser - PakfireParser parser = NULL; + struct pakfire_parser* parser = NULL; num_lines = 1; @@ -446,15 +446,15 @@ int pakfire_parser_parse_data(PakfireParser parent, const char* data, size_t len return r; } -static PakfireParser make_if_stmt(Pakfire pakfire, const enum operator op, - const char* val1, const char* val2, PakfireParser if_block, PakfireParser else_block) { +static struct pakfire_parser* make_if_stmt(Pakfire pakfire, const enum operator op, + const char* val1, const char* val2, struct pakfire_parser* if_block, struct pakfire_parser* else_block) { switch (op) { case OP_EQUALS: DEBUG(pakfire, "Evaluating if statement: %s == %s?\n", val1, val2); break; } - PakfireParser parent = pakfire_parser_get_parent(if_block); + struct pakfire_parser* parent = pakfire_parser_get_parent(if_block); DEBUG(pakfire, " parent = %p, if = %p, else = %p\n", parent, if_block, else_block); @@ -462,7 +462,7 @@ static PakfireParser make_if_stmt(Pakfire pakfire, const enum operator op, char* v1 = pakfire_parser_expand(parent, NULL, val1); char* v2 = pakfire_parser_expand(parent, NULL, val2); - PakfireParser result = NULL; + struct pakfire_parser* result = NULL; switch (op) { case OP_EQUALS: diff --git a/tests/libpakfire/makefile.c b/tests/libpakfire/makefile.c index d773cb844..8731caf83 100644 --- a/tests/libpakfire/makefile.c +++ b/tests/libpakfire/makefile.c @@ -36,7 +36,7 @@ static const char* makefiles[] = { NULL, }; -static int load_macros(PakfireParser parser) { +static int load_macros(struct pakfire_parser* parser) { const char* macros = TEST_SRC_PATH "../macros/*.macro"; glob_t buffer; @@ -63,7 +63,7 @@ static int test_parse(const struct test* t) { FILE* f = fopen(path, "r"); ASSERT(f); - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); r = pakfire_parser_read(parser, f, NULL); ASSERT(r == 0); @@ -79,7 +79,7 @@ static int test_parse(const struct test* t) { } static int test_macros(const struct test* t) { - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); ASSERT(parser); // Load 'em all @@ -98,7 +98,7 @@ static int test_packages(const struct test* t) { struct pakfire_repo* repo = pakfire_repo_create(t->pakfire, "test"); ASSERT(repo); - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS); ASSERT(parser); diff --git a/tests/libpakfire/parser.c b/tests/libpakfire/parser.c index 846bca8c7..f77c07931 100644 --- a/tests/libpakfire/parser.c +++ b/tests/libpakfire/parser.c @@ -31,7 +31,7 @@ static int test_parser(const struct test* t) { char* value = NULL; // Create a new parser - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); // Retrieve a value that does not exist value = pakfire_parser_get(parser, NULL, "null"); @@ -54,7 +54,7 @@ static int test_parser(const struct test* t) { ASSERT_STRING_EQUALS(value, "a b"); // Make a child parser - PakfireParser subparser = pakfire_parser_create_child(parser, "child"); + struct pakfire_parser* subparser = pakfire_parser_create_child(parser, "child"); ASSERT(subparser); // Try to get a again @@ -120,7 +120,7 @@ static int test_parser_files(const struct test* t) { ASSERT(r >= 0); // Create a new parser - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0); FILE* f = fopen(path, "r"); ASSERT(f); @@ -144,7 +144,7 @@ static int test_parser_files(const struct test* t) { static int test_parser_command(const struct test* t) { const char* command = "%(echo \"ABC\")"; - PakfireParser parser = pakfire_parser_create(t->pakfire, NULL, NULL, + struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS); ASSERT(parser);