lib/libstand/dosfs.c
/*
 * Copy name from extended directory entry
 */
Copy name from extended directory entry
Copy name from extended directory entry
static void
cp_xdnm(u_char *lfn, DOS_XDE *xde)
{
    static struct {
        u_int off;
        u_int dim;
    } ix[3] = {
        {offsetof(DOS_XDE, name1), sizeof(xde->name1) / 2},
        {offsetof(DOS_XDE, name2), sizeof(xde->name2) / 2},
        {offsetof(DOS_XDE, name3), sizeof(xde->name3) / 2}
    };
    u_char *p;
    u_int n, x, c;
    lfn += 13 * ((xde->seq & ~0x40) - 1);
    for (n = 0; n < 3; n++)
        for (p = (u_char *)xde + ix[n].off, x = ix[n].dim; x;
	     p += 2, x--) {
            if ((c = cv2(p)) && (c < 32 || c > 127))
                c = '?';
            if (!(*lfn++ = c))
                return;
        }
    if (xde->seq & 0x40)
        *lfn = 0;
}
static void cp_xdnm ( u_char * lfn , DOS_XDE * xde ) { static struct { u_int off ; u_int dim ; } ix [ 3 ] = { { offsetof ( DOS_XDE , name1 ) , sizeof ( xde -> name1 ) / 2 } , { offsetof ( DOS_XDE , name2 ) , sizeof ( xde -> name2 ) / 2 } , { offsetof ( DOS_XDE , name3 ) , sizeof ( xde -> name3 ) / 2 } } ; u_char * p ; u_int n , x , c ; lfn += 13 * ( ( xde -> seq & ~ 0x40 ) - 1 ) ; for ( n = 0 ; n < 3 ; n ++ ) for ( p = ( u_char * ) xde + ix [ n ] . off , x = ix [ n ] . dim ; x ; p += 2 , x -- ) { if ( ( c = cv2 ( p ) ) && ( c < 32 || c > 127 ) ) c = ' ' ; if ( ! ( * lfn ++ = c ) ) return ; } if ( xde -> seq & 0x40 ) * lfn = 0 ; }
Copy name from extended directory entry
Copy name from extended directory entry