static int parse_short_name(BDRVVVFATState* s,

	long_file_name* lfn, direntry_t* direntry)

{

    int i, j;



    if (!is_short_name(direntry))

	return 1;



    for (j = 7; j >= 0 && direntry->name[j] == ' '; j--);

    for (i = 0; i <= j; i++) {

	if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)

	    return -1;

	else if (s->downcase_short_names)

	    lfn->name[i] = qemu_tolower(direntry->name[i]);

	else

	    lfn->name[i] = direntry->name[i];

    }



    for (j = 2; j >= 0 && direntry->extension[j] == ' '; j--);

    if (j >= 0) {

	lfn->name[i++] = '.';

	lfn->name[i + j + 1] = '\0';

	for (;j >= 0; j--) {

	    if (direntry->extension[j] <= ' ' || direntry->extension[j] > 0x7f)

		return -2;

	    else if (s->downcase_short_names)

		lfn->name[i + j] = qemu_tolower(direntry->extension[j]);

	    else

		lfn->name[i + j] = direntry->extension[j];

	}

    } else

	lfn->name[i + j + 1] = '\0';



    lfn->len = strlen((char*)lfn->name);



    return 0;

}

static int parse_short_name(BDRVVVFATState* s,

	long_file_name* lfn, direntry_t* direntry)

{

    int i, j;



    if (!is_short_name(direntry))

	return 1;



    for (j = 7; j >= 0 && direntry->name[j] == ' '; j--);

    for (i = 0; i <= j; i++) {

	if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)

	    return -1;

	else if (s->downcase_short_names)

	    lfn->name[i] = qemu_tolower(direntry->name[i]);

	else

	    lfn->name[i] = direntry->name[i];

    }



    for (j = 2; j >= 0 && direntry->extension[j] == ' '; j--);

    if (j >= 0) {

	lfn->name[i++] = '.';

	lfn->name[i + j + 1] = '\0';

	for (;j >= 0; j--) {

	    if (direntry->extension[j] <= ' ' || direntry->extension[j] > 0x7f)

		return -2;

	    else if (s->downcase_short_names)

		lfn->name[i + j] = qemu_tolower(direntry->extension[j]);

	    else

		lfn->name[i + j] = direntry->extension[j];

	}

    } else

	lfn->name[i + j + 1] = '\0';



    lfn->len = strlen((char*)lfn->name);



    return 0;

}

static int FUNC_0(BDRVVVFATState* VAR_0,

	long_file_name* VAR_1, direntry_t* VAR_2)

{

    int VAR_3, VAR_4;



    if (!is_short_name(VAR_2))

	return 1;



    for (VAR_4 = 7; VAR_4 >= 0 && VAR_2->name[VAR_4] == ' '; VAR_4--);

    for (VAR_3 = 0; VAR_3 <= VAR_4; VAR_3++) {

	if (VAR_2->name[VAR_3] <= ' ' || VAR_2->name[VAR_3] > 0x7f)

	    return -1;

	else if (VAR_0->downcase_short_names)

	    VAR_1->name[VAR_3] = qemu_tolower(VAR_2->name[VAR_3]);

	else

	    VAR_1->name[VAR_3] = VAR_2->name[VAR_3];

    }



    for (VAR_4 = 2; VAR_4 >= 0 && VAR_2->extension[VAR_4] == ' '; VAR_4--);

    if (VAR_4 >= 0) {

	VAR_1->name[VAR_3++] = '.';

	VAR_1->name[VAR_3 + VAR_4 + 1] = '\0';

	for (;VAR_4 >= 0; VAR_4--) {

	    if (VAR_2->extension[VAR_4] <= ' ' || VAR_2->extension[VAR_4] > 0x7f)

		return -2;

	    else if (VAR_0->downcase_short_names)

		VAR_1->name[VAR_3 + VAR_4] = qemu_tolower(VAR_2->extension[VAR_4]);

	    else

		VAR_1->name[VAR_3 + VAR_4] = VAR_2->extension[VAR_4];

	}

    } else

	VAR_1->name[VAR_3 + VAR_4 + 1] = '\0';



    VAR_1->len = strlen((char*)VAR_1->name);



    return 0;

}

static int FUNC_0(BDRVVVFATState* VAR_0,
long_file_name* VAR_1, direntry_t* VAR_2)
{ int VAR_3, VAR_4; if (!is_short_name(VAR_2))
return 1; for (VAR_4 = 7; VAR_4 >= 0 && VAR_2->name[VAR_4] == ' '; VAR_4--); for (VAR_3 = 0; VAR_3 <= VAR_4; VAR_3++) { if (VAR_2->name[VAR_3] <= ' ' || VAR_2->name[VAR_3] > 0x7f)
return -1; else if (VAR_0->downcase_short_names)
VAR_1->name[VAR_3] = qemu_tolower(VAR_2->name[VAR_3]); else
VAR_1->name[VAR_3] = VAR_2->name[VAR_3]; } for (VAR_4 = 2; VAR_4 >= 0 && VAR_2->extension[VAR_4] == ' '; VAR_4--); if (VAR_4 >= 0) { VAR_1->name[VAR_3++] = '.'; VAR_1->name[VAR_3 + VAR_4 + 1] = '\0'; for (;VAR_4 >= 0; VAR_4--) { if (VAR_2->extension[VAR_4] <= ' ' || VAR_2->extension[VAR_4] > 0x7f)
return -2; else if (VAR_0->downcase_short_names)
VAR_1->name[VAR_3 + VAR_4] = qemu_tolower(VAR_2->extension[VAR_4]); else
VAR_1->name[VAR_3 + VAR_4] = VAR_2->extension[VAR_4]; } } else VAR_1->name[VAR_3 + VAR_4 + 1] = '\0'; VAR_1->len = strlen((char*)VAR_1->name); return 0; }