From: Michael Tremer Date: Fri, 27 Jun 2025 15:14:01 +0000 (+0000) Subject: json: Use "json_object" instead of "struct json_object" X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=16b8708f4a96d0c04eb98e04035c897a888959dd;p=pakfire.git json: Use "json_object" instead of "struct json_object" Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/dump.c b/src/cli/lib/dump.c index 419b2545..476f4c77 100644 --- a/src/cli/lib/dump.c +++ b/src/cli/lib/dump.c @@ -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 diff --git a/src/cli/lib/dump.h b/src/cli/lib/dump.h index 606c6333..30bd2d91 100644 --- a/src/cli/lib/dump.h +++ b/src/cli/lib/dump.h @@ -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 */ diff --git a/src/pakfire/archive.c b/src/pakfire/archive.c index e6ae6786..3eaeb234 100644 --- a/src/pakfire/archive.c +++ b/src/pakfire/archive.c @@ -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; diff --git a/src/pakfire/archive_writer.c b/src/pakfire/archive_writer.c index 95e4a9a7..a9685d19 100644 --- a/src/pakfire/archive_writer.c +++ b/src/pakfire/archive_writer.c @@ -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; diff --git a/src/pakfire/archive_writer.h b/src/pakfire/archive_writer.h index 36268968..8d25c25a 100644 --- a/src/pakfire/archive_writer.h +++ b/src/pakfire/archive_writer.h @@ -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); diff --git a/src/pakfire/builder.c b/src/pakfire/builder.c index 3d7d0ea8..7a5fd1da 100644 --- a/src/pakfire/builder.c +++ b/src/pakfire/builder.c @@ -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; diff --git a/src/pakfire/builder.h b/src/pakfire/builder.h index 672ee797..45e239d1 100644 --- a/src/pakfire/builder.h +++ b/src/pakfire/builder.h @@ -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 diff --git a/src/pakfire/client.c b/src/pakfire/client.c index 81761d51..f4c7aca1 100644 --- a/src/pakfire/client.c +++ b/src/pakfire/client.c @@ -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; diff --git a/src/pakfire/job.c b/src/pakfire/job.c index 43fb96c6..43844344 100644 --- a/src/pakfire/job.c +++ b/src/pakfire/job.c @@ -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; diff --git a/src/pakfire/job.h b/src/pakfire/job.h index 3cfc844e..00e81ede 100644 --- a/src/pakfire/job.h +++ b/src/pakfire/job.h @@ -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 */ diff --git a/src/pakfire/json.c b/src/pakfire/json.c index de07927e..49cac69b 100644 --- a/src/pakfire/json.c +++ b/src/pakfire/json.c @@ -28,7 +28,7 @@ #include #include -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; diff --git a/src/pakfire/json.h b/src/pakfire/json.h index 1d4403db..2aa9caf7 100644 --- a/src/pakfire/json.h +++ b/src/pakfire/json.h @@ -28,44 +28,44 @@ #include // 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 */ diff --git a/src/pakfire/jwt.c b/src/pakfire/jwt.c index f71d0321..7624d3fb 100644 --- a/src/pakfire/jwt.c +++ b/src/pakfire/jwt.c @@ -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; diff --git a/src/pakfire/jwt.h b/src/pakfire/jwt.h index ab92af25..f7d3fb2f 100644 --- a/src/pakfire/jwt.h +++ b/src/pakfire/jwt.h @@ -23,7 +23,7 @@ #include -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); diff --git a/src/pakfire/mirrorlist.c b/src/pakfire/mirrorlist.c index 1cdcc503..2415da59 100644 --- a/src/pakfire/mirrorlist.c +++ b/src/pakfire/mirrorlist.c @@ -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; diff --git a/src/pakfire/oci.c b/src/pakfire/oci.c index 11891b8c..b950c528 100644 --- a/src/pakfire/oci.c +++ b/src/pakfire/oci.c @@ -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; diff --git a/src/pakfire/package.c b/src/pakfire/package.c index 6dde9852..68025e46 100644 --- a/src/pakfire/package.c +++ b/src/pakfire/package.c @@ -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 diff --git a/src/pakfire/package.h b/src/pakfire/package.h index 1e0f5cc5..c4560885 100644 --- a/src/pakfire/package.h +++ b/src/pakfire/package.h @@ -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 */ diff --git a/src/pakfire/packager.c b/src/pakfire/packager.c index 5fe962fc..e1ae7f47 100644 --- a/src/pakfire/packager.c +++ b/src/pakfire/packager.c @@ -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 diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index 64da9b29..73e49299 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -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; diff --git a/src/pakfire/xfer.c b/src/pakfire/xfer.c index c8a80d72..d0ea0a80 100644 --- a/src/pakfire/xfer.c +++ b/src/pakfire/xfer.c @@ -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; diff --git a/src/pakfire/xfer.h b/src/pakfire/xfer.h index 8c411ef8..9c67b122 100644 --- a/src/pakfire/xfer.h +++ b/src/pakfire/xfer.h @@ -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); diff --git a/tests/libpakfire/jwt.c b/tests/libpakfire/jwt.c index 7cd8d88b..e74d6b5d 100644 --- a/tests/libpakfire/jwt.c +++ b/tests/libpakfire/jwt.c @@ -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