Lines Matching defs:ms
269 unreadable_info(struct magic_set *ms, mode_t md, const char *file)
274 if (file_printf(ms, "writable, ") == -1)
277 if (file_printf(ms, "executable, ") == -1)
281 if (file_printf(ms, "regular file, ") == -1)
283 if (file_printf(ms, "no read permission") == -1)
289 magic_close(struct magic_set *ms)
291 if (ms == NULL)
293 file_ms_free(ms);
300 magic_load(struct magic_set *ms, const char *magicfile)
302 if (ms == NULL)
304 return file_apprentice(ms, magicfile, FILE_LOAD);
312 magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes,
315 if (ms == NULL)
317 return buffer_apprentice(ms, (struct magic **)bufs, sizes, nbufs);
322 magic_compile(struct magic_set *ms, const char *magicfile)
324 if (ms == NULL)
326 return file_apprentice(ms, magicfile, FILE_COMPILE);
330 magic_check(struct magic_set *ms, const char *magicfile)
332 if (ms == NULL)
334 return file_apprentice(ms, magicfile, FILE_CHECK);
338 magic_list(struct magic_set *ms, const char *magicfile)
340 if (ms == NULL)
342 return file_apprentice(ms, magicfile, FILE_LIST);
346 close_and_restore(const struct magic_set *ms, const char *name, int fd,
353 if ((ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
384 magic_descriptor(struct magic_set *ms, int fd)
386 if (ms == NULL)
388 return file_or_fd(ms, NULL, fd);
395 magic_file(struct magic_set *ms, const char *inname)
397 if (ms == NULL)
399 return file_or_fd(ms, inname, STDIN_FILENO);
403 file_or_fd(struct magic_set *ms, const char *inname, int fd)
412 if (file_reset(ms) == -1)
420 if ((buf = CAST(unsigned char *, malloc(ms->bytes_max + SLOP))) == NULL)
423 switch (file_fsmagic(ms, inname, &sb)) {
470 unreadable_info(ms, sb.st_mode, inname) == -1)
484 * try looking at the first ms->bytes_max bytes
490 (size_t)(ms->bytes_max - nbytes), 1)) > 0) {
497 if (unreadable_info(ms, sb.st_mode, inname) == -1)
509 ms->bytes_max;
512 file_error(ms, errno, "cannot read fd %d", fd);
514 file_error(ms, errno, "cannot read `%s'",
521 if (file_buffer(ms, fd, inname, buf, (size_t)nbytes) == -1)
529 close_and_restore(ms, inname, fd, &sb);
532 return rv == 0 ? file_getbuffer(ms) : NULL;
537 magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
539 if (ms == NULL)
541 if (file_reset(ms) == -1)
547 if (file_buffer(ms, -1, NULL, buf, nb) == -1) {
550 return file_getbuffer(ms);
555 magic_error(struct magic_set *ms)
557 if (ms == NULL)
559 return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL;
563 magic_errno(struct magic_set *ms)
565 if (ms == NULL)
567 return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0;
571 magic_setflags(struct magic_set *ms, int flags)
573 if (ms == NULL)
579 ms->flags = flags;
590 magic_setparam(struct magic_set *ms, int param, const void *val)
594 ms->indir_max = (uint16_t)*(const size_t *)val;
597 ms->name_max = (uint16_t)*(const size_t *)val;
600 ms->elf_phnum_max = (uint16_t)*(const size_t *)val;
603 ms->elf_shnum_max = (uint16_t)*(const size_t *)val;
606 ms->elf_notes_max = (uint16_t)*(const size_t *)val;
609 ms->elf_notes_max = (uint16_t)*(const size_t *)val;
612 ms->bytes_max = *(const size_t *)val;
621 magic_getparam(struct magic_set *ms, int param, void *val)
625 *(size_t *)val = ms->indir_max;
628 *(size_t *)val = ms->name_max;
631 *(size_t *)val = ms->elf_phnum_max;
634 *(size_t *)val = ms->elf_shnum_max;
637 *(size_t *)val = ms->elf_notes_max;
640 *(size_t *)val = ms->regex_max;
643 *(size_t *)val = ms->bytes_max;