… | |
… | |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | #include <string.h> |
5 | #include <string.h> |
6 | #include <setjmp.h> |
6 | #include <setjmp.h> |
|
|
7 | |
|
|
8 | #include <magic.h> |
7 | |
9 | |
8 | #include <jpeglib.h> |
10 | #include <jpeglib.h> |
9 | #include <glib.h> |
11 | #include <glib.h> |
10 | #include <gtk/gtk.h> |
12 | #include <gtk/gtk.h> |
11 | #include <gdk-pixbuf/gdk-pixbuf.h> |
13 | #include <gdk-pixbuf/gdk-pixbuf.h> |
… | |
… | |
126 | |
128 | |
127 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV |
129 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV |
128 | |
130 | |
129 | PROTOTYPES: ENABLE |
131 | PROTOTYPES: ENABLE |
130 | |
132 | |
|
|
133 | # missing function in perl. really :) |
|
|
134 | int |
|
|
135 | common_prefix_length (a, b) |
|
|
136 | unsigned char *a = (unsigned char *)SvPVutf8_nolen ($arg); |
|
|
137 | unsigned char *b = (unsigned char *)SvPVutf8_nolen ($arg); |
|
|
138 | CODE: |
|
|
139 | RETVAL = 0; |
|
|
140 | |
|
|
141 | while (*a == *b && *a) |
|
|
142 | { |
|
|
143 | RETVAL += (*a & 0xc0) != 0x80; |
|
|
144 | a++, b++; |
|
|
145 | } |
|
|
146 | |
|
|
147 | OUTPUT: |
|
|
148 | RETVAL |
|
|
149 | |
|
|
150 | const char * |
|
|
151 | magic (const char *path) |
|
|
152 | CODE: |
|
|
153 | { |
|
|
154 | static magic_t cookie; |
|
|
155 | |
|
|
156 | if (!cookie) |
|
|
157 | { |
|
|
158 | cookie = magic_open (MAGIC_NONE); |
|
|
159 | |
|
|
160 | if (cookie) |
|
|
161 | magic_load (cookie, 0); |
|
|
162 | else |
|
|
163 | XSRETURN_UNDEF; |
|
|
164 | } |
|
|
165 | |
|
|
166 | RETVAL = magic_file (cookie, path); |
|
|
167 | } |
|
|
168 | OUTPUT: |
|
|
169 | RETVAL |
|
|
170 | |
|
|
171 | const char * |
|
|
172 | magic_mime (const char *path) |
|
|
173 | CODE: |
|
|
174 | { |
|
|
175 | static magic_t cookie; |
|
|
176 | |
|
|
177 | if (!cookie) |
|
|
178 | { |
|
|
179 | cookie = magic_open (MAGIC_MIME); |
|
|
180 | |
|
|
181 | if (cookie) |
|
|
182 | magic_load (cookie, 0); |
|
|
183 | else |
|
|
184 | XSRETURN_UNDEF; |
|
|
185 | } |
|
|
186 | |
|
|
187 | RETVAL = magic_file (cookie, path); |
|
|
188 | } |
|
|
189 | OUTPUT: |
|
|
190 | RETVAL |
|
|
191 | |
131 | # missing in Gtk2 perl module |
192 | # missing in Gtk2 perl module |
132 | |
193 | |
133 | gboolean |
194 | gboolean |
134 | gdk_net_wm_supports (GdkAtom property) |
195 | gdk_net_wm_supports (GdkAtom property) |
135 | CODE: |
196 | CODE: |
… | |
… | |
184 | struct jpg_err_mgr jerr; |
245 | struct jpg_err_mgr jerr; |
185 | guchar *data; |
246 | guchar *data; |
186 | int rs; |
247 | int rs; |
187 | FILE *fp; |
248 | FILE *fp; |
188 | volatile GdkPixbuf *pb = 0; |
249 | volatile GdkPixbuf *pb = 0; |
189 | gchar *filename; |
|
|
190 | |
250 | |
191 | RETVAL = 0; |
251 | RETVAL = 0; |
192 | |
252 | |
193 | filename = g_filename_from_utf8 (SvPVutf8_nolen (path), -1, 0, 0, 0); |
|
|
194 | fp = fopen (filename, "rb"); |
253 | fp = fopen (SvPVbyte_nolen (path), "rb"); |
195 | g_free (filename); |
|
|
196 | |
254 | |
197 | if (!fp) |
255 | if (!fp) |
198 | XSRETURN_UNDEF; |
256 | XSRETURN_UNDEF; |
199 | |
257 | |
200 | cinfo.err = jpeg_std_error (&jerr.err); |
258 | cinfo.err = jpeg_std_error (&jerr.err); |