Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / media / media-magic.c
1 /** media-magic.h -- file/libmagic file analysis
2  *
3  * Copyright (C) 2007 Sebastian Freundt
4  *
5  * This file is part of SXEmacs.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the author nor the names of any contributors
19  *    may be used to endorse or promote products derived from this
20  *    software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 /* Synched up with: Not in FSF. */
36
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
40 #include "lisp.h"
41
42 #include "media-magic.h"
43
44 Lisp_Object Qmagic;
45
46 /* just a dummy declaration */
47 void magic_process(magic_t magic, const char *inname);
48
49 void
50 magic_process(magic_t magic, const char *inname)
51 {
52         const char *type;
53
54         magic = magic_open(0);
55         if (magic == NULL) {
56                 fprintf(stderr, "ERROR\n");
57         }
58
59         if (magic_load(magic, "/usr/local/share/file/magic") == -1) {
60                 fprintf(stderr, "magic: %s\n", magic_error(magic));
61                 return;
62         }
63
64         type = magic_file(magic, inname);
65         if (type == NULL) {
66                 fprintf(stderr, "ERROR: %s\n", magic_error(magic));
67         } else {
68                 fprintf(stderr, "%s\n", type);
69         }
70 }
71
72
73 /* media-magic.c ends here */