]> git.ipfire.org Git - pakfire.git/commitdiff
json: Use "json_object" instead of "struct json_object"
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 15:14:01 +0000 (15:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 15:14:01 +0000 (15:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
23 files changed:
src/cli/lib/dump.c
src/cli/lib/dump.h
src/pakfire/archive.c
src/pakfire/archive_writer.c
src/pakfire/archive_writer.h
src/pakfire/builder.c
src/pakfire/builder.h
src/pakfire/client.c
src/pakfire/job.c
src/pakfire/job.h
src/pakfire/json.c
src/pakfire/json.h
src/pakfire/jwt.c
src/pakfire/jwt.h
src/pakfire/mirrorlist.c
src/pakfire/oci.c
src/pakfire/package.c
src/pakfire/package.h
src/pakfire/packager.c
src/pakfire/repo.c
src/pakfire/xfer.c
src/pakfire/xfer.h
tests/libpakfire/jwt.c

index 419b2545c4c71734788cb2e3eecc15b8e7d4e48f..476f4c773b31bf850e56e323d838bce1ebc77975 100644 (file)
@@ -98,7 +98,7 @@ ERROR:
        return r;
 }
 
-int cli_dump_json(struct json_object* object) {
+int cli_dump_json(json_object* object) {
        int r;
 
        // Serialize the object as a JSON string
index 606c6333cf4171c111355af81cdd1ea5d598f892..30bd2d91ef4153eb7baffaba4de446a2bba1f584 100644 (file)
@@ -33,6 +33,6 @@ int cli_dump_packagelist(pakfire_packagelist* list, int flags);
 
 int cli_dump_repolist(pakfire_repolist* list, int flags);
 
-int cli_dump_json(struct json_object* object);
+int cli_dump_json(json_object* object);
 
 #endif /* PAKFIRE_CLI_DUMP_H */
index e6ae67865da27e59aa8eca202e07146e37ab8882..3eaeb234367e0a3e80748ab64080090478207dae 100644 (file)
@@ -78,7 +78,7 @@ struct pakfire_archive {
 
        // metadata
        unsigned int format;
-       struct json_object* metadata;
+       json_object* metadata;
 
        pakfire_filelist* filelist;
 
@@ -765,9 +765,9 @@ ERROR:
        return r;
 }
 
-static struct json_object* pakfire_archive_metadata_get_object(
+static json_object* pakfire_archive_metadata_get_object(
                pakfire_archive* archive, const char* key1, const char* key2) {
-       struct json_object* object = archive->metadata;
+       json_object* object = archive->metadata;
        int r;
 
        const char* keys[] = {
@@ -792,7 +792,7 @@ static struct json_object* pakfire_archive_metadata_get_object(
 static const char* pakfire_archive_metadata_get(
                pakfire_archive* archive, const char* key1, const char* key2) {
        // Try finding an object
-       struct json_object* object = pakfire_archive_metadata_get_object(archive, key1, key2);
+       json_object* object = pakfire_archive_metadata_get_object(archive, key1, key2);
        if (!object)
                return NULL;
 
@@ -803,7 +803,7 @@ static const char* pakfire_archive_metadata_get(
 static int64_t pakfire_archive_metadata_get_int64(
                pakfire_archive* archive, const char* key1, const char* key2) {
        // Try finding an object
-       struct json_object* object = pakfire_archive_metadata_get_object(archive, key1, key2);
+       json_object* object = pakfire_archive_metadata_get_object(archive, key1, key2);
        if (!object)
                return 0;
 
@@ -1544,7 +1544,7 @@ int pakfire_archive_verify_checksum(pakfire_archive* archive,
 
 static int pakfire_archive_import_filelist_from_json(
                pakfire_archive* archive, pakfire_package* package) {
-       struct json_object* array = NULL;
+       json_object* array = NULL;
        int r;
 
        // Fetch the array with the filelist
@@ -1563,7 +1563,7 @@ static int pakfire_archive_import_filelist_from_json(
 
        // Walk through all items in this array
        for (unsigned int i = 0; i < length; i++) {
-               struct json_object* item = json_object_array_get_idx(array, i);
+               json_object* item = json_object_array_get_idx(array, i);
                if (!item)
                        continue;
 
@@ -1647,14 +1647,14 @@ static int pakfire_archive_make_package_from_json(pakfire_archive* archive,
        }
 
        // Groups
-       struct json_object* groups = pakfire_archive_metadata_get_object(archive, "groups", NULL);
+       json_object* groups = pakfire_archive_metadata_get_object(archive, "groups", NULL);
 
        if (groups) {
                if (json_object_is_type(groups, json_type_array)) {
                        const size_t length = json_object_array_length(groups);
 
                        for (unsigned int i = 0; i < length; i++) {
-                               struct json_object* item = json_object_array_get_idx(groups, i);
+                               json_object* item = json_object_array_get_idx(groups, i);
                                if (!item)
                                        continue;
 
@@ -1763,12 +1763,12 @@ static int pakfire_archive_make_package_from_json(pakfire_archive* archive,
        }
 
        // Build arches
-       struct json_object* build_arches = pakfire_archive_metadata_get_object(archive, "build", "arches");
+       json_object* build_arches = pakfire_archive_metadata_get_object(archive, "build", "arches");
        if (build_arches && json_object_is_type(build_arches, json_type_array)) {
                const size_t length = json_object_array_length(build_arches);
 
                for (unsigned int i = 0; i < length; i++) {
-                       struct json_object* item = json_object_array_get_idx(build_arches, i);
+                       json_object* item = json_object_array_get_idx(build_arches, i);
                        if (!item)
                                continue;
 
@@ -1808,7 +1808,7 @@ static int pakfire_archive_make_package_from_json(pakfire_archive* archive,
 
        // Dependencies
        for (const struct pakfire_dep* dep = pakfire_deps; dep->key; dep++) {
-               struct json_object* array = pakfire_archive_metadata_get_object(
+               json_object* array = pakfire_archive_metadata_get_object(
                        archive, "dependencies", dep->name);
                if (!array)
                        continue;
@@ -1820,7 +1820,7 @@ static int pakfire_archive_make_package_from_json(pakfire_archive* archive,
 
                // Walk through all items in this array
                for (unsigned int i = 0; i < length; i++) {
-                       struct json_object* item = json_object_array_get_idx(array, i);
+                       json_object* item = json_object_array_get_idx(array, i);
                        if (!item)
                                continue;
 
index 95e4a9a7f03111820d0d6680b9cec61205d17b80..a9685d19b361aa6425956021989ed77b22635a2f 100644 (file)
@@ -670,7 +670,7 @@ ERROR:
 }
 
 int pakfire_archive_writer_create_file_from_json(
-               pakfire_archive_writer* self, const char* path, mode_t mode, struct json_object* json) {
+               pakfire_archive_writer* self, const char* path, mode_t mode, json_object* json) {
        const char* buffer = NULL;
        size_t length = 0;
 
index 362689686fd9e923f910ef27670979f2ed2e5b29..8d25c25a84f2aa6986448cb0c0ca174eb4187e2e 100644 (file)
@@ -58,7 +58,7 @@ int pakfire_archive_writer_write_everything(
 int pakfire_archive_writer_create_file(pakfire_archive_writer* self,
        const char* path, mode_t mode, const char* payload, const size_t length);
 int pakfire_archive_writer_create_file_from_json(pakfire_archive_writer* self,
-       const char* path, mode_t mode, struct json_object* json);
+       const char* path, mode_t mode, json_object* json);
 int pakfire_archive_writer_create_file_from_file(
        pakfire_archive_writer* self, const char* path, mode_t mode, FILE* f);
 
index 3d7d0ea86d4107c6e79e094ef528c4d63c542566..7a5fd1dad79672cfddac59b4063e2bedcfd9c4d4 100644 (file)
@@ -179,8 +179,8 @@ static int pakfire_builder_submit_stats(sd_event_source* event, uint64_t usec, v
        struct pakfire_cpustat cpustat = {};
        struct pakfire_loadavg loadavg = {};
        struct pakfire_meminfo meminfo = {};
-       struct json_object* stats = NULL;
-       struct json_object* p = NULL;
+       json_object* stats = NULL;
+       json_object* p = NULL;
        int r;
 
        // Log action
@@ -526,7 +526,7 @@ int pakfire_builder_job_finished(pakfire_builder* self, pakfire_job* job) {
        Called when we have received a message for a specific job
 */
 static int pakfire_builder_handle_job_message(
-               pakfire_builder* self, const char* job_id, struct json_object* message) {
+               pakfire_builder* self, const char* job_id, json_object* message) {
        pakfire_job* job = NULL;
        int r;
 
@@ -553,7 +553,7 @@ ERROR:
        Called when a new job has been received
 */
 static int pakfire_builder_job(pakfire_builder* self, json_object* m) {
-       struct json_object* data = NULL;
+       json_object* data = NULL;
        pakfire_job* job = NULL;
        int r;
 
@@ -604,7 +604,7 @@ ERROR:
 }
 
 
-static int pakfire_builder_handle_message(pakfire_builder* self, struct json_object* message) {
+static int pakfire_builder_handle_message(pakfire_builder* self, json_object* message) {
        const char* job_id = NULL;
        const char* type = NULL;
        int r;
@@ -648,7 +648,7 @@ static int pakfire_builder_handle_message(pakfire_builder* self, struct json_obj
 int pakfire_builder_recv(pakfire_xfer* xfer,
                const char* message, const size_t size, void* data) {
        pakfire_builder* self = data;
-       struct json_object* m = NULL;
+       json_object* m = NULL;
        char* error = NULL;
        int r;
 
@@ -678,7 +678,7 @@ int pakfire_builder_send(pakfire_xfer* xfer, void* data) {
        return pakfire_builder_stream_logs(self);
 }
 
-int pakfire_builder_send_message(pakfire_builder* self, struct json_object* message) {
+int pakfire_builder_send_message(pakfire_builder* self, json_object* message) {
        const char* m = NULL;
        size_t length = 0;
        int r;
index 672ee79787a2cbbab408fe68eb68a8f0ab604a26..45e239d13c1a3a26c4f801eb39a55c99c8c78653 100644 (file)
@@ -46,7 +46,7 @@ int pakfire_builder_close(pakfire_xfer* xfer, int code, void* data);
 int pakfire_builder_recv(pakfire_xfer* xfer, const char* message, const size_t size, void* data);
 int pakfire_builder_send(pakfire_xfer* xfer, void* data);
 
-int pakfire_builder_send_message(pakfire_builder* self, struct json_object* message);
+int pakfire_builder_send_message(pakfire_builder* self, json_object* message);
 
 // Jobs
 
index 81761d511b81dde83f610fe6e5143f7c422266ee..f4c7aca1f53da617b76170d2443164336cf3f101 100644 (file)
@@ -176,7 +176,7 @@ static int pakfire_client_auth_required(pakfire_client* self);
 */
 static int pakfire_client_auth_refresh(pakfire_client* self) {
        pakfire_xfer* xfer = NULL;
-       struct json_object* request = NULL;
+       json_object* request = NULL;
        int r;
 
        // Require full authentication if we don't have all credentials
@@ -315,7 +315,7 @@ static int pakfire_client_set_refresh_token(pakfire_client* self, const char* to
 }
 
 static int pakfire_client_store_read(pakfire_client* self) {
-       struct json_object* store = NULL;
+       json_object* store = NULL;
        const char* refresh_token = NULL;
        const char* access_token = NULL;
        char path[PATH_MAX];
@@ -386,7 +386,7 @@ ERROR:
 }
 
 static int pakfire_client_store_write(pakfire_client* self) {
-       struct json_object* store = NULL;
+       json_object* store = NULL;
        char path[PATH_MAX];
        int r;
 
@@ -854,7 +854,7 @@ int pakfire_client_builder_disconnected(pakfire_client* self, pakfire_xfer* xfer
 int pakfire_client_build(pakfire_client* self, const char* upload, const char* repo,
                const char** arches, int flags, pakfire_xfer_response_callback callback, void* data) {
        pakfire_xfer* xfer = NULL;
-       struct json_object* request = NULL;
+       json_object* request = NULL;
        int r;
 
        // Create a new xfer
@@ -1111,7 +1111,7 @@ static int pakfire_client_upload_response(pakfire_xfer* xfer,
 int pakfire_client_upload_create(pakfire_client* self,
                const char* path, const char* filename, pakfire_client_upload_callback callback, void* data) {
        pakfire_client_upload* upload = NULL;
-       struct json_object* request = NULL;
+       json_object* request = NULL;
        char* hexdigest_blake2b512 = NULL;
        pakfire_xfer* xfer = NULL;
        int r;
@@ -1317,7 +1317,7 @@ ERROR:
 int pakfire_client_create_repo(pakfire_client* self,
                const char* distro, const char* name, const char* description) {
        pakfire_xfer* xfer = NULL;
-       struct json_object* request = NULL;
+       json_object* request = NULL;
        int r;
 
        // Check inputs
@@ -1414,7 +1414,7 @@ ERROR:
 */
 int pakfire_client_job_finished(pakfire_client* self,
                const char* job_id, const char* logfile, char** packages) {
-       struct json_object* request = NULL;
+       json_object* request = NULL;
        pakfire_xfer* xfer = NULL;
        int r;
 
index 43fb96c6ae2d30ac35df2a16441da4b4643f932d..438443448e726e18dc410d2c553e744e018fe81f 100644 (file)
@@ -743,8 +743,8 @@ int pakfire_job_launch(pakfire_job* job) {
 
 static int pakfire_job_send_log_line(pakfire_job* job,
                const struct timeval* timestamp, int priority, const char* line, size_t length) {
-       struct json_object* message = NULL;
-       struct json_object* data = NULL;
+       json_object* message = NULL;
+       json_object* data = NULL;
        char* base64 = NULL;
        char buffer[64];
        int r;
@@ -977,7 +977,7 @@ int pakfire_job_terminate(pakfire_job* job, int signal) {
        return 0;
 }
 
-int pakfire_job_handle_message(pakfire_job* self, struct json_object* message) {
+int pakfire_job_handle_message(pakfire_job* self, json_object* message) {
        const char* command = NULL;
        int r;
 
index 3cfc844eb994307b114aeb6704247532f8e1697c..00e81edeb23141ad45d39aef3a9ae98895acbdba 100644 (file)
@@ -49,6 +49,6 @@ int pakfire_job_terminate(pakfire_job* worker, int signal);
 int pakfire_job_stream_logs(pakfire_job* self);
 
 // Message Received
-int pakfire_job_handle_message(pakfire_job* self, struct json_object* message);
+int pakfire_job_handle_message(pakfire_job* self, json_object* message);
 
 #endif /* PAKFIRE_JOB_H */
index de07927edbe4e2f1578523ec96c5a7be00f1f729..49cac69b9c69c4e819a56db3b17a9fcbe6d3d6c4 100644 (file)
@@ -28,7 +28,7 @@
 #include <pakfire/logging.h>
 #include <pakfire/util.h>
 
-const char* pakfire_json_to_string(struct json_object* json, size_t* length) {
+const char* pakfire_json_to_string(json_object* json, size_t* length) {
        const char* s = NULL;
 
        const int flags = JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY;
@@ -46,7 +46,7 @@ const char* pakfire_json_to_string(struct json_object* json, size_t* length) {
 }
 
 int pakfire_json_to_file(const char* path, id_t owner, gid_t group, mode_t mode,
-               struct json_object* json) {
+               json_object* json) {
        const char* payload = NULL;
 
        // Serialize the JSON object
@@ -57,10 +57,10 @@ int pakfire_json_to_file(const char* path, id_t owner, gid_t group, mode_t mode,
        return pakfire_file_write(path, owner, group, mode, "%s\n", payload);
 }
 
-int pakfire_json_parse(struct json_object** json, char** error,
+int pakfire_json_parse(json_object** json, char** error,
                const char* buffer, const size_t length) {
        struct json_tokener* tokener = NULL;
-       struct json_object* object = NULL;
+       json_object* object = NULL;
        enum json_tokener_error e;
        int r;
 
@@ -98,7 +98,7 @@ ERROR:
        return r;
 }
 
-static int pakfire_json_parse_file(struct json_object** json, char** error, FILE* f) {
+static int pakfire_json_parse_file(json_object** json, char** error, FILE* f) {
        char* buffer = NULL;
        size_t length = 0;
        int r;
@@ -118,7 +118,7 @@ ERROR:
        return r;
 }
 
-int pakfire_json_parse_from_file(struct json_object** json, char** error, const char* path) {
+int pakfire_json_parse_from_file(json_object** json, char** error, const char* path) {
        FILE* f = NULL;
        int r;
 
@@ -141,7 +141,7 @@ ERROR:
        return r;
 }
 
-int pakfire_json_new_object(struct json_object** json) {
+int pakfire_json_new_object(json_object** json) {
        // Make a new object
        *json = json_object_new_object();
 
@@ -152,11 +152,11 @@ int pakfire_json_new_object(struct json_object** json) {
        return 0;
 }
 
-int pakfire_json_add_null(struct json_object* json, const char* name) {
+int pakfire_json_add_null(json_object* json, const char* name) {
        return json_object_object_add(json, name, NULL);
 }
 
-int pakfire_json_add_string(struct json_object* json,
+int pakfire_json_add_string(json_object* json,
                const char* name, const char* value) {
        if (!value)
                return 0;
@@ -164,14 +164,14 @@ int pakfire_json_add_string(struct json_object* json,
        return pakfire_json_add_stringn(json, name, value, strlen(value));
 }
 
-int pakfire_json_add_stringn(struct json_object* json,
+int pakfire_json_add_stringn(json_object* json,
                const char* name, const char* value, size_t length) {
        // No string? Nothing to do
        if (!value)
                return 0;
 
        // Convert string to JSON object
-       struct json_object* object = json_object_new_string_len(value, length);
+       json_object* object = json_object_new_string_len(value, length);
        if (!object)
                return 1;
 
@@ -179,7 +179,7 @@ int pakfire_json_add_stringn(struct json_object* json,
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_stringf(struct json_object* json,
+int pakfire_json_add_stringf(json_object* json,
                const char* name, const char* format, ...) {
        char* buffer = NULL;
        va_list args;
@@ -201,11 +201,11 @@ int pakfire_json_add_stringf(struct json_object* json,
        return r;
 }
 
-int pakfire_json_add_string_array(struct json_object* json, const char* name, char** array) {
+int pakfire_json_add_string_array(json_object* json, const char* name, char** array) {
        int r = 1;
 
        // Allocate a new array
-       struct json_object* object = json_object_new_array();
+       json_object* object = json_object_new_array();
        if (!object)
                goto ERROR;
 
@@ -229,7 +229,7 @@ ERROR:
        return r;
 }
 
-int pakfire_json_add_bytes(struct json_object* json,
+int pakfire_json_add_bytes(json_object* json,
                const char* name, const char* data, size_t length) {
        char* bytes = NULL;
        int r;
@@ -255,9 +255,9 @@ ERROR:
        return r;
 }
 
-int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t value) {
+int pakfire_json_add_int64(json_object* json, const char* name, int64_t value) {
        // Convert integer to JSON object
-       struct json_object* object = json_object_new_int64(value);
+       json_object* object = json_object_new_int64(value);
        if (!object)
                return -errno;
 
@@ -265,8 +265,8 @@ int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t v
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_uint64(struct json_object* json, const char* name, uint64_t value) {
-       struct json_object* object = NULL;
+int pakfire_json_add_uint64(json_object* json, const char* name, uint64_t value) {
+       json_object* object = NULL;
 
        // Convert the value to JSON
        object = json_object_new_uint64(value);
@@ -277,8 +277,8 @@ int pakfire_json_add_uint64(struct json_object* json, const char* name, uint64_t
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_double(struct json_object* json, const char* name, double value) {
-       struct json_object* object = NULL;
+int pakfire_json_add_double(json_object* json, const char* name, double value) {
+       json_object* object = NULL;
 
        // Convert the value to JSON
        object = json_object_new_double(value);
@@ -289,8 +289,8 @@ int pakfire_json_add_double(struct json_object* json, const char* name, double v
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_boolean(struct json_object* json, const char* name, int value) {
-       struct json_object* object = NULL;
+int pakfire_json_add_boolean(json_object* json, const char* name, int value) {
+       json_object* object = NULL;
 
        // Make a new boolean value
        object = json_object_new_boolean(value);
@@ -301,8 +301,8 @@ int pakfire_json_add_boolean(struct json_object* json, const char* name, int val
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_object(struct json_object* json, const char* name, struct json_object** o) {
-       struct json_object* object = NULL;
+int pakfire_json_add_object(json_object* json, const char* name, json_object** o) {
+       json_object* object = NULL;
 
        // Make a new object
        object = json_object_new_object();
@@ -317,8 +317,8 @@ int pakfire_json_add_object(struct json_object* json, const char* name, struct j
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_add_array(struct json_object* json, const char* name, struct json_object** array) {
-       struct json_object* object = NULL;
+int pakfire_json_add_array(json_object* json, const char* name, json_object** array) {
+       json_object* object = NULL;
 
        // Make a new array
        object = json_object_new_array();
@@ -333,16 +333,16 @@ int pakfire_json_add_array(struct json_object* json, const char* name, struct js
        return json_object_object_add(json, name, object);
 }
 
-int pakfire_json_array_add_string(struct json_object* array, const char* s) {
+int pakfire_json_array_add_string(json_object* array, const char* s) {
        // Make a new string object
-       struct json_object* object = json_object_new_string_len(s, strlen(s));
+       json_object* object = json_object_new_string_len(s, strlen(s));
        if (!object)
                return -errno;
 
        return json_object_array_add(array, object);
 }
 
-int pakfire_json_array_add_stringf(struct json_object* array, const char* format, ...) {
+int pakfire_json_array_add_stringf(json_object* array, const char* format, ...) {
        char* buffer = NULL;
        va_list args;
        int r;
@@ -363,9 +363,9 @@ int pakfire_json_array_add_stringf(struct json_object* array, const char* format
        return r;
 }
 
-static int __pakfire_json_get_object(struct json_object* json,
-               const char* key, const json_type type, struct json_object** o) {
-       struct json_object* object = NULL;
+static int __pakfire_json_get_object(json_object* json,
+               const char* key, const json_type type, json_object** o) {
+       json_object* object = NULL;
        int r;
 
        // Fetch the object
@@ -384,8 +384,8 @@ static int __pakfire_json_get_object(struct json_object* json,
        return 0;
 }
 
-int pakfire_json_get_string(struct json_object* json, const char* key, const char** value) {
-       struct json_object* object = NULL;
+int pakfire_json_get_string(json_object* json, const char* key, const char** value) {
+       json_object* object = NULL;
        int r;
 
        // Fetch the object
@@ -399,8 +399,8 @@ int pakfire_json_get_string(struct json_object* json, const char* key, const cha
        return 0;
 }
 
-int pakfire_json_get_int64(struct json_object* json, const char* key, int64_t* value) {
-       struct json_object* object = NULL;
+int pakfire_json_get_int64(json_object* json, const char* key, int64_t* value) {
+       json_object* object = NULL;
        int r;
 
        // Fetch the object
@@ -414,15 +414,15 @@ int pakfire_json_get_int64(struct json_object* json, const char* key, int64_t* v
        return 0;
 }
 
-int pakfire_json_get_object(struct json_object* json, const char* key, struct json_object** object) {
+int pakfire_json_get_object(json_object* json, const char* key, json_object** object) {
        return __pakfire_json_get_object(json, key, json_type_object, object);
 }
 
-int pakfire_json_get_array(struct json_object* json, const char* key, struct json_object** array) {
+int pakfire_json_get_array(json_object* json, const char* key, json_object** array) {
        return __pakfire_json_get_object(json, key, json_type_array, array);
 }
 
-int pakfire_json_write(struct json_object* json, const char* path) {
+int pakfire_json_write(json_object* json, const char* path) {
        FILE* f = NULL;
        int r;
 
index 1d4403db185d88ba97362518c0dc09fc91f041f7..2aa9caf7acdf509bbd06c5fdd11c79549a477bcb 100644 (file)
 #include <pakfire/ctx.h>
 
 // To String
-const char* pakfire_json_to_string(struct json_object* json, size_t* length);
+const char* pakfire_json_to_string(json_object* json, size_t* length);
 
 // To File
 int pakfire_json_to_file(const char* path, id_t owner, gid_t group, mode_t mode,
-       struct json_object* json);
+       json_object* json);
 
 // Parse
-int pakfire_json_parse(struct json_object** json, char** error,
+int pakfire_json_parse(json_object** json, char** error,
        const char* buffer, const size_t length);
 
 // Parse from file
-int pakfire_json_parse_from_file(struct json_object** json, char** error, const char* path);
+int pakfire_json_parse_from_file(json_object** json, char** error, const char* path);
 
-int pakfire_json_new_object(struct json_object** json);
+int pakfire_json_new_object(json_object** json);
 
-int pakfire_json_add_null(struct json_object* json, const char* name);
-int pakfire_json_add_string(struct json_object* json, const char* name, const char* value);
-int pakfire_json_add_stringn(struct json_object* json, const char* name, const char* value, size_t length);
-int pakfire_json_add_stringf(struct json_object* json, const char* name, const char* format, ...)
+int pakfire_json_add_null(json_object* json, const char* name);
+int pakfire_json_add_string(json_object* json, const char* name, const char* value);
+int pakfire_json_add_stringn(json_object* json, const char* name, const char* value, size_t length);
+int pakfire_json_add_stringf(json_object* json, const char* name, const char* format, ...)
        __attribute__((format(printf, 3, 4)));
-int pakfire_json_add_bytes(struct json_object* json, const char* name, const char* data, size_t length);
-int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t value);
-int pakfire_json_add_uint64(struct json_object* json, const char* name, uint64_t value);
-int pakfire_json_add_double(struct json_object* json, const char* name, double value);
-int pakfire_json_add_boolean(struct json_object* json, const char* name, int value);
-int pakfire_json_add_string_array(struct json_object* json, const char* name, char** array);
-int pakfire_json_add_object(struct json_object* json, const char* name, struct json_object** o);
-int pakfire_json_add_array(struct json_object* json, const char* name, struct json_object** array);
+int pakfire_json_add_bytes(json_object* json, const char* name, const char* data, size_t length);
+int pakfire_json_add_int64(json_object* json, const char* name, int64_t value);
+int pakfire_json_add_uint64(json_object* json, const char* name, uint64_t value);
+int pakfire_json_add_double(json_object* json, const char* name, double value);
+int pakfire_json_add_boolean(json_object* json, const char* name, int value);
+int pakfire_json_add_string_array(json_object* json, const char* name, char** array);
+int pakfire_json_add_object(json_object* json, const char* name, json_object** o);
+int pakfire_json_add_array(json_object* json, const char* name, json_object** array);
 
-int pakfire_json_array_add_string(struct json_object* array, const char* s);
-int pakfire_json_array_add_stringf(struct json_object* array, const char* format, ...)
+int pakfire_json_array_add_string(json_object* array, const char* s);
+int pakfire_json_array_add_stringf(json_object* array, const char* format, ...)
        __attribute__((format(printf, 2, 3)));
 
-int pakfire_json_get_string(struct json_object* json, const char* key, const char** value);
-int pakfire_json_get_int64(struct json_object* json, const char* key, int64_t* value);
-int pakfire_json_get_object(struct json_object* json, const char* key, struct json_object** object);
-int pakfire_json_get_array(struct json_object* json, const char* key, struct json_object** array);
+int pakfire_json_get_string(json_object* json, const char* key, const char** value);
+int pakfire_json_get_int64(json_object* json, const char* key, int64_t* value);
+int pakfire_json_get_object(json_object* json, const char* key, json_object** object);
+int pakfire_json_get_array(json_object* json, const char* key, json_object** array);
 
-int pakfire_json_write(struct json_object* json, const char* path);
+int pakfire_json_write(json_object* json, const char* path);
 
 #endif /* PAKFIRE_JSON_H */
index f71d03215f633c747d2ecbb75344ff1a77bfb448..7624d3fb64f2deca5691f78d4f6fb1f6c023ea17 100644 (file)
@@ -87,7 +87,7 @@ ERROR:
        return r;
 }
 
-int pakfire_jwt_payload(const char* token, struct json_object** payload) {
+int pakfire_jwt_payload(const char* token, json_object** payload) {
        char* p = NULL;
        size_t l = 0;
        int r;
@@ -110,7 +110,7 @@ ERROR:
 }
 
 time_t pakfire_jwt_expires_at(const char* token) {
-       struct json_object* payload = NULL;
+       json_object* payload = NULL;
        time_t expires_at = -1;
        int r;
 
index ab92af25398edcae07972c5403a817522932c336..f7d3fb2f236c5bdc3c211eca50d5ced8c4230934 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <json.h>
 
-int pakfire_jwt_payload(const char* token, struct json_object** payload);
+int pakfire_jwt_payload(const char* token, json_object** payload);
 
 time_t pakfire_jwt_expires_at(const char* token);
 int pakfire_jwt_has_expired(const char* token);
index 1cdcc503dc8f5dddbb8871bf278fc4b5a52e9188..2415da5921f3c9287ce386267fc5d14ee2eedb02 100644 (file)
@@ -93,8 +93,8 @@ pakfire_mirrorlist* pakfire_mirrorlist_unref(pakfire_mirrorlist* list) {
 }
 
 static int pakfire_mirrorlist_check_mirrorlist(pakfire_mirrorlist* list,
-               struct json_object* root) {
-       struct json_object* typeobj = NULL;
+               json_object* root) {
+       json_object* typeobj = NULL;
        int r;
 
        r = json_object_object_get_ex(root, "type", &typeobj);
@@ -140,7 +140,7 @@ ERROR:
 }
 
 int pakfire_mirrorlist_read(pakfire_mirrorlist* list, const char* path) {
-       struct json_object* json = NULL;
+       json_object* json = NULL;
        char* error = NULL;
        int r;
 
@@ -162,7 +162,7 @@ int pakfire_mirrorlist_read(pakfire_mirrorlist* list, const char* path) {
                return 1;
        }
 
-       struct json_object* mirrors = NULL;
+       json_object* mirrors = NULL;
 
        // Check if we found a valid mirrorlist
        r = pakfire_mirrorlist_check_mirrorlist(list, json);
@@ -183,12 +183,12 @@ int pakfire_mirrorlist_read(pakfire_mirrorlist* list, const char* path) {
        size_t num_mirrors = json_object_array_length(mirrors);
 
        for (unsigned int i = 0; i < num_mirrors; i++) {
-               struct json_object* mirror = json_object_array_get_idx(mirrors, i);
+               json_object* mirror = json_object_array_get_idx(mirrors, i);
                if (!mirror)
                        continue;
 
                // Find URL
-               struct json_object* urlobj;
+               json_object* urlobj;
                r = json_object_object_get_ex(mirror, "url", &urlobj);
                if (!r)
                        goto ERROR;
index 11891b8c9fda87a3b0e3e2f9ea13835d63957645..b950c5284629ca733924d373308759235c6d752d 100644 (file)
@@ -53,9 +53,9 @@ struct pakfire_oci_writer {
        char* diffid;
 
        // JSON Objects
-       struct json_object* config;
-       struct json_object* layers;
-       struct json_object* manifests;
+       json_object* config;
+       json_object* layers;
+       json_object* manifests;
 };
 
 static const char* pakfire_oci_arch(struct pakfire* pakfire) {
@@ -78,7 +78,7 @@ static const char* pakfire_oci_arch(struct pakfire* pakfire) {
 }
 
 static int pakfire_oci_writer_write_oci_layout(struct pakfire_oci_writer* self) {
-       struct json_object* o = NULL;
+       json_object* o = NULL;
        int r;
 
        // Make a new object
@@ -104,7 +104,7 @@ ERROR:
 }
 
 static int pakfire_oci_writer_write_json_blob(
-               struct pakfire_oci_writer* self, struct json_object* json, char** hexdigest, size_t* size) {
+               struct pakfire_oci_writer* self, json_object* json, char** hexdigest, size_t* size) {
        struct pakfire_hashes hashes = {};
        const char* buffer = NULL;
        char* hd = NULL;
@@ -156,7 +156,7 @@ ERROR:
 }
 
 static int pakfire_oci_writer_write_index(struct pakfire_oci_writer* self) {
-       struct json_object* o = NULL;
+       json_object* o = NULL;
        int r;
 
        // Make a new object
@@ -192,16 +192,16 @@ ERROR:
 }
 
 static int pakfire_oci_writer_write_config(struct pakfire_oci_writer* self) {
-       struct json_object* o = NULL;
+       json_object* o = NULL;
        char* hexdigest = NULL;
        char created[64];
        size_t size = 0;
        int r;
 
-       struct json_object* config = NULL;
-       struct json_object* cmd = NULL;
-       struct json_object* rootfs = NULL;
-       struct json_object* diffids = NULL;
+       json_object* config = NULL;
+       json_object* cmd = NULL;
+       json_object* rootfs = NULL;
+       json_object* diffids = NULL;
 
        // Make a new object
        r = pakfire_json_new_object(&o);
@@ -324,9 +324,9 @@ ERROR:
 }
 
 static int pakfire_oci_writer_write_manifest(struct pakfire_oci_writer* self) {
-       struct json_object* manifest = NULL;
-       struct json_object* platform = NULL;
-       struct json_object* o = NULL;
+       json_object* manifest = NULL;
+       json_object* platform = NULL;
+       json_object* o = NULL;
        char* hexdigest = NULL;
        size_t size = 0;
        int r;
@@ -422,7 +422,7 @@ static int pakfire_oci_writer_make_layer(struct pakfire_oci_writer* self) {
        char path[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-oci-layer.XXXXXX";
        pakfire_archive_writer* layer = NULL;
        struct pakfire_hashes hashes = {};
-       struct json_object* json = NULL;
+       json_object* json = NULL;
        char filename[PATH_MAX];
        char* hexdigest = NULL;
        FILE* f = NULL;
index 6dde985218ce7b1115122bb1e693d58a966e21a4..68025e46687e102b9d3a5fd1dac3e9500c8a6f05 100644 (file)
@@ -2334,7 +2334,7 @@ ERROR:
 
 static int _pakfire_package_add_json_dependencies(
                pakfire_package* pkg,
-               struct json_object* json,
+               json_object* json,
                const char* name,
                const enum pakfire_package_key key) {
        int r;
@@ -2357,11 +2357,11 @@ ERROR:
 }
 
 static int pakfire_package_add_json_dependencies(
-               pakfire_package* pkg, struct json_object* md) {
+               pakfire_package* pkg, json_object* md) {
        int r = 0;
 
        // Create new dependencies object
-       struct json_object* object = json_object_new_object();
+       json_object* object = json_object_new_object();
        if (!object)
                return -errno;
 
@@ -2433,14 +2433,14 @@ ERROR:
 
 static int __pakfire_package_add_json_filelist(
                pakfire_ctx* ctx, pakfire_file* file, void* data) {
-       struct json_object* filelist = data;
+       json_object* filelist = data;
        int r;
 
        // Fetch the file path
        const char* path = pakfire_file_get_path(file);
 
        // Create a new JSON string
-       struct json_object* object = json_object_new_string(path);
+       json_object* object = json_object_new_string(path);
        if (!object) {
                r = -errno;
                goto ERROR;
@@ -2462,9 +2462,9 @@ ERROR:
 }
 
 static int pakfire_package_add_json_filelist(
-               pakfire_package* pkg, struct json_object* md) {
+               pakfire_package* pkg, json_object* md) {
        pakfire_filelist* filelist = NULL;
-       struct json_object* object = NULL;
+       json_object* object = NULL;
        int r;
 
        // Fetch the filelist
@@ -2506,7 +2506,7 @@ ERROR:
 
 static int __pakfire_package_add_build_packages(pakfire_ctx* ctx,
                pakfire_package* pkg, void* p) {
-       struct json_object* object = (struct json_object*)p;
+       json_object* object = (json_object*)p;
        int r;
 
        const char* name = pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME);
@@ -2528,9 +2528,9 @@ static int __pakfire_package_add_build_packages(pakfire_ctx* ctx,
 }
 
 static int pakfire_package_add_build_packages(pakfire_package* pkg,
-               struct json_object* md) {
+               json_object* md) {
        pakfire_repo* repo = NULL;
-       struct json_object* object = NULL;
+       json_object* object = NULL;
        int r;
 
        // Create a new JSON array
@@ -2569,11 +2569,11 @@ ERROR:
 }
 
 static int pakfire_package_add_build_metadata(pakfire_package* pkg,
-               struct json_object* md) {
+               json_object* md) {
        int r;
 
        // Create a new JSON object
-       struct json_object* object = json_object_new_object();
+       json_object* object = json_object_new_object();
        if (!object)
                return -errno;
 
@@ -2661,8 +2661,8 @@ ERROR:
        return r;
 }
 
-int pakfire_package_to_json(pakfire_package* pkg, struct json_object** json) {
-       struct json_object* md = NULL;
+int pakfire_package_to_json(pakfire_package* pkg, json_object** json) {
+       json_object* md = NULL;
        int r = 0;
 
        // Allocate a new JSON object
index 1e0f5cc595ef82a1c7e68d585d20af99acb9e4d5..c45608854e69fb567842b85ca4008f601cbab143 100644 (file)
@@ -189,6 +189,6 @@ int pakfire_package_has_rich_deps(pakfire_package* pkg);
 int pakfire_package_matches_dep(pakfire_package* pkg,
        const enum pakfire_package_key key, const char* dep);
 
-int pakfire_package_to_json(pakfire_package* pkg, struct json_object** json);
+int pakfire_package_to_json(pakfire_package* pkg, json_object** json);
 
 #endif /* PAKFIRE_PACKAGE_H */
index 5fe962fc0a231a44d76af565a73eac6234fbf3ec..e1ae7f47d494b465b349b6aa9be02d173c19cbec 100644 (file)
@@ -246,7 +246,7 @@ static int pakfire_packager_write_format(pakfire_packager* packager,
 
 static int pakfire_packager_write_metadata(pakfire_packager* packager,
                pakfire_archive_writer* writer) {
-       struct json_object* md = NULL;
+       json_object* md = NULL;
        int r;
 
        // Convert all package metadata to JSON
index 64da9b29093dec88081189acabc6887675e4bfc6..73e49299652699eb2bbc5c2d2020e2d114ceea54 100644 (file)
@@ -949,10 +949,10 @@ static void pakfire_repo_reset_metadata(pakfire_repo* self) {
 }
 
 static int pakfire_repo_parse_repomd(pakfire_repo* self,
-               pakfire_repomd* repomd, struct json_object* root) {
-       struct json_object* files = NULL;
-       struct json_object* file = NULL;
-       struct json_object* chksums = NULL;
+               pakfire_repomd* repomd, json_object* root) {
+       json_object* files = NULL;
+       json_object* file = NULL;
+       json_object* chksums = NULL;
        const char* type = NULL;
        const char* filename = NULL;
        ssize_t size = 0;
@@ -1054,7 +1054,7 @@ ERROR:
 }
 
 static int pakfire_repo_read_metadata(pakfire_repo* repo, const char* path) {
-       struct json_object* json = NULL;
+       json_object* json = NULL;
        char* error = NULL;
        int r;
 
@@ -1263,7 +1263,7 @@ static int pakfire_repo_download_metadata(pakfire_repo* repo, const char* path,
        pakfire_repomd repomd = {};
        pakfire_buffer buffer = {};
        pakfire_xfer* xfer = NULL;
-       struct json_object* json = NULL;
+       json_object* json = NULL;
        char* error = NULL;
        int r;
 
@@ -2267,12 +2267,12 @@ static int pakfire_repo_cleanup_metadata(pakfire_repo* self) {
 }
 
 static int pakfire_repo_metadata_add_file(pakfire_repo* self,
-               struct json_object* repomd, const char* type, const char* path) {
+               json_object* repomd, const char* type, const char* path) {
        enum pakfire_hash_type hash = PAKFIRE_HASH_UNDEFINED;
        struct pakfire_hashes checksums = {};
-       struct json_object* files = NULL;
-       struct json_object* file = NULL;
-       struct json_object* chksums = NULL;
+       json_object* files = NULL;
+       json_object* file = NULL;
+       json_object* chksums = NULL;
        char filename[PATH_MAX];
        char* hexdigest = NULL;
        struct stat st = {};
@@ -2366,7 +2366,7 @@ ERROR:
        return r;
 }
 
-static int pakfire_repo_write_database(pakfire_repo* self, struct json_object* repomd) {
+static int pakfire_repo_write_database(pakfire_repo* self, json_object* repomd) {
        char filename[PATH_MAX];
        char path[PATH_MAX];
        char tmp[PATH_MAX];
@@ -2439,7 +2439,7 @@ ERROR:
        return r;
 }
 
-static int pakfire_repo_make_metadata(pakfire_repo* self, struct json_object* md) {
+static int pakfire_repo_make_metadata(pakfire_repo* self, json_object* md) {
        int r;
 
        // Set the version
@@ -2463,7 +2463,7 @@ static int pakfire_repo_make_metadata(pakfire_repo* self, struct json_object* md
 }
 
 int pakfire_repo_write_metadata(pakfire_repo* self, pakfire_key* key) {
-       struct json_object* repomd = NULL;
+       json_object* repomd = NULL;
        char repomd_path[PATH_MAX];
        char sigpath[PATH_MAX];
        FILE* f = NULL;
index c8a80d722cf6438c07f56158e4781d8558d190fd..d0ea0a800fbfaa2de045ac896b6c3551e35de9c7 100644 (file)
@@ -651,7 +651,7 @@ int pakfire_xfer_set_payload(pakfire_xfer* self, const char* payload) {
        return 0;
 }
 
-int pakfire_xfer_set_json_payload(pakfire_xfer* self, struct json_object* json) {
+int pakfire_xfer_set_json_payload(pakfire_xfer* self, json_object* json) {
        const char* s = NULL;
        int r;
 
index 8c411ef8ee6e20143d12ec84b11bd2fd5a194a72..9c67b1222a71c2436973714f24628d377d535fab 100644 (file)
@@ -131,7 +131,7 @@ int pakfire_xfer_add_query(pakfire_xfer* xfer,
 
 // Payload
 int pakfire_xfer_set_payload(pakfire_xfer* self, const char* payload);
-int pakfire_xfer_set_json_payload(pakfire_xfer* self, struct json_object* json);
+int pakfire_xfer_set_json_payload(pakfire_xfer* self, json_object* json);
 
 // Output
 int pakfire_xfer_set_output(pakfire_xfer* xfer, FILE* f);
index 7cd8d88ba9cbbebf69a182644cf7648ea035c870..e74d6b5d956c9afc94241555c57f038558d0074a 100644 (file)
@@ -35,7 +35,7 @@ const char* ACCESS_TOKEN =
 const char* INVALID_TOKEN = "THISISANINVALIDTOKEN";
 
 static int test_payload(const struct test* t) {
-       struct json_object* payload = NULL;
+       json_object* payload = NULL;
        int r = EXIT_FAILURE;
 
        // Try to decode an invalid token