static int qemu_rbd_parsename(const char *filename,

                              char *pool, int pool_len,

                              char *snap, int snap_len,

                              char *name, int name_len,

                              char *conf, int conf_len,

                              Error **errp)

{

    const char *start;

    char *p, *buf;

    int ret = 0;

    char *found_str;

    Error *local_err = NULL;



    if (!strstart(filename, "rbd:", &start)) {

        error_setg(errp, "File name must start with 'rbd:'");

        return -EINVAL;

    }



    buf = g_strdup(start);

    p = buf;

    *snap = '\0';

    *conf = '\0';



    found_str = qemu_rbd_next_tok(pool_len, p,

                                  '/', "pool name", &p, &local_err);

    if (local_err) {

        goto done;

    }

    if (!p) {

        ret = -EINVAL;

        error_setg(errp, "Pool name is required");

        goto done;

    }

    qemu_rbd_unescape(found_str);

    g_strlcpy(pool, found_str, pool_len);



    if (strchr(p, '@')) {

        found_str = qemu_rbd_next_tok(name_len, p,

                                      '@', "object name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(name, found_str, name_len);



        found_str = qemu_rbd_next_tok(snap_len, p,

                                      ':', "snap name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(snap, found_str, snap_len);

    } else {

        found_str = qemu_rbd_next_tok(name_len, p,

                                      ':', "object name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(name, found_str, name_len);

    }

    if (!p) {

        goto done;

    }



    found_str = qemu_rbd_next_tok(conf_len, p,

                                  '\0', "configuration", &p, &local_err);

    if (local_err) {

        goto done;

    }

    g_strlcpy(conf, found_str, conf_len);



done:

    if (local_err) {

        ret = -EINVAL;

        error_propagate(errp, local_err);

    }

    g_free(buf);

    return ret;

}

static int qemu_rbd_parsename(const char *filename,

                              char *pool, int pool_len,

                              char *snap, int snap_len,

                              char *name, int name_len,

                              char *conf, int conf_len,

                              Error **errp)

{

    const char *start;

    char *p, *buf;

    int ret = 0;

    char *found_str;

    Error *local_err = NULL;



    if (!strstart(filename, "rbd:", &start)) {

        error_setg(errp, "File name must start with 'rbd:'");

        return -EINVAL;

    }



    buf = g_strdup(start);

    p = buf;

    *snap = '\0';

    *conf = '\0';



    found_str = qemu_rbd_next_tok(pool_len, p,

                                  '/', "pool name", &p, &local_err);

    if (local_err) {

        goto done;

    }

    if (!p) {

        ret = -EINVAL;

        error_setg(errp, "Pool name is required");

        goto done;

    }

    qemu_rbd_unescape(found_str);

    g_strlcpy(pool, found_str, pool_len);



    if (strchr(p, '@')) {

        found_str = qemu_rbd_next_tok(name_len, p,

                                      '@', "object name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(name, found_str, name_len);



        found_str = qemu_rbd_next_tok(snap_len, p,

                                      ':', "snap name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(snap, found_str, snap_len);

    } else {

        found_str = qemu_rbd_next_tok(name_len, p,

                                      ':', "object name", &p, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(found_str);

        g_strlcpy(name, found_str, name_len);

    }

    if (!p) {

        goto done;

    }



    found_str = qemu_rbd_next_tok(conf_len, p,

                                  '\0', "configuration", &p, &local_err);

    if (local_err) {

        goto done;

    }

    g_strlcpy(conf, found_str, conf_len);



done:

    if (local_err) {

        ret = -EINVAL;

        error_propagate(errp, local_err);

    }

    g_free(buf);

    return ret;

}

static int FUNC_0(const char *VAR_0,

                              char *VAR_1, int VAR_2,

                              char *VAR_3, int VAR_4,

                              char *VAR_5, int VAR_6,

                              char *VAR_7, int VAR_8,

                              Error **VAR_9)

{

    const char *VAR_10;

    char *VAR_11, *VAR_12;

    int VAR_13 = 0;

    char *VAR_14;

    Error *local_err = NULL;



    if (!strstart(VAR_0, "rbd:", &VAR_10)) {

        error_setg(VAR_9, "File VAR_5 must VAR_10 with 'rbd:'");

        return -EINVAL;

    }



    VAR_12 = g_strdup(VAR_10);

    VAR_11 = VAR_12;

    *VAR_3 = '\0';

    *VAR_7 = '\0';



    VAR_14 = qemu_rbd_next_tok(VAR_2, VAR_11,

                                  '/', "VAR_1 VAR_5", &VAR_11, &local_err);

    if (local_err) {

        goto done;

    }

    if (!VAR_11) {

        VAR_13 = -EINVAL;

        error_setg(VAR_9, "Pool VAR_5 is required");

        goto done;

    }

    qemu_rbd_unescape(VAR_14);

    g_strlcpy(VAR_1, VAR_14, VAR_2);



    if (strchr(VAR_11, '@')) {

        VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,

                                      '@', "object VAR_5", &VAR_11, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(VAR_14);

        g_strlcpy(VAR_5, VAR_14, VAR_6);



        VAR_14 = qemu_rbd_next_tok(VAR_4, VAR_11,

                                      ':', "VAR_3 VAR_5", &VAR_11, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(VAR_14);

        g_strlcpy(VAR_3, VAR_14, VAR_4);

    } else {

        VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,

                                      ':', "object VAR_5", &VAR_11, &local_err);

        if (local_err) {

            goto done;

        }

        qemu_rbd_unescape(VAR_14);

        g_strlcpy(VAR_5, VAR_14, VAR_6);

    }

    if (!VAR_11) {

        goto done;

    }



    VAR_14 = qemu_rbd_next_tok(VAR_8, VAR_11,

                                  '\0', "configuration", &VAR_11, &local_err);

    if (local_err) {

        goto done;

    }

    g_strlcpy(VAR_7, VAR_14, VAR_8);



done:

    if (local_err) {

        VAR_13 = -EINVAL;

        error_propagate(VAR_9, local_err);

    }

    g_free(VAR_12);

    return VAR_13;

}

static int FUNC_0(const char *VAR_0,
char *VAR_1, int VAR_2,
char *VAR_3, int VAR_4,
char *VAR_5, int VAR_6,
char *VAR_7, int VAR_8,
Error **VAR_9)
{ const char *VAR_10; char *VAR_11, *VAR_12; int VAR_13 = 0; char *VAR_14; Error *local_err = NULL; if (!strstart(VAR_0, "rbd:", &VAR_10)) { error_setg(VAR_9, "File VAR_5 must VAR_10 with 'rbd:'"); return -EINVAL; } VAR_12 = g_strdup(VAR_10); VAR_11 = VAR_12; *VAR_3 = '\0'; *VAR_7 = '\0'; VAR_14 = qemu_rbd_next_tok(VAR_2, VAR_11,
'/', "VAR_1 VAR_5", &VAR_11, &local_err); if (local_err) { goto done; } if (!VAR_11) { VAR_13 = -EINVAL; error_setg(VAR_9, "Pool VAR_5 is required"); goto done; } qemu_rbd_unescape(VAR_14); g_strlcpy(VAR_1, VAR_14, VAR_2); if (strchr(VAR_11, '@')) { VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,
'@', "object VAR_5", &VAR_11, &local_err); if (local_err) { goto done; } qemu_rbd_unescape(VAR_14); g_strlcpy(VAR_5, VAR_14, VAR_6); VAR_14 = qemu_rbd_next_tok(VAR_4, VAR_11,
':', "VAR_3 VAR_5", &VAR_11, &local_err); if (local_err) { goto done; } qemu_rbd_unescape(VAR_14); g_strlcpy(VAR_3, VAR_14, VAR_4); } else { VAR_14 = qemu_rbd_next_tok(VAR_6, VAR_11,
':', "object VAR_5", &VAR_11, &local_err); if (local_err) { goto done; } qemu_rbd_unescape(VAR_14); g_strlcpy(VAR_5, VAR_14, VAR_6); } if (!VAR_11) { goto done; } VAR_14 = qemu_rbd_next_tok(VAR_8, VAR_11,
'\0', "configuration", &VAR_11, &local_err); if (local_err) { goto done; } g_strlcpy(VAR_7, VAR_14, VAR_8); done:
if (local_err) { VAR_13 = -EINVAL; error_propagate(VAR_9, local_err); } g_free(VAR_12); return VAR_13; }