#include <pakfire/logging.h>
#include <pakfire/mirror.h>
#include <pakfire/mirrorlist.h>
+#include <pakfire/string.h>
#include <pakfire/util.h>
struct pakfire_mirrorlist {
static int pakfire_mirrorlist_check_mirrorlist(struct pakfire_mirrorlist* list,
struct json_object* root) {
struct json_object* typeobj = NULL;
- int r = 1;
+ int r;
r = json_object_object_get_ex(root, "type", &typeobj);
if (!r) {
ERROR(list->ctx, "mirrorlist does not have a 'type' attribute\n");
- goto ERROR;
+ return -EBADMSG;
}
const char* type = json_object_get_string(typeobj);
if (!type) {
ERROR(list->ctx, "mirrorlist has an empty or unknown 'type' attribute\n");
- goto ERROR;
+ return -EBADMSG;
}
- if (strcmp(type, "mirrorlist") != 0) {
+ if (!pakfire_string_equals(type, "mirrorlist")) {
ERROR(list->ctx, "Unexpected type: %s\n", type);
- goto ERROR;
+ return -EBADMSG;
}
- // Success
- r = 0;
-
-ERROR:
- if (typeobj)
- json_object_put(typeobj);
-
- return r;
+ return 0;
}
static int pakfire_mirrorlist_add_mirror_from_url(