… | |
… | |
14 | #include <gdk-pixbuf/gdk-pixbuf.h> |
14 | #include <gdk-pixbuf/gdk-pixbuf.h> |
15 | |
15 | |
16 | #include <gperl.h> |
16 | #include <gperl.h> |
17 | #include <gtk2perl.h> |
17 | #include <gtk2perl.h> |
18 | |
18 | |
|
|
19 | #include <assert.h> |
|
|
20 | |
19 | #define IW 80 /* MUST match Schnauzer.pm! */ |
21 | #define IW 80 /* MUST match Schnauzer.pm! */ |
20 | #define IH 60 /* MUST match Schnauzer.pm! */ |
22 | #define IH 60 /* MUST match Schnauzer.pm! */ |
21 | |
23 | |
22 | #define RAND (seed = (seed + 7141) * 54773 % 134456) |
24 | #define RAND (seed = (seed + 7141) * 54773 % 134456) |
23 | |
25 | |
24 | #define LINELENGTH 240 |
26 | #define LINELENGTH 240 |
25 | |
27 | |
26 | #define ELLIPSIS "\xe2\x80\xa6" |
28 | #define ELLIPSIS "\xe2\x80\xa6" |
|
|
29 | |
|
|
30 | typedef char *octet_string; |
27 | |
31 | |
28 | struct jpg_err_mgr |
32 | struct jpg_err_mgr |
29 | { |
33 | { |
30 | struct jpeg_error_mgr err; |
34 | struct jpeg_error_mgr err; |
31 | jmp_buf setjmp_buffer; |
35 | jmp_buf setjmp_buffer; |
… | |
… | |
202 | |
206 | |
203 | OUTPUT: |
207 | OUTPUT: |
204 | RETVAL |
208 | RETVAL |
205 | |
209 | |
206 | const char * |
210 | const char * |
207 | magic (const char *path) |
211 | magic (octet_string path) |
208 | CODE: |
212 | CODE: |
209 | { |
213 | { |
210 | static magic_t cookie; |
214 | static magic_t cookie; |
211 | |
215 | |
212 | if (!cookie) |
216 | if (!cookie) |
213 | { |
217 | { |
214 | cookie = magic_open (MAGIC_NONE); |
218 | cookie = magic_open (MAGIC_SYMLINK); |
215 | |
219 | |
216 | if (cookie) |
220 | if (cookie) |
217 | magic_load (cookie, 0); |
221 | magic_load (cookie, 0); |
218 | else |
222 | else |
219 | XSRETURN_UNDEF; |
223 | XSRETURN_UNDEF; |
… | |
… | |
223 | } |
227 | } |
224 | OUTPUT: |
228 | OUTPUT: |
225 | RETVAL |
229 | RETVAL |
226 | |
230 | |
227 | const char * |
231 | const char * |
228 | magic_mime (const char *path) |
232 | magic_mime (octet_string path) |
229 | CODE: |
233 | CODE: |
230 | { |
234 | { |
231 | static magic_t cookie; |
235 | static magic_t cookie; |
232 | |
236 | |
233 | if (!cookie) |
237 | if (!cookie) |
234 | { |
238 | { |
235 | cookie = magic_open (MAGIC_MIME); |
239 | cookie = magic_open (MAGIC_MIME | MAGIC_SYMLINK); |
236 | |
240 | |
237 | if (cookie) |
241 | if (cookie) |
238 | magic_load (cookie, 0); |
242 | magic_load (cookie, 0); |
239 | else |
243 | else |
240 | XSRETURN_UNDEF; |
244 | XSRETURN_UNDEF; |
… | |
… | |
288 | RETVAL |
292 | RETVAL |
289 | |
293 | |
290 | GdkPixbuf_noinc * |
294 | GdkPixbuf_noinc * |
291 | rotate (GdkPixbuf *pb, int angle) |
295 | rotate (GdkPixbuf *pb, int angle) |
292 | CODE: |
296 | CODE: |
|
|
297 | if (angle < 0) |
|
|
298 | angle += 360; |
293 | RETVAL = gdk_pixbuf_rotate_simple (pb, angle == 0 ? GDK_PIXBUF_ROTATE_NONE |
299 | RETVAL = gdk_pixbuf_rotate_simple (pb, angle == 0 ? GDK_PIXBUF_ROTATE_NONE |
294 | : angle == 90 ? GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE |
300 | : angle == 90 ? GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE |
295 | : angle == 180 ? GDK_PIXBUF_ROTATE_UPSIDEDOWN |
301 | : angle == 180 ? GDK_PIXBUF_ROTATE_UPSIDEDOWN |
296 | : angle == 270 ? GDK_PIXBUF_ROTATE_CLOCKWISE |
302 | : angle == 270 ? GDK_PIXBUF_ROTATE_CLOCKWISE |
297 | : angle); |
303 | : angle); |
… | |
… | |
398 | compare (GdkPixbuf *a, GdkPixbuf *b) |
404 | compare (GdkPixbuf *a, GdkPixbuf *b) |
399 | PPCODE: |
405 | PPCODE: |
400 | { |
406 | { |
401 | int w = gdk_pixbuf_get_width (a); |
407 | int w = gdk_pixbuf_get_width (a); |
402 | int h = gdk_pixbuf_get_height (a); |
408 | int h = gdk_pixbuf_get_height (a); |
|
|
409 | |
403 | int sa = gdk_pixbuf_get_rowstride (a); |
410 | int sa = gdk_pixbuf_get_rowstride (a); |
404 | int sb = gdk_pixbuf_get_rowstride (b); |
411 | int sb = gdk_pixbuf_get_rowstride (b); |
405 | |
412 | |
406 | guchar *pa = gdk_pixbuf_get_pixels (a); |
413 | guchar *pa = gdk_pixbuf_get_pixels (a); |
407 | guchar *pb = gdk_pixbuf_get_pixels (b); |
414 | guchar *pb = gdk_pixbuf_get_pixels (b); |
… | |
… | |
440 | |
447 | |
441 | ############################################################################# |
448 | ############################################################################# |
442 | |
449 | |
443 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
450 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
444 | |
451 | |
|
|
452 | # currently only works for filenames (octet strings) |
|
|
453 | |
445 | SV * |
454 | SV * |
446 | foldcase (SV *pathsv) |
455 | foldcase (SV *pathsv) |
447 | PROTOTYPE: $ |
456 | PROTOTYPE: $ |
448 | CODE: |
457 | CODE: |
449 | { |
458 | { |
450 | STRLEN plen; |
459 | STRLEN plen; |
451 | U8 *path = (U8 *)SvPVutf8 (pathsv, plen); |
460 | U8 *path = (U8 *)SvPV (pathsv, plen); |
452 | U8 *pend = path + plen; |
461 | U8 *pend = path + plen; |
453 | U8 dst [plen * 6 * 3], *dstp = dst; |
462 | U8 dst [plen * 6 * 3], *dstp = dst; |
454 | |
463 | |
455 | while (path < pend) |
464 | while (path < pend) |
456 | { |
465 | { |
457 | U8 ch = *path; |
466 | U8 ch = *path; |
458 | |
467 | |
459 | if (ch >= 'a' && ch <= 'z') |
468 | if (ch >= 'a' && ch <= 'z') |
460 | *dstp++ = *path++; |
469 | *dstp++ = *path++; |
|
|
470 | else if (ch >= 'A' && ch <= 'Z') |
|
|
471 | *dstp++ = *path++ + ('a' - 'A'); |
461 | else if (ch >= '0' && ch <= '9') |
472 | else if (ch >= '0' && ch <= '9') |
462 | { |
473 | { |
463 | STRLEN el, nl = 0; |
474 | STRLEN el, nl = 0; |
464 | while (*path >= '0' && *path <= '9' && path < pend) |
475 | while (*path >= '0' && *path <= '9' && path < pend) |
465 | path++, nl++; |
476 | path++, nl++; |
… | |
… | |
468 | *dstp++ = '0'; |
479 | *dstp++ = '0'; |
469 | |
480 | |
470 | memcpy (dstp, path - nl, nl); |
481 | memcpy (dstp, path - nl, nl); |
471 | dstp += nl; |
482 | dstp += nl; |
472 | } |
483 | } |
|
|
484 | else |
|
|
485 | *dstp++ = *path++; |
|
|
486 | #if 0 |
473 | else |
487 | else |
474 | { |
488 | { |
475 | STRLEN cl; |
489 | STRLEN cl; |
476 | to_utf8_fold (path, dstp, &cl); |
490 | to_utf8_fold (path, dstp, &cl); |
477 | dstp += cl; |
491 | dstp += cl; |
478 | path += is_utf8_char (path); |
492 | path += is_utf8_char (path); |
479 | } |
493 | } |
|
|
494 | #endif |
480 | } |
495 | } |
481 | |
496 | |
482 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
497 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
483 | } |
498 | } |
484 | OUTPUT: |
499 | OUTPUT: |