return r;
}
-static int pakfire_client_api_response_string(struct pakfire_client* self,
- struct json_object* response, const char* key, char** value) {
- struct json_object* object = NULL;
- const char* s = NULL;
- char* buffer = NULL;
- int r;
-
- // Fetch the object at key
- r = json_object_object_get_ex(response, key, &object);
- if (r == 0) {
- ERROR(self->ctx, "Could not fetch '%s' from response\n", key);
- r = -EBADMSG;
- goto ERROR;
- }
-
- // Read the string
- s = json_object_get_string(object);
- if (!s) {
- ERROR(self->ctx, "Could not fetch value from '%s'\n", key);
- r = -EBADMSG;
- goto ERROR;
- }
-
- // Copy the value
- buffer = strdup(s);
- if (!buffer) {
- ERROR(self->ctx, "Could not copy the string: %m\n");
- r = -errno;
- goto ERROR;
- }
-
- // Return the value
- *value = buffer;
- return 0;
-
-ERROR:
- if (buffer)
- free(buffer);
-
- return r;
-}
-
// Uploads
static void pakfire_client_upload_free(struct pakfire_client_upload* upload) {