Lines Matching refs:map

364 add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)  in add_mlist()  argument
371 ml->map = idx == 0 ? map : NULL; in add_mlist()
372 ml->magic = map->magic[idx]; in add_mlist()
373 ml->nmagic = map->nmagic[idx]; in add_mlist()
389 struct magic_map *map; in apprentice_1() local
394 (unsigned long)sizeof(*map->magic[0]), in apprentice_1()
400 map = apprentice_load(ms, fn, action); in apprentice_1()
401 if (map == NULL) in apprentice_1()
403 return apprentice_compile(ms, map, fn); in apprentice_1()
406 map = apprentice_map(ms, fn); in apprentice_1()
407 if (map == NULL) { in apprentice_1()
411 map = apprentice_load(ms, fn, action); in apprentice_1()
413 if (map == NULL) in apprentice_1()
418 if (add_mlist(ms->mlist[i], map, i) == -1) { in apprentice_1()
420 apprentice_unmap(map); in apprentice_1()
491 apprentice_unmap(struct magic_map *map) in apprentice_unmap() argument
493 if (map == NULL) in apprentice_unmap()
495 if (map->p != php_magic_database) { in apprentice_unmap()
496 if (map->p == NULL) { in apprentice_unmap()
499 if (map->magic[j]) { in apprentice_unmap()
500 efree(map->magic[j]); in apprentice_unmap()
504 efree(map->p); in apprentice_unmap()
507 efree(map); in apprentice_unmap()
531 if (ml->map) in mlist_free()
532 apprentice_unmap(ml->map); in mlist_free()
1140 struct magic_map *map; in apprentice_load() local
1148 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) { in apprentice_load()
1149 file_oomem(ms, sizeof(*map)); in apprentice_load()
1237 &map->magic[j], &map->nmagic[j]) == -1) { in apprentice_load()
1249 if (map->magic[j]) in apprentice_load()
1250 efree(map->magic[j]); in apprentice_load()
1252 efree(map); in apprentice_load()
1255 return map; in apprentice_load()
2596 struct magic_map *map; in apprentice_map() local
2604 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) { in apprentice_map()
2605 file_oomem(ms, sizeof(*map)); in apprentice_map()
2610 map->p = (void *)&php_magic_database; in apprentice_map()
2648 map->len = (size_t)st.sb.st_size; in apprentice_map()
2649 if ((map->p = CAST(void *, emalloc(map->len))) == NULL) { in apprentice_map()
2650 file_oomem(ms, map->len); in apprentice_map()
2653 if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) { in apprentice_map()
2657 map->len = 0; in apprentice_map()
2664 ptr = (uint32_t *)(void *)map->p; in apprentice_map()
2688 map->p = emalloc(sizeof(php_magic_database)); in apprentice_map()
2689 map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database)); in apprentice_map()
2702 map->magic[0] = CAST(struct magic *, map->p) + 1; in apprentice_map()
2706 map->nmagic[i] = swap4(ptr[i + 2]); in apprentice_map()
2708 map->nmagic[i] = ptr[i + 2]; in apprentice_map()
2710 map->magic[i + 1] = map->magic[i] + map->nmagic[i]; in apprentice_map()
2711 nentries += map->nmagic[i]; in apprentice_map()
2721 byteswap(map->magic[i], map->nmagic[i]); in apprentice_map()
2726 return map; in apprentice_map()
2732 apprentice_unmap(map); in apprentice_map()
2747 apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) in apprentice_compile() argument
2749 static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS; in apprentice_compile()
2750 static const size_t m = sizeof(**map->magic); in apprentice_compile()
2782 if (php_stream_write(stream, (const char *)map->nmagic, nm) != (ssize_t)nm) { in apprentice_compile()
2795 len = m * map->nmagic[i]; in apprentice_compile()
2796 if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) { in apprentice_compile()