Lines Matching refs:map

392 add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)  in add_mlist()  argument
396 mlp->map = NULL; in add_mlist()
400 ml->map = idx == 0 ? map : NULL; in add_mlist()
401 ml->magic = map->magic[idx]; in add_mlist()
402 ml->nmagic = map->nmagic[idx]; in add_mlist()
417 struct magic_map *map; in apprentice_1() local
423 CAST(unsigned long, sizeof(*map->magic[0])), in apprentice_1()
429 map = apprentice_load(ms, fn, action); in apprentice_1()
430 if (map == NULL) in apprentice_1()
432 return apprentice_compile(ms, map, fn); in apprentice_1()
435 map = apprentice_map(ms, fn); in apprentice_1()
436 if (map == RCAST(struct magic_map *, -1)) in apprentice_1()
438 if (map == NULL) { in apprentice_1()
442 map = apprentice_load(ms, fn, action); in apprentice_1()
444 if (map == NULL) in apprentice_1()
449 if (add_mlist(ms->mlist[i], map, i) == -1) { in apprentice_1()
528 apprentice_unmap(struct magic_map *map) in apprentice_unmap() argument
530 if (map == NULL) in apprentice_unmap()
532 if (map->p != php_magic_database) { in apprentice_unmap()
533 if (map->p == NULL) { in apprentice_unmap()
536 if (map->magic[j]) { in apprentice_unmap()
537 efree(map->magic[j]); in apprentice_unmap()
541 efree(map->p); in apprentice_unmap()
544 efree(map); in apprentice_unmap()
561 if (ml->map) in mlist_free_one()
562 apprentice_unmap(CAST(struct magic_map *, ml->map)); in mlist_free_one()
1288 struct magic_map *map; in apprentice_load() local
1298 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) in apprentice_load()
1300 file_oomem(ms, sizeof(*map)); in apprentice_load()
1303 map->type = MAP_TYPE_MALLOC; in apprentice_load()
1381 &map->magic[j], &map->nmagic[j]) == -1) { in apprentice_load()
1392 apprentice_unmap(map); in apprentice_load()
1395 return map; in apprentice_load()
2958 struct magic_map *map;
2960 if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
2961 file_oomem(ms, sizeof(*map));
2964 map->len = len;
2965 map->p = buf;
2966 map->type = MAP_TYPE_USER;
2967 if (check_buffer(ms, map, "buffer") != 0) {
2968 apprentice_unmap(map);
2971 return map;
2986 struct magic_map *map; in apprentice_map() local
2993 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) { in apprentice_map()
2994 file_oomem(ms, sizeof(*map)); in apprentice_map()
2999 map->p = (void *)&php_magic_database; in apprentice_map()
3035 map->type = MAP_TYPE_MALLOC; in apprentice_map()
3036 map->len = CAST(size_t, st.sb.st_size); in apprentice_map()
3037 map->p = CAST(void *, emalloc(map->len)); in apprentice_map()
3039 if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) { in apprentice_map()
3048 ptr = (uint32_t *)(void *)map->p; in apprentice_map()
3072 map->p = emalloc(sizeof(php_magic_database)); in apprentice_map()
3073 map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database)); in apprentice_map()
3086 map->magic[0] = CAST(struct magic *, map->p) + 1; in apprentice_map()
3090 map->nmagic[i] = swap4(ptr[i + 2]); in apprentice_map()
3092 map->nmagic[i] = ptr[i + 2]; in apprentice_map()
3094 map->magic[i + 1] = map->magic[i] + map->nmagic[i]; in apprentice_map()
3095 nentries += map->nmagic[i]; in apprentice_map()
3104 byteswap(map->magic[i], map->nmagic[i]); in apprentice_map()
3109 return map; in apprentice_map()
3115 apprentice_unmap(map); in apprentice_map()
3124 check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname)
3131 ptr = CAST(uint32_t *, map->p);
3150 entries = CAST(uint32_t, map->len / sizeof(struct magic));
3151 if ((entries * sizeof(struct magic)) != map->len) {
3154 dbname, map->len, sizeof(struct magic));
3157 map->magic[0] = CAST(struct magic *, map->p) + 1;
3161 map->nmagic[i] = swap4(ptr[i + 2]);
3163 map->nmagic[i] = ptr[i + 2];
3165 map->magic[i + 1] = map->magic[i] + map->nmagic[i];
3166 nentries += map->nmagic[i];
3175 byteswap(map->magic[i], map->nmagic[i]);
3184 apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) in apprentice_compile() argument
3186 static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS; in apprentice_compile()
3187 static const size_t m = sizeof(**map->magic); in apprentice_compile()
3213 memcpy(hdr.h + 2, map->nmagic, nm); in apprentice_compile()
3221 len = m * map->nmagic[i]; in apprentice_compile()
3222 if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) { in apprentice_compile()