Lines Matching refs:ms
92 unreadable_info(struct magic_set *ms, mode_t md, const char *file) in unreadable_info() argument
97 if (file_printf(ms, "writable, ") == -1) in unreadable_info()
100 if (file_printf(ms, "executable, ") == -1) in unreadable_info()
104 if (file_printf(ms, "regular file, ") == -1) in unreadable_info()
106 if (file_printf(ms, "no read permission") == -1) in unreadable_info()
112 magic_close(struct magic_set *ms) in magic_close() argument
114 if (ms == NULL) in magic_close()
116 file_ms_free(ms); in magic_close()
123 magic_load(struct magic_set *ms, const char *magicfile) in magic_load() argument
125 if (ms == NULL) in magic_load()
127 return file_apprentice(ms, magicfile, FILE_LOAD); in magic_load()
131 magic_compile(struct magic_set *ms, const char *magicfile) in magic_compile() argument
133 if (ms == NULL) in magic_compile()
135 return file_apprentice(ms, magicfile, FILE_COMPILE); in magic_compile()
139 magic_check(struct magic_set *ms, const char *magicfile) in magic_check() argument
141 if (ms == NULL) in magic_check()
143 return file_apprentice(ms, magicfile, FILE_CHECK); in magic_check()
147 magic_list(struct magic_set *ms, const char *magicfile) in magic_list() argument
149 if (ms == NULL) in magic_list()
151 return file_apprentice(ms, magicfile, FILE_LIST); in magic_list()
160 magic_descriptor(struct magic_set *ms, int fd) in magic_descriptor() argument
162 if (ms == NULL) in magic_descriptor()
164 return file_or_stream(ms, NULL, NULL); in magic_descriptor()
171 magic_file(struct magic_set *ms, const char *inname) in magic_file() argument
173 if (ms == NULL) in magic_file()
175 return file_or_stream(ms, inname, NULL); in magic_file()
179 magic_stream(struct magic_set *ms, php_stream *stream) in magic_stream() argument
181 if (ms == NULL) in magic_stream()
183 return file_or_stream(ms, NULL, stream); in magic_stream()
187 file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream) in file_or_stream() argument
195 if (file_reset(ms, 1) == -1) in file_or_stream()
203 if ((buf = CAST(unsigned char *, emalloc(ms->bytes_max + SLOP))) == NULL) in file_or_stream()
206 switch (file_fsmagic(ms, inname, &sb)) { in file_or_stream()
222 if (unreadable_info(ms, sb.st_mode, inname) == -1) in file_or_stream()
231 if (ms->flags & MAGIC_ERROR) { in file_or_stream()
232 file_error(ms, errno, "cannot stat `%s'", inname); in file_or_stream()
242 if ((nbytes = php_stream_read(stream, (char *)buf, ms->bytes_max - nbytes)) < 0) { in file_or_stream()
243 file_error(ms, errno, "cannot read `%s'", inname); in file_or_stream()
248 if (file_buffer(ms, stream, &sb, inname, buf, CAST(size_t, nbytes)) == -1) in file_or_stream()
258 return rv == 0 ? file_getbuffer(ms) : NULL; in file_or_stream()
263 magic_buffer(struct magic_set *ms, const void *buf, size_t nb) in magic_buffer() argument
265 if (ms == NULL) in magic_buffer()
267 if (file_reset(ms, 1) == -1) in magic_buffer()
273 if (file_buffer(ms, NULL, NULL, NULL, buf, nb) == -1) { in magic_buffer()
276 return file_getbuffer(ms); in magic_buffer()
281 magic_error(struct magic_set *ms) in magic_error() argument
283 if (ms == NULL) in magic_error()
285 return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL; in magic_error()
289 magic_errno(struct magic_set *ms) in magic_errno() argument
291 if (ms == NULL) in magic_errno()
293 return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0; in magic_errno()
297 magic_getflags(struct magic_set *ms) in magic_getflags() argument
299 if (ms == NULL) in magic_getflags()
302 return ms->flags; in magic_getflags()
306 magic_setflags(struct magic_set *ms, int flags) in magic_setflags() argument
308 if (ms == NULL) in magic_setflags()
314 ms->flags = flags; in magic_setflags()
325 magic_setparam(struct magic_set *ms, int param, const void *val) in magic_setparam() argument
327 if (ms == NULL) in magic_setparam()
331 ms->indir_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
334 ms->name_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
337 ms->elf_phnum_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
340 ms->elf_shnum_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
343 ms->elf_notes_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
346 ms->regex_max = CAST(uint16_t, *CAST(const size_t *, val)); in magic_setparam()
349 ms->bytes_max = *CAST(const size_t *, val); in magic_setparam()
358 magic_getparam(struct magic_set *ms, int param, void *val) in magic_getparam() argument
360 if (ms == NULL) in magic_getparam()
364 *CAST(size_t *, val) = ms->indir_max; in magic_getparam()
367 *CAST(size_t *, val) = ms->name_max; in magic_getparam()
370 *CAST(size_t *, val) = ms->elf_phnum_max; in magic_getparam()
373 *CAST(size_t *, val) = ms->elf_shnum_max; in magic_getparam()
376 *CAST(size_t *, val) = ms->elf_notes_max; in magic_getparam()
379 *CAST(size_t *, val) = ms->regex_max; in magic_getparam()
382 *CAST(size_t *, val) = ms->bytes_max; in magic_getparam()