static int parse_vdiname(BDRVSheepdogState *s, const char *filename,

                         char *vdi, uint32_t *snapid, char *tag)

{

    char *p, *q, *uri;

    const char *host_spec, *vdi_spec;

    int nr_sep, ret;



    strstart(filename, "sheepdog:", &filename);

    p = q = g_strdup(filename);



    /* count the number of separators */

    nr_sep = 0;

    while (*p) {

        if (*p == ':') {

            nr_sep++;

        }

        p++;

    }

    p = q;



    /* use the first two tokens as host_spec. */

    if (nr_sep >= 2) {

        host_spec = p;

        p = strchr(p, ':');

        p++;

        p = strchr(p, ':');

        *p++ = '\0';

    } else {

        host_spec = "";

    }



    vdi_spec = p;



    p = strchr(vdi_spec, ':');

    if (p) {

        *p++ = '#';

    }



    uri = g_strdup_printf("sheepdog://%s/%s", host_spec, vdi_spec);



    ret = sd_parse_uri(s, uri, vdi, snapid, tag);



    g_free(q);

    g_free(uri);



    return ret;

}

static int parse_vdiname(BDRVSheepdogState *s, const char *filename,

                         char *vdi, uint32_t *snapid, char *tag)

{

    char *p, *q, *uri;

    const char *host_spec, *vdi_spec;

    int nr_sep, ret;



    strstart(filename, "sheepdog:", &filename);

    p = q = g_strdup(filename);



    

    nr_sep = 0;

    while (*p) {

        if (*p == ':') {

            nr_sep++;

        }

        p++;

    }

    p = q;



    

    if (nr_sep >= 2) {

        host_spec = p;

        p = strchr(p, ':');

        p++;

        p = strchr(p, ':');

        *p++ = '\0';

    } else {

        host_spec = "";

    }



    vdi_spec = p;



    p = strchr(vdi_spec, ':');

    if (p) {

        *p++ = '#';

    }



    uri = g_strdup_printf("sheepdog:



    ret = sd_parse_uri(s, uri, vdi, snapid, tag);



    g_free(q);

    g_free(uri);



    return ret;

}

    return ret; static int parse_vdiname(BDRVSheepdogState *s, const char *filename,                          char *vdi, uint32_t *snapid, char *tag)     int nr_sep, ret;     ret = sd_parse_uri(s, uri, vdi, snapid, tag);     return ret;
static int FUNC_0(BDRVSheepdogState *VAR_0, const char *VAR_1,

                         char *VAR_2, uint32_t *VAR_3, char *VAR_4)

{

    char *VAR_5, *VAR_6, *VAR_7;

    const char *VAR_8, *VAR_9;

    int VAR_10, VAR_11;



    strstart(VAR_1, "sheepdog:", &VAR_1);

    VAR_5 = VAR_6 = g_strdup(VAR_1);



    

    VAR_10 = 0;

    while (*VAR_5) {

        if (*VAR_5 == ':') {

            VAR_10++;

        }

        VAR_5++;

    }

    VAR_5 = VAR_6;



    

    if (VAR_10 >= 2) {

        VAR_8 = VAR_5;

        VAR_5 = strchr(VAR_5, ':');

        VAR_5++;

        VAR_5 = strchr(VAR_5, ':');

        *VAR_5++ = '\0';

    } else {

        VAR_8 = "";

    }



    VAR_9 = VAR_5;



    VAR_5 = strchr(VAR_9, ':');

    if (VAR_5) {

        *VAR_5++ = '#';

    }



    VAR_7 = g_strdup_printf("sheepdog:



    VAR_11 = sd_parse_uri(VAR_0, VAR_7, VAR_2, VAR_3, VAR_4);



    g_free(VAR_6);

    g_free(VAR_7);



    return VAR_11;

}

static int FUNC_0(BDRVSheepdogState *VAR_0, const char *VAR_1,
char *VAR_2, uint32_t *VAR_3, char *VAR_4)
{ char *VAR_5, *VAR_6, *VAR_7; const char *VAR_8, *VAR_9; int VAR_10, VAR_11; strstart(VAR_1, "sheepdog:", &VAR_1); VAR_5 = VAR_6 = g_strdup(VAR_1); VAR_10 = 0; while (*VAR_5) { if (*VAR_5 == ':') { VAR_10++; } VAR_5++; } VAR_5 = VAR_6; if (VAR_10 >= 2) { VAR_8 = VAR_5; VAR_5 = strchr(VAR_5, ':'); VAR_5++; VAR_5 = strchr(VAR_5, ':'); *VAR_5++ = '\0'; } else { VAR_8 = ""; } VAR_9 = VAR_5; VAR_5 = strchr(VAR_9, ':'); if (VAR_5) { *VAR_5++ = '#'; } VAR_7 = g_strdup_printf("sheepdog:
VAR_11 = sd_parse_uri(VAR_0, VAR_7, VAR_2, VAR_3, VAR_4); g_free(VAR_6); g_free(VAR_7); return VAR_11; }