}
static int pakfire_build_find_dependencies(pakfire_build* build,
- struct pakfire_parser* makefile, const char* namespace,
+ pakfire_parser* makefile, const char* namespace,
pakfire_package* pkg, pakfire_filelist* filelist) {
char* filter_provides = NULL;
char* filter_requires = NULL;
}
static int pakfire_build_package_mark_config_files(pakfire_build* build,
- pakfire_filelist* filelist, struct pakfire_parser* makefile, const char* namespace) {
+ pakfire_filelist* filelist, pakfire_parser* makefile, const char* namespace) {
char** configfiles = NULL;
int r;
}
static int pakfire_build_package_add_files(pakfire_build* build,
- struct pakfire_parser* makefile, const char* buildroot, const char* namespace,
+ pakfire_parser* makefile, const char* buildroot, const char* namespace,
pakfire_package* pkg, pakfire_packager* packager) {
pakfire_filelist* filelist = NULL;
char** includes = NULL;
}
static int pakfire_build_package_add_scriptlets(pakfire_build* build,
- struct pakfire_parser* makefile, const char* namespace,
+ pakfire_parser* makefile, const char* namespace,
pakfire_package* pkg, pakfire_packager* packager) {
char name[NAME_MAX];
int r;
return 0;
}
-static int pakfire_build_package(pakfire_build* build, struct pakfire_parser* makefile,
+static int pakfire_build_package(pakfire_build* build, pakfire_parser* makefile,
const char* buildroot, const char* namespace) {
pakfire_archive* archive = NULL;
pakfire_package* pkg = NULL;
}
static int pakfire_build_packages(pakfire_build* build,
- struct pakfire_parser* makefile) {
+ pakfire_parser* makefile) {
INFO(build->ctx, "Creating packages...");
int r = 1;
}
static int pakfire_build_stage(pakfire_build* build,
- struct pakfire_parser* makefile, const char* stage) {
+ pakfire_parser* makefile, const char* stage) {
pakfire_env* env = NULL;
char* script = NULL;
char template[1024];
}
static int pakfire_build_read_makefile(pakfire_build* build,
- struct pakfire_parser** parser, pakfire_package* package) {
+ pakfire_parser** parser, pakfire_package* package) {
char path[PATH_MAX];
int r;
- struct pakfire_parser_error* error = NULL;
+ pakfire_parser_error* error = NULL;
const char* nevra = pakfire_package_get_string(package, PAKFIRE_PKG_NEVRA);
const char* name = pakfire_package_get_string(package, PAKFIRE_PKG_NAME);
}
static int pakfire_build_perform(pakfire_build* build,
- struct pakfire_parser* makefile) {
+ pakfire_parser* makefile) {
int r;
// Prepare the build
int pakfire_build_exec(pakfire_build* build, const char* path,
pakfire_build_result_callback result_callback, void* data) {
pakfire_package* package = NULL;
- struct pakfire_parser* makefile = NULL;
+ pakfire_parser* makefile = NULL;
char* problems = NULL;
char duration[TIME_STRING_MAX];
int r;
};
static int pakfire_makefile_set_defaults(struct pakfire* pakfire,
- struct pakfire_parser* parser, const char* path) {
+ pakfire_parser* parser, const char* path) {
char dirname[PATH_MAX];
char buffer[1024];
int r;
return 0;
}
-int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfire,
- const char* path, struct pakfire_parser_error** error) {
+int pakfire_read_makefile(pakfire_parser** parser, struct pakfire* pakfire,
+ const char* path, pakfire_parser_error** error) {
int r;
// Fetch context
}
static int pakfire_dist_get_mirrorlist(pakfire_ctx* ctx, struct pakfire* pakfire,
- struct pakfire_parser* makefile, pakfire_mirrorlist** list) {
+ pakfire_parser* makefile, pakfire_mirrorlist** list) {
pakfire_mirrorlist* m = NULL;
pakfire_mirror* mirror = NULL;
char* p = NULL;
}
static int pakfire_dist_add_sources(pakfire_ctx* ctx, struct pakfire* pakfire,
- pakfire_packager* packager, pakfire_package* pkg, struct pakfire_parser* makefile) {
+ pakfire_packager* packager, pakfire_package* pkg, pakfire_parser* makefile) {
pakfire_mirrorlist* mirrorlist = NULL;
char* sources = NULL;
char* p = NULL;
const char* path, pakfire_archive** archive) {
pakfire_packager* packager = NULL;
pakfire_package* pkg = NULL;
- struct pakfire_parser* makefile = NULL;
- struct pakfire_parser_error* error = NULL;
+ pakfire_parser* makefile = NULL;
+ pakfire_parser_error* error = NULL;
pakfire_archive* a = NULL;
int r;
int pakfire_dist(struct pakfire* pakfire,
const char* path, pakfire_archive** archive);
-int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfire,
- const char* path, struct pakfire_parser_error** error);
+int pakfire_read_makefile(pakfire_parser** parser, struct pakfire* pakfire,
+ const char* path, pakfire_parser_error** error);
#endif /* PAKFIRE_DIST_H */
struct pakfire* pakfire;
int nrefs;
- struct pakfire_parser* parent;
+ pakfire_parser* parent;
int flags;
// Namespace
char namespace[NAME_MAX];
- struct pakfire_parser_declaration** declarations;
+ pakfire_parser_declaration** declarations;
size_t num_declarations;
};
-static void pakfire_parser_free_declaration(struct pakfire_parser_declaration* d) {
+static void pakfire_parser_free_declaration(pakfire_parser_declaration* d) {
if (d->value)
free(d->value);
free(d);
}
-static void pakfire_parser_free_declarations(struct pakfire_parser* parser) {
+static void pakfire_parser_free_declarations(pakfire_parser* parser) {
if (parser->declarations) {
for (unsigned int i = 0; i < parser->num_declarations; i++)
pakfire_parser_free_declaration(parser->declarations[i]);
}
}
-static void pakfire_parser_free(struct pakfire_parser* parser) {
+static void pakfire_parser_free(pakfire_parser* parser) {
pakfire_parser_free_declarations(parser);
if (parser->parent)
free(parser);
}
-int pakfire_parser_create(struct pakfire_parser** parser,
- struct pakfire* pakfire, struct pakfire_parser* parent, const char* namespace, int flags) {
- struct pakfire_parser* self = NULL;
+int pakfire_parser_create(pakfire_parser** parser,
+ struct pakfire* pakfire, pakfire_parser* parent, const char* namespace, int flags) {
+ pakfire_parser* self = NULL;
int r;
// Allocate some memory
return r;
}
-struct pakfire_parser* pakfire_parser_create_child(struct pakfire_parser* parser, const char* namespace) {
- struct pakfire_parser* child = NULL;
+pakfire_parser* pakfire_parser_create_child(pakfire_parser* parser, const char* namespace) {
+ pakfire_parser* child = NULL;
int r;
// Create the parser
return child;
}
-struct pakfire_parser* pakfire_parser_ref(struct pakfire_parser* parser) {
+pakfire_parser* pakfire_parser_ref(pakfire_parser* parser) {
++parser->nrefs;
return parser;
}
-struct pakfire* pakfire_parser_get_pakfire(struct pakfire_parser* parser) {
+struct pakfire* pakfire_parser_get_pakfire(pakfire_parser* parser) {
return pakfire_ref(parser->pakfire);
}
-struct pakfire_parser* pakfire_parser_unref(struct pakfire_parser* parser) {
+pakfire_parser* pakfire_parser_unref(pakfire_parser* parser) {
if (--parser->nrefs > 0)
return parser;
return NULL;
}
-struct pakfire_parser* pakfire_parser_get_parent(struct pakfire_parser* parser) {
+pakfire_parser* pakfire_parser_get_parent(pakfire_parser* parser) {
if (parser->parent)
return pakfire_parser_ref(parser->parent);
return NULL;
}
-static struct pakfire_parser_declaration* pakfire_parser_get_declaration(
- struct pakfire_parser* parser, const char* namespace, const char* name) {
+static pakfire_parser_declaration* pakfire_parser_get_declaration(
+ pakfire_parser* parser, const char* namespace, const char* name) {
if (!name) {
errno = EINVAL;
return NULL;
DEBUG(parser->ctx, "%p: Looking up %s\n", parser, name);
#endif /* PAKFIRE_DEBUG_PARSER */
- struct pakfire_parser_declaration* d;
+ pakfire_parser_declaration* d;
for (unsigned i = 0; i < parser->num_declarations; i++) {
d = parser->declarations[i];
if (!d)
return NULL;
}
-static struct pakfire_parser_declaration* pakfire_parser_get_declaration_recursive(
- struct pakfire_parser* parser, const char* namespace, const char* name) {
- struct pakfire_parser_declaration* d = pakfire_parser_get_declaration(
+static pakfire_parser_declaration* pakfire_parser_get_declaration_recursive(
+ pakfire_parser* parser, const char* namespace, const char* name) {
+ pakfire_parser_declaration* d = pakfire_parser_get_declaration(
parser, namespace, name);
if (d)
return d;
return result;
}
-static struct pakfire_parser_declaration* pakfire_parser_find_declaration(
- struct pakfire_parser* parser, const char* namespace, const char* name) {
- struct pakfire_parser_declaration* d = NULL;
+static pakfire_parser_declaration* pakfire_parser_find_declaration(
+ pakfire_parser* parser, const char* namespace, const char* name) {
+ pakfire_parser_declaration* d = NULL;
char n[NAME_MAX] = "";
int r;
return NULL;
}
-int pakfire_parser_set(struct pakfire_parser* parser,
+int pakfire_parser_set(pakfire_parser* parser,
const char* namespace, const char* name, const char* value, int flags) {
- struct pakfire_parser_declaration* d = NULL;
+ pakfire_parser_declaration* d = NULL;
char* buffer = NULL;
int r;
return r;
}
-int pakfire_parser_apply_declaration(struct pakfire_parser* parser,
- struct pakfire_parser_declaration* declaration) {
+int pakfire_parser_apply_declaration(pakfire_parser* parser,
+ pakfire_parser_declaration* declaration) {
return pakfire_parser_set(parser, declaration->namespace,
declaration->name, declaration->value, declaration->flags);
}
-static int pakfire_parser_find_template(struct pakfire_parser* parser,
+static int pakfire_parser_find_template(pakfire_parser* parser,
char* template, const size_t length, const char* namespace) {
- struct pakfire_parser_declaration* d = NULL;
+ pakfire_parser_declaration* d = NULL;
const char* value = "MAIN";
DEBUG(parser->ctx, "Looking up template in namespace '%s'\n", namespace);
return __pakfire_string_format(template, length, "packages.template:%s", value);
}
-static const char* pakfire_parser_get_raw(struct pakfire_parser* parser, const char* namespace, const char* name) {
- struct pakfire_parser_declaration* d = NULL;
+static const char* pakfire_parser_get_raw(pakfire_parser* parser, const char* namespace, const char* name) {
+ pakfire_parser_declaration* d = NULL;
char template[NAME_MAX];
int r;
return NULL;
}
-int pakfire_parser_append(struct pakfire_parser* parser,
+int pakfire_parser_append(pakfire_parser* parser,
const char* namespace, const char* name, const char* value) {
char* buffer = NULL;
return r;
}
-static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char** buffer) {
+static int pakfire_parser_expand_commands(pakfire_parser* parser, char** buffer) {
pcre2_match_data* match = NULL;
PCRE2_UCHAR* command = NULL;
PCRE2_SIZE command_length;
return r;
}
-static int pakfire_parser_expand_variables(struct pakfire_parser* parser,
+static int pakfire_parser_expand_variables(pakfire_parser* parser,
const char* namespace, char** buffer) {
char parent_namespace[NAME_MAX];
pcre2_match_data* match = NULL;
return r;
}
-char* pakfire_parser_expand(struct pakfire_parser* parser,
+char* pakfire_parser_expand(pakfire_parser* parser,
const char* namespace, const char* value) {
char* buffer = NULL;
int r;
return NULL;
}
-char* pakfire_parser_get(struct pakfire_parser* parser, const char* namespace, const char* name) {
+char* pakfire_parser_get(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
return pakfire_parser_expand(parser, namespace, value);
}
-int pakfire_parser_get_filelist(struct pakfire_parser* parser, const char* namespace,
+int pakfire_parser_get_filelist(pakfire_parser* parser, const char* namespace,
const char* name, char*** includes, char*** excludes) {
const char* file = NULL;
char* p = NULL;
return r;
}
-char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, const char* filter) {
- struct pakfire_parser_declaration* d = NULL;
+char** pakfire_parser_list_namespaces(pakfire_parser* parser, const char* filter) {
+ pakfire_parser_declaration* d = NULL;
char** namespaces = NULL;
int r;
return NULL;
}
-int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser* parser2) {
- struct pakfire_parser_declaration* d = NULL;
+int pakfire_parser_merge(pakfire_parser* parser1, pakfire_parser* parser2) {
+ pakfire_parser_declaration* d = NULL;
char* namespace = NULL;
char* value = NULL;
int r = 0;
return r;
}
-int pakfire_parser_read(struct pakfire_parser* parser, FILE* f,
- struct pakfire_parser_error** error) {
+int pakfire_parser_read(pakfire_parser* parser, FILE* f,
+ pakfire_parser_error** error) {
char* data = NULL;
size_t length = 0;
int fd = -EBADF;
return r;
}
-int pakfire_parser_read_file(struct pakfire_parser* parser, const char* path,
- struct pakfire_parser_error** error) {
+int pakfire_parser_read_file(pakfire_parser* parser, const char* path,
+ pakfire_parser_error** error) {
FILE* f = NULL;
int r;
return r;
}
-int pakfire_parser_parse(struct pakfire_parser* parser,
- const char* data, size_t size, struct pakfire_parser_error** error) {
+int pakfire_parser_parse(pakfire_parser* parser,
+ const char* data, size_t size, pakfire_parser_error** error) {
return pakfire_parser_parse_data(parser, data, size, error);
}
-char* pakfire_parser_dump(struct pakfire_parser* parser) {
+char* pakfire_parser_dump(pakfire_parser* parser) {
char buffer[NAME_MAX*2 + 1];
char* s = NULL;
int r;
for (unsigned int i = 0; i < parser->num_declarations; i++) {
- struct pakfire_parser_declaration* d = parser->declarations[i];
+ pakfire_parser_declaration* d = parser->declarations[i];
if (d) {
if (*d->namespace)
return s;
}
-const char* pakfire_parser_get_namespace(struct pakfire_parser* parser) {
+const char* pakfire_parser_get_namespace(pakfire_parser* parser) {
return parser->namespace;
}
-int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace) {
+int pakfire_parser_set_namespace(pakfire_parser* parser, const char* namespace) {
return pakfire_string_set(parser->namespace, namespace);
}
-int pakfire_parser_set_env(struct pakfire_parser* parser, pakfire_env* env) {
- struct pakfire_parser_declaration* d = NULL;
+int pakfire_parser_set_env(pakfire_parser* parser, pakfire_env* env) {
+ pakfire_parser_declaration* d = NULL;
char* value = NULL;
int r;
return 0;
}
-int pakfire_parser_create_package(struct pakfire_parser* parser,
+int pakfire_parser_create_package(pakfire_parser* parser,
pakfire_package** pkg, struct pakfire_repo* repo, const char* namespace, const char* default_arch) {
int r = 1;
// Error
struct pakfire_parser_error {
- struct pakfire_parser* parser;
+ pakfire_parser* parser;
int nrefs;
char* filename;
char* message;
};
-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));
+int pakfire_parser_error_create(pakfire_parser_error** error,
+ pakfire_parser* parser, const char* filename, int line, const char* message) {
+ pakfire_parser_error* e = calloc(1, sizeof(*e));
if (!e)
return ENOMEM;
return 0;
}
-struct pakfire_parser_error* pakfire_parser_error_ref(
- struct pakfire_parser_error* error) {
+pakfire_parser_error* pakfire_parser_error_ref(
+ pakfire_parser_error* error) {
++error->nrefs;
return error;
}
-static void pakfire_parser_error_free(struct pakfire_parser_error* error) {
+static void pakfire_parser_error_free(pakfire_parser_error* error) {
if (error->parser)
pakfire_parser_unref(error->parser);
if (error->filename)
free(error);
}
-struct pakfire_parser_error* pakfire_parser_error_unref(
- struct pakfire_parser_error* error) {
+pakfire_parser_error* pakfire_parser_error_unref(
+ pakfire_parser_error* error) {
if (--error->nrefs > 0)
return error;
}
const char* pakfire_parser_error_get_filename(
- struct pakfire_parser_error* error) {
+ pakfire_parser_error* error) {
return error->filename;
}
-int pakfire_parser_error_get_line(struct pakfire_parser_error* error) {
+int pakfire_parser_error_get_line(pakfire_parser_error* error) {
return error->line;
}
const char* pakfire_parser_error_get_message(
- struct pakfire_parser_error* error) {
+ pakfire_parser_error* error) {
return error->message;
}
#include <linux/limits.h>
#include <stdio.h>
-struct pakfire_parser;
+typedef struct pakfire_parser pakfire_parser;
#include <pakfire/env.h>
#include <pakfire/package.h>
PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS = (1 << 0),
};
-struct pakfire_parser_error;
+typedef struct pakfire_parser_error pakfire_parser_error;
-int pakfire_parser_create(struct pakfire_parser** parser, struct pakfire* pakfire,
- struct pakfire_parser* parent, const char* namespace, int flags);
-struct pakfire_parser* pakfire_parser_create_child(struct pakfire_parser* parser,
+int pakfire_parser_create(pakfire_parser** parser, struct pakfire* pakfire,
+ pakfire_parser* parent, const char* namespace, int flags);
+pakfire_parser* pakfire_parser_create_child(pakfire_parser* parser,
const char* namespace);
-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);
+pakfire_parser* pakfire_parser_ref(pakfire_parser* parser);
+pakfire_parser* pakfire_parser_unref(pakfire_parser* parser);
+pakfire_parser* pakfire_parser_get_parent(pakfire_parser* parser);
-int pakfire_parser_set(struct pakfire_parser* parser,
+int pakfire_parser_set(pakfire_parser* parser,
const char* namespace, const char* name, const char* value, int flags);
-int pakfire_parser_append(struct pakfire_parser* parser,
+int pakfire_parser_append(pakfire_parser* parser,
const char* namespace, const char* name, const char* value);
-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);
-int pakfire_parser_get_filelist(struct pakfire_parser* parser, const char* namespace,
+char* pakfire_parser_expand(pakfire_parser* parser, const char* namespace, const char* value);
+char* pakfire_parser_get(pakfire_parser* parser, const char* namespace, const char* name);
+int pakfire_parser_get_filelist(pakfire_parser* parser, const char* namespace,
const char* name, char*** includes, char*** excludes);
-char** pakfire_parser_list_namespaces(struct pakfire_parser* parser, const char* filter);
+char** pakfire_parser_list_namespaces(pakfire_parser* parser, const char* filter);
-int pakfire_parser_merge(struct pakfire_parser* parser1, struct pakfire_parser* parser2);
+int pakfire_parser_merge(pakfire_parser* parser1, pakfire_parser* parser2);
-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(struct pakfire_parser* parser, const char* data, size_t size,
- struct pakfire_parser_error** error);
-char* pakfire_parser_dump(struct pakfire_parser* parser);
+int pakfire_parser_read(pakfire_parser* parser, FILE* f, pakfire_parser_error** error);
+int pakfire_parser_read_file(pakfire_parser* parser, const char* path,
+ pakfire_parser_error** error);
+int pakfire_parser_parse(pakfire_parser* parser, const char* data, size_t size,
+ pakfire_parser_error** error);
+char* pakfire_parser_dump(pakfire_parser* parser);
-const char* pakfire_parser_get_namespace(struct pakfire_parser* parser);
-int pakfire_parser_set_namespace(struct pakfire_parser* parser, const char* namespace);
+const char* pakfire_parser_get_namespace(pakfire_parser* parser);
+int pakfire_parser_set_namespace(pakfire_parser* parser, const char* namespace);
-int pakfire_parser_create_package(struct pakfire_parser* parser,
+int pakfire_parser_create_package(pakfire_parser* parser,
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,
- 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);
+int pakfire_parser_error_create(pakfire_parser_error** error,
+ pakfire_parser* parser, const char* filename, int line, const char* message);
+pakfire_parser_error* pakfire_parser_error_ref(pakfire_parser_error* error);
+pakfire_parser_error* pakfire_parser_error_unref(pakfire_parser_error* error);
-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);
+const char* pakfire_parser_error_get_filename(pakfire_parser_error* error);
+int pakfire_parser_error_get_line(pakfire_parser_error* error);
+const char* pakfire_parser_error_get_message(pakfire_parser_error* error);
-struct pakfire* pakfire_parser_get_pakfire(struct pakfire_parser* parser);
+struct pakfire* pakfire_parser_get_pakfire(pakfire_parser* parser);
-struct pakfire_parser_state {
+typedef struct pakfire_parser_state {
unsigned int lineno;
// Indentation level
// Remember current indentation
unsigned int current_indent;
unsigned int readline_indent;
-};
+} pakfire_parser_state;
-struct pakfire_parser_declaration {
+typedef struct pakfire_parser_declaration {
char namespace[NAME_MAX];
char name[NAME_MAX];
char* value;
PAKFIRE_PARSER_DECLARATION_EXPORT = (1 << 0),
PAKFIRE_PARSER_DECLARATION_APPEND = (1 << 1),
} flags;
-};
+} pakfire_parser_declaration;
int pakfire_parser_apply_declaration(
- struct pakfire_parser* parser, struct pakfire_parser_declaration* declaration);
+ pakfire_parser* parser, pakfire_parser_declaration* declaration);
-int pakfire_parser_parse_data(struct pakfire_parser* parent, const char* data, size_t len,
- struct pakfire_parser_error** error);
+int pakfire_parser_parse_data(pakfire_parser* parent, const char* data, size_t len,
+ pakfire_parser_error** error);
-int pakfire_parser_set_env(struct pakfire_parser* parser, pakfire_env* env);
+int pakfire_parser_set_env(pakfire_parser* parser, pakfire_env* env);
#endif /* PAKFIRE_PARSER_H */
{yyscan_t* scanner}
{pakfire_ctx* ctx}
{struct pakfire* pakfire}
- {struct pakfire_parser** parser}
- {struct pakfire_parser* parent}
- {struct pakfire_parser_error** error}
+ {pakfire_parser** parser}
+ {pakfire_parser* parent}
+ {pakfire_parser_error** error}
// Make the parser reentrant
%define api.pure full
#endif
typedef void* yyscan_t;
-extern int yylex_init_extra(struct pakfire_parser_state* state, yyscan_t* scanner);
+extern int yylex_init_extra(pakfire_parser_state* state, yyscan_t* scanner);
int yylex_destroy(yyscan_t scanner);
typedef struct yy_buffer_state* YY_BUFFER_STATE;
extern YY_BUFFER_STATE yy_scan_bytes(const char* buffer, int len, yyscan_t scanner);
extern void yy_delete_buffer(YY_BUFFER_STATE buffer, yyscan_t scanner);
-#define YY_EXTRA_TYPE struct pakfire_parser_state*
+#define YY_EXTRA_TYPE pakfire_parser_state*
YY_EXTRA_TYPE yyget_extra(yyscan_t scanner);
#include "grammar.h"
};
static void yyerror(yyscan_t* scanner, pakfire_ctx* ctx, struct pakfire* pakfire,
- struct pakfire_parser** parser, struct pakfire_parser* parent,
- struct pakfire_parser_error** error, const char* s) {
- const struct pakfire_parser_state* state = yyget_extra(scanner);
+ pakfire_parser** parser, pakfire_parser* parent,
+ pakfire_parser_error** error, const char* s) {
+ const pakfire_parser_state* state = yyget_extra(scanner);
ERROR(ctx, "Error (line %u): %s\n", state->lineno, s);
}
}
-static struct pakfire_parser* make_if_stmt(pakfire_ctx* ctx, const enum operator op,
- const char* val1, const char* val2, struct pakfire_parser* if_block, struct pakfire_parser* else_block);
+static pakfire_parser* make_if_stmt(pakfire_ctx* ctx, const enum operator op,
+ const char* val1, const char* val2, pakfire_parser* if_block, pakfire_parser* else_block);
static int pakfire_parser_new_declaration(
- struct pakfire_parser_declaration** declaration, const char* name, const char* value, int flags) {
+ pakfire_parser_declaration** declaration, const char* name, const char* value, int flags) {
if (!name)
return EINVAL;
- struct pakfire_parser_declaration* d = calloc(1, sizeof(*d));
+ pakfire_parser_declaration* d = calloc(1, sizeof(*d));
if (!d)
return ENOMEM;
return 0;
}
-static void pakfire_parser_free_declaration(struct pakfire_parser_declaration* declaration) {
+static void pakfire_parser_free_declaration(pakfire_parser_declaration* declaration) {
if (declaration->value)
free(declaration->value);
%type <string> line
%union {
- struct pakfire_parser* parser;
+ pakfire_parser* parser;
char* string;
- struct pakfire_parser_declaration* declaration;
+ pakfire_parser_declaration* declaration;
}
%initial-action {
block : T_INDENT grammar T_OUTDENT
{
// Reset the top parser
- struct pakfire_parser* p = pakfire_parser_get_parent(*parser);
+ pakfire_parser* p = pakfire_parser_get_parent(*parser);
pakfire_parser_unref(*parser);
*parser = p;
%%
-int pakfire_parser_parse_data(struct pakfire_parser* parent, const char* data, size_t len,
- struct pakfire_parser_error** error) {
+int pakfire_parser_parse_data(pakfire_parser* parent, const char* data, size_t len,
+ pakfire_parser_error** error) {
struct pakfire* pakfire = pakfire_parser_get_pakfire(parent);
yyscan_t scanner;
int r;
// Initialize the parser's state
- struct pakfire_parser_state state = {
+ pakfire_parser_state state = {
.lineno = 1,
.indent_level = 0,
.current_indent = 0,
yylex_init_extra(&state, &scanner);
// Create a new sub-parser
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
YY_BUFFER_STATE buffer = yy_scan_bytes(data, len, scanner);
r = yyparse(scanner, ctx, pakfire, &parser, parent, error);
return r;
}
-static struct pakfire_parser* make_if_stmt(pakfire_ctx* ctx, const enum operator op,
- const char* val1, const char* val2, struct pakfire_parser* if_block, struct pakfire_parser* else_block) {
+static pakfire_parser* make_if_stmt(pakfire_ctx* ctx, const enum operator op,
+ const char* val1, const char* val2, pakfire_parser* if_block, pakfire_parser* else_block) {
switch (op) {
case OP_EQUALS:
DEBUG(ctx, "Evaluating if statement: %s == %s?\n", val1, val2);
break;
}
- struct pakfire_parser* parent = pakfire_parser_get_parent(if_block);
+ pakfire_parser* parent = pakfire_parser_get_parent(if_block);
DEBUG(ctx, " parent = %p, if = %p, else = %p\n", parent, if_block, else_block);
char* v1 = pakfire_parser_expand(parent, NULL, val1);
char* v2 = pakfire_parser_expand(parent, NULL, val2);
- struct pakfire_parser* result = NULL;
+ pakfire_parser* result = NULL;
switch (op) {
case OP_EQUALS:
%option reentrant
%option stack noyy_top_state
%option warn
-%option extra-type="struct pakfire_parser_state*"
+%option extra-type="pakfire_parser_state*"
/* Enable to debug the scanner */
/* %option debug */
NULL,
};
-static int load_macros(struct pakfire_parser* parser) {
+static int load_macros(pakfire_parser* parser) {
const char* macros = TEST_SRC_PATH "../macros/*.macro";
glob_t buffer;
}
static int test_parse(const struct test* t) {
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
const char** makefile = makefiles;
char path[PATH_MAX];
int r = EXIT_FAILURE;
}
static int test_macros(const struct test* t) {
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
int r = EXIT_FAILURE;
ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
}
static int test_packages(const struct test* t) {
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
pakfire_package* pkg = NULL;
struct pakfire_repo* repo = NULL;
char* s = NULL;
#include "../testsuite.h"
static int test_parser(const struct test* t) {
- struct pakfire_parser* parser = NULL;
- struct pakfire_parser* subparser = NULL;
+ pakfire_parser* parser = NULL;
+ pakfire_parser* subparser = NULL;
int r = EXIT_FAILURE;
char* s = NULL;
};
static int test_parser_files(const struct test* t) {
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
const char** file = files;
char path[PATH_MAX];
int r = EXIT_FAILURE;
}
static int test_append(const struct test* t) {
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
int r = EXIT_FAILURE;
char* s = NULL;
#if 0
static int test_parser_command(const struct test* t) {
const char* command = "%(echo \"ABC\")";
- struct pakfire_parser* parser = NULL;
+ pakfire_parser* parser = NULL;
int r = EXIT_FAILURE;
ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS));
pakfire_config* config = NULL;
pakfire_ctx* ctx = NULL;
struct pakfire* pakfire = NULL;
- struct pakfire_parser* parser = NULL;
- struct pakfire_parser_error* error = NULL;
+ pakfire_parser* parser = NULL;
+ pakfire_parser_error* error = NULL;
const char* message = NULL;
FILE* f = NULL;
int r = 1;