1.1 --- a/librazor/razor-internal.h Thu Nov 13 10:44:53 2014 +0000
1.2 +++ b/librazor/razor-internal.h Mon Jul 04 10:48:18 2016 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
1.6 * Copyright (C) 2008 Red Hat, Inc
1.7 - * Copyright (C) 2009, 2011-2012, 2014 J. Ali Harlow <ali@juiblex.co.uk>
1.8 + * Copyright (C) 2009, 2011-2012, 2014, 2016 J. Ali Harlow <ali@juiblex.co.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or modify
1.11 * it under the terms of the GNU General Public License as published by
1.12 @@ -42,6 +42,9 @@
1.13 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
1.14 #define PADDING(value, base) (-(value) & (base - 1))
1.15 #define ALIGN(value, base) ((value) + PADDING(value, base))
1.16 +
1.17 +#define str_has_prefix(s, prefix) (!strncmp(s, prefix, strlen(prefix)))
1.18 +
1.19 void *zalloc(size_t size);
1.20
1.21 struct razor_set_section {
1.22 @@ -181,7 +184,7 @@
1.23 };
1.24
1.25 int
1.26 -razor_set_aquire_lock(struct razor_set *set, const char *path, int exclusive);
1.27 +razor_set_acquire_lock(struct razor_set *set, const char *path, int exclusive);
1.28
1.29 struct razor_entry *
1.30 razor_set_find_entry(struct razor_set *set,
1.31 @@ -206,7 +209,72 @@
1.32 ssize_t len, int arg1);
1.33
1.34 int razor_run_script(const char *root, enum razor_property_flags script,
1.35 - const char *program, const char *body, int arg1);
1.36 + const char *program, const char *body, int arg1,
1.37 + struct razor_error **error);
1.38 +
1.39 +/* URI functions */
1.40 +
1.41 +struct razor_uri {
1.42 + char *scheme;
1.43 + char *userinfo;
1.44 + char *host;
1.45 + char *port;
1.46 + char *path;
1.47 + char *query;
1.48 + char *fragment;
1.49 +};
1.50 +
1.51 +void razor_uri_destroy(struct razor_uri *ru);
1.52 +int razor_uri_parse_uri(struct razor_uri *ru, const char *uri, int absolute,
1.53 + struct razor_error **error);
1.54 +int razor_uri_parse_relative_ref(struct razor_uri *ru, const char *uri,
1.55 + struct razor_error **error);
1.56 +int razor_uri_parse(struct razor_uri *ru, const char *uri,
1.57 + struct razor_error **error);
1.58 +void razor_uri_normalize(struct razor_uri *ru);
1.59 +char *razor_uri_get_authority(const struct razor_uri *ru) RAZOR_MALLOC;
1.60 +char *razor_uri_recompose(const struct razor_uri *ru) RAZOR_MALLOC;
1.61 +void razor_uri_resolve(struct razor_uri *T, const struct razor_uri *base,
1.62 + const struct razor_uri *R);
1.63 +
1.64 +char *razor_resolve_uri_root(const char *root_uri, const char *relative_uri,
1.65 + int is_relative, struct razor_error **error)
1.66 + RAZOR_MALLOC;
1.67 +
1.68 +int razor_file_mkdir(const char *path, mode_t mode, struct razor_error **error);
1.69 +int razor_file_unlink(const char *path, struct razor_error **error);
1.70 +int razor_file_open(const char *path, int flags, mode_t mode,
1.71 + struct razor_error **error);
1.72 +int razor_file_move(const char *path, const char *dest,
1.73 + struct razor_error **error);
1.74 +void *razor_file_get_contents(const char *path, size_t *length, int _private,
1.75 + struct razor_error **error);
1.76 +int razor_file_free_contents(void *addr, size_t length);
1.77 +int razor_file_is_directory(const char *path, struct razor_error **error);
1.78 +char *razor_file_mkdtemp_near(const char *path, const char *_template,
1.79 + struct razor_error **error);
1.80 +void *razor_file_opendir(const char *path, struct razor_error **error);
1.81 +char *razor_file_readdir(void *dir, struct razor_error **error);
1.82 +int razor_file_closedir(void *dir, struct razor_error **error);
1.83 +
1.84 +int razor_uri_mkdir(const char *uri, mode_t mode, struct razor_error **error);
1.85 +int razor_uri_unlink(const char *uri, struct razor_error **error);
1.86 +int razor_uri_open(const char *uri, int flags, mode_t mode,
1.87 + struct razor_error **error);
1.88 +int razor_uri_move(const char *uri, const char *dest,
1.89 + struct razor_error **error);
1.90 +int razor_uri_is_directory(const char *uri, struct razor_error **error);
1.91 +char *razor_uri_mkdtemp_near(const char *uri, const char *template,
1.92 + struct razor_error **error) RAZOR_MALLOC;
1.93 +void *razor_uri_opendir(const char *uri, struct razor_error **error);
1.94 +char *razor_uri_readdir(void *dir, struct razor_error **error) RAZOR_MALLOC;
1.95 +int razor_uri_closedir(void *dir, struct razor_error **error);
1.96 +void *razor_uri_get_contents(const char *uri, size_t *length, int private,
1.97 + struct razor_error **error);
1.98 +int razor_uri_free_contents(void *addr, size_t length);
1.99 +
1.100 +char *razor_path_from_parsed_uri(const struct razor_uri *ru,
1.101 + struct razor_error **error);
1.102
1.103 /* Utility functions */
1.104
1.105 @@ -216,16 +284,6 @@
1.106 va_list args);
1.107 void razor_rpm_get_details_varg(struct razor_rpm *rpm, va_list args);
1.108
1.109 -int razor_create_dir(const char *root, const char *path);
1.110 -int razor_remove(const char *path);
1.111 -int razor_write(int fd, const void *data, size_t size);
1.112 -
1.113 -void *
1.114 -razor_file_get_contents(const char *filename, size_t *length, int private,
1.115 - struct razor_error **error);
1.116 -int razor_file_free_contents(void *addr, size_t length);
1.117 -
1.118 -
1.119 typedef int (*razor_compare_with_data_func_t)(const void *p1,
1.120 const void *p,
1.121 void *data);
1.122 @@ -267,6 +325,10 @@
1.123 if (error) \
1.124 *(error) = razor_error_new_posix(object); \
1.125 else
1.126 +#define razor_set_error(error, domain, code, object, str) \
1.127 + if (error) \
1.128 + *(error) = razor_error_new_str(domain, code, object, str); \
1.129 + else
1.130
1.131 #ifdef MSWIN_API
1.132 struct razor_error *razor_error_new_mswin(const wchar_t *object, DWORD error);
1.133 @@ -312,7 +374,7 @@
1.134 ACTION_MOVE,
1.135 } type;
1.136 struct {
1.137 - char *path;
1.138 + char *uri;
1.139 union atomic_action_args {
1.140 struct {
1.141 char *root;
1.142 @@ -359,6 +421,9 @@
1.143 };
1.144 #endif
1.145
1.146 +char *razor_resolve_database_file(const char *root_uri, const char *filename,
1.147 + struct razor_error **error);
1.148 +
1.149 int razor_allow_all_root_names(void);
1.150 int razor_valid_root_name(const char *name);
1.151