src/libmetha/mime.c
FT_ID
lm_mimetb_lookup(mimetb_t *t, const char *mime)
{
    mime_t m = lm_mime_hash(mime);
    int c = (m & ~MT_HASH_MASK) >> MT_HASH_CAT_BIT_OFFS; /* category */
    int o = (m & MT_HASH_MASK); /* offset in hash table */

    if (t->listsz[c] == MT_HASH_LIST_LIMIT) {
        /* hash table search */
        mimetb_nh_t *n = t->tbl[c][o];
        do {
            if (strcmp(mime, n->str) == 0)
                return n->id;
        } while ((n = n->next));
    } else {
        /* list form search */
        if (!t->tbl[c])
            return FT_ID_NULL;
        int x;
        for (x=0; x<t->listsz[c]; x++)
            if (((mimetb_nl_t*)(t->tbl[c]))[x].mime == m && strcmp(((mimetb_nl_t*)(t->tbl[c]))[x].str, mime) == 0)
                return ((mimetb_nl_t*)(t->tbl[c]))[x].id;
    }

    return FT_ID_NULL;
}
/** 
 * Find the mime, return the corresponding filetype ID
 **/
Find the mime, return the corresponding filetype ID
Find the mime return the corresponding filetype ID
FT_ID
lm_mimetb_lookup(mimetb_t *t, const char *mime)
{
    mime_t m = lm_mime_hash(mime);
    int c = (m & ~MT_HASH_MASK) >> MT_HASH_CAT_BIT_OFFS; 
    int o = (m & MT_HASH_MASK); 
    if (t->listsz[c] == MT_HASH_LIST_LIMIT) {
        mimetb_nh_t *n = t->tbl[c][o];
        do {
            if (strcmp(mime, n->str) == 0)
                return n->id;
        } while ((n = n->next));
    } else {
        if (!t->tbl[c])
            return FT_ID_NULL;
        int x;
        for (x=0; x<t->listsz[c]; x++)
            if (((mimetb_nl_t*)(t->tbl[c]))[x].mime == m && strcmp(((mimetb_nl_t*)(t->tbl[c]))[x].str, mime) == 0)
                return ((mimetb_nl_t*)(t->tbl[c]))[x].id;
    }
    return FT_ID_NULL;
}
FT_ID lm_mimetb_lookup ( mimetb_t * t , const char * mime ) { mime_t m = lm_mime_hash ( mime ) ; int c = ( m & ~ MT_HASH_MASK ) >> MT_HASH_CAT_BIT_OFFS ; int o = ( m & MT_HASH_MASK ) ; if ( t -> listsz [ c ] == MT_HASH_LIST_LIMIT ) { mimetb_nh_t * n = t -> tbl [ c ] [ o ] ; do { if ( strcmp ( mime , n -> str ) == 0 ) return n -> id ; } while ( ( n = n -> next ) ) ; } else { if ( ! t -> tbl [ c ] ) return FT_ID_NULL ; int x ; for ( x = 0 ; x < t -> listsz [ c ] ; x ++ ) if ( ( ( mimetb_nl_t * ) ( t -> tbl [ c ] ) ) [ x ] . mime == m && strcmp ( ( ( mimetb_nl_t * ) ( t -> tbl [ c ] ) ) [ x ] . str , mime ) == 0 ) return ( ( mimetb_nl_t * ) ( t -> tbl [ c ] ) ) [ x ] . id ; } return FT_ID_NULL ; }
Find the mime, return the corresponding filetype ID
Find the mime return the corresponding filetype ID
/* category */ /* offset in hash table */ /* hash table search */ /* list form search */