]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Change type from PakfireParser to struct pakfire_parser
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Jul 2021 11:46:28 +0000 (11:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Jul 2021 11:46:28 +0000 (11:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
12 files changed:
src/_pakfire/parser.c
src/_pakfire/parser.h
src/libpakfire/archive.c
src/libpakfire/build.c
src/libpakfire/dist.c
src/libpakfire/include/pakfire/dist.h
src/libpakfire/include/pakfire/parser.h
src/libpakfire/include/pakfire/types.h
src/libpakfire/parser.c
src/libpakfire/parser/grammar.y
tests/libpakfire/makefile.c
tests/libpakfire/parser.c

index e391f8e28030cc17a17929f59b010ed80c2b3b00..234f424d9ce7624f270c920d4737964297bbb705 100644 (file)
@@ -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;
index 3636d12fdfe0cc62ee8ede916860d88add2c4727..e664bc4be36c416136dcb5621b8c2103e563e40c 100644 (file)
 
 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 */
index b4176725ba9649baf93a00487a74f4ed246bad00..cf61f932f2d3f7fd6475b67e8b8a83f67c2a8a3d 100644 (file)
@@ -70,7 +70,7 @@ struct _PakfireArchive {
 
        // metadata
        unsigned int format;
-       PakfireParser parser;
+       struct pakfire_parser* parser;
 
        PakfireFilelist filelist;
 
index 192f4ba12434e78b91df1dc89fac86f929ef065b..d886dc8f4455b3d3775e106b8edc3a44941b1264 100644 (file)
@@ -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;
index 8948ce2b7726a37619eafe04ffa0125c6629d354..3459cd13d4f5701c812f159245ebe296230ea0a4 100644 (file)
@@ -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;
index 431659cc15872b316e7b3f343ce2fcc24e927153..db8fdc24514a2a79ddd53d9747ac6c5ef20a9b64 100644 (file)
@@ -29,7 +29,7 @@ int pakfire_dist(Pakfire pakfire, const char* path, const char* target);
 
 #include <pakfire/parser.h>
 
-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
index dd92d1750f7e285e114f7b9c9084672ce2d2cc02..00fa7475062dc890d17f28c39e013c76e55b54a1 100644 (file)
 
 #include <stdio.h>
 
+struct pakfire_parser;
+
 #include <pakfire/package.h>
+#include <pakfire/parser.h>
 #include <pakfire/repo.h>
 #include <pakfire/types.h>
 
@@ -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 <linux/limits.h>
 
-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 */
 
index 599a00e9807c70ace64ea862da846ac27a971bfa..28b07102e4594325cfa145f3c3e1d7bac898b6e4 100644 (file)
@@ -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 */
index 7d1020b7efb66b679fc869d84572053178116a84..d261070dfbfedce6f1f84016ef20b7602743a478 100644 (file)
 #include <pakfire/private.h>
 #include <pakfire/util.h>
 
-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;
index bb83b9445bed57a219654f2c7e00650af993c875..f8801da0dcac8a0bbd4cb01bc700cc6e041c07bf 100644 (file)
@@ -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 <string>                         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:
index d773cb844cd2e05ee7bcbbcfd4f6ab45c756f891..8731caf83d61ca75e92851d6a849ea641123e067 100644 (file)
@@ -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);
 
index 846bca8c79e4d0624d603850e5ffcb6cf6d523c1..f77c07931446a8f409747d316143cce0df83d3c2 100644 (file)
@@ -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);