Lines Matching refs:ms

88 unreadable_info(struct magic_set *ms, mode_t md, const char *file)  in unreadable_info()  argument
93 if (file_printf(ms, "writable, ") == -1) in unreadable_info()
97 if (file_printf(ms, "executable, ") == -1) in unreadable_info()
107 if (file_printf(ms, "writable, ") == -1) in unreadable_info()
113 if (file_printf(ms, "regular file, ") == -1) in unreadable_info()
115 if (file_printf(ms, "no read permission") == -1) in unreadable_info()
121 magic_close(struct magic_set *ms) in magic_close() argument
123 if (ms == NULL) in magic_close()
125 file_ms_free(ms); in magic_close()
132 magic_load(struct magic_set *ms, const char *magicfile) in magic_load() argument
134 if (ms == NULL) in magic_load()
136 return file_apprentice(ms, magicfile, FILE_LOAD); in magic_load()
140 magic_compile(struct magic_set *ms, const char *magicfile) in magic_compile() argument
142 if (ms == NULL) in magic_compile()
144 return file_apprentice(ms, magicfile, FILE_COMPILE); in magic_compile()
148 magic_check(struct magic_set *ms, const char *magicfile) in magic_check() argument
150 if (ms == NULL) in magic_check()
152 return file_apprentice(ms, magicfile, FILE_CHECK); in magic_check()
156 magic_list(struct magic_set *ms, const char *magicfile) in magic_list() argument
158 if (ms == NULL) in magic_list()
160 return file_apprentice(ms, magicfile, FILE_LIST); in magic_list()
169 magic_descriptor(struct magic_set *ms, int fd) in magic_descriptor() argument
171 if (ms == NULL) in magic_descriptor()
173 return file_or_stream(ms, NULL, NULL); in magic_descriptor()
180 magic_file(struct magic_set *ms, const char *inname) in magic_file() argument
182 if (ms == NULL) in magic_file()
184 return file_or_stream(ms, inname, NULL); in magic_file()
188 magic_stream(struct magic_set *ms, php_stream *stream) in magic_stream() argument
190 if (ms == NULL) in magic_stream()
192 return file_or_stream(ms, NULL, stream); in magic_stream()
196 file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream) in file_or_stream() argument
204 if (file_reset(ms, 1) == -1) in file_or_stream()
212 if ((buf = CAST(unsigned char *, emalloc(ms->bytes_max + SLOP))) == NULL) in file_or_stream()
215 switch (file_fsmagic(ms, inname, &sb)) { in file_or_stream()
231 if (unreadable_info(ms, sb.st_mode, inname) == -1) in file_or_stream()
240 if (ms->flags & MAGIC_ERROR) { in file_or_stream()
241 file_error(ms, errno, "cannot stat `%s'", inname); in file_or_stream()
251 if ((nbytes = php_stream_read(stream, (char *)buf, ms->bytes_max - nbytes)) < 0) { in file_or_stream()
252 file_error(ms, errno, "cannot read `%s'", inname); in file_or_stream()
257 if (file_buffer(ms, stream, &sb, inname, buf, CAST(size_t, nbytes)) == -1) in file_or_stream()
267 return rv == 0 ? file_getbuffer(ms) : NULL; in file_or_stream()
272 magic_buffer(struct magic_set *ms, const void *buf, size_t nb) in magic_buffer() argument
274 if (ms == NULL) in magic_buffer()
276 if (file_reset(ms, 1) == -1) in magic_buffer()
282 if (file_buffer(ms, NULL, NULL, NULL, buf, nb) == -1) { in magic_buffer()
285 return file_getbuffer(ms); in magic_buffer()
290 magic_error(struct magic_set *ms) in magic_error() argument
292 if (ms == NULL) in magic_error()
294 return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL; in magic_error()
298 magic_errno(struct magic_set *ms) in magic_errno() argument
300 if (ms == NULL) in magic_errno()
302 return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0; in magic_errno()
306 magic_getflags(struct magic_set *ms) in magic_getflags() argument
308 if (ms == NULL) in magic_getflags()
311 return ms->flags; in magic_getflags()
315 magic_setflags(struct magic_set *ms, int flags) in magic_setflags() argument
317 if (ms == NULL) in magic_setflags()
323 ms->flags = flags; in magic_setflags()
334 magic_setparam(struct magic_set *ms, int param, const void *val) in magic_setparam() argument
336 if (ms == NULL) in magic_setparam()
340 ms->indir_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
343 ms->name_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
346 ms->elf_phnum_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
349 ms->elf_shnum_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
352 ms->elf_shsize_max = *CAST(const size_t *, val); in magic_setparam()
355 ms->elf_notes_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
358 ms->regex_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
361 ms->bytes_max = *CAST(const size_t *, val); in magic_setparam()
364 ms->encoding_max = *CAST(const size_t *, val); in magic_setparam()
373 magic_getparam(struct magic_set *ms, int param, void *val) in magic_getparam() argument
375 if (ms == NULL) in magic_getparam()
379 *CAST(size_t *, val) = ms->indir_max; in magic_getparam()
382 *CAST(size_t *, val) = ms->name_max; in magic_getparam()
385 *CAST(size_t *, val) = ms->elf_phnum_max; in magic_getparam()
388 *CAST(size_t *, val) = ms->elf_shnum_max; in magic_getparam()
391 *CAST(size_t *, val) = ms->elf_shsize_max; in magic_getparam()
394 *CAST(size_t *, val) = ms->elf_notes_max; in magic_getparam()
397 *CAST(size_t *, val) = ms->regex_max; in magic_getparam()
400 *CAST(size_t *, val) = ms->bytes_max; in magic_getparam()
403 *CAST(size_t *, val) = ms->encoding_max; in magic_getparam()