ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/CV.xs
(Generate patch)

Comparing CV/CV.xs (file contents):
Revision 1.40 by root, Sat Nov 25 15:00:51 2006 UTC vs.
Revision 1.43 by root, Sun May 3 08:16:47 2009 UTC

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
30typedef char *octet_string;
27 31
28struct jpg_err_mgr 32struct 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
206const char * 210const char *
207magic (const char *path) 211magic (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)
223} 227}
224 OUTPUT: 228 OUTPUT:
225 RETVAL 229 RETVAL
226 230
227const char * 231const char *
228magic_mime (const char *path) 232magic_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)
398compare (GdkPixbuf *a, GdkPixbuf *b) 402compare (GdkPixbuf *a, GdkPixbuf *b)
399 PPCODE: 403 PPCODE:
400{ 404{
401 int w = gdk_pixbuf_get_width (a); 405 int w = gdk_pixbuf_get_width (a);
402 int h = gdk_pixbuf_get_height (a); 406 int h = gdk_pixbuf_get_height (a);
407
403 int sa = gdk_pixbuf_get_rowstride (a); 408 int sa = gdk_pixbuf_get_rowstride (a);
404 int sb = gdk_pixbuf_get_rowstride (b); 409 int sb = gdk_pixbuf_get_rowstride (b);
405 410
406 guchar *pa = gdk_pixbuf_get_pixels (a); 411 guchar *pa = gdk_pixbuf_get_pixels (a);
407 guchar *pb = gdk_pixbuf_get_pixels (b); 412 guchar *pb = gdk_pixbuf_get_pixels (b);
440 445
441############################################################################# 446#############################################################################
442 447
443MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer 448MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer
444 449
450# currently only works for filenames (octet strings)
451
445SV * 452SV *
446foldcase (SV *pathsv) 453foldcase (SV *pathsv)
447 PROTOTYPE: $ 454 PROTOTYPE: $
448 CODE: 455 CODE:
449{ 456{
450 STRLEN plen; 457 STRLEN plen;
451 U8 *path = (U8 *)SvPVutf8 (pathsv, plen); 458 U8 *path = (U8 *)SvPV (pathsv, plen);
452 U8 *pend = path + plen; 459 U8 *pend = path + plen;
453 U8 dst [plen * 6 * 3], *dstp = dst; 460 U8 dst [plen * 6 * 3], *dstp = dst;
454 461
455 while (path < pend) 462 while (path < pend)
456 { 463 {
457 U8 ch = *path; 464 U8 ch = *path;
458 465
459 if (ch >= 'a' && ch <= 'z') 466 if (ch >= 'a' && ch <= 'z')
460 *dstp++ = *path++; 467 *dstp++ = *path++;
468 else if (ch >= 'A' && ch <= 'Z')
469 *dstp++ = *path++ + ('a' - 'A');
461 else if (ch >= '0' && ch <= '9') 470 else if (ch >= '0' && ch <= '9')
462 { 471 {
463 STRLEN el, nl = 0; 472 STRLEN el, nl = 0;
464 while (*path >= '0' && *path <= '9' && path < pend) 473 while (*path >= '0' && *path <= '9' && path < pend)
465 path++, nl++; 474 path++, nl++;
468 *dstp++ = '0'; 477 *dstp++ = '0';
469 478
470 memcpy (dstp, path - nl, nl); 479 memcpy (dstp, path - nl, nl);
471 dstp += nl; 480 dstp += nl;
472 } 481 }
482 else
483 *dstp++ = *path++;
484#if 0
473 else 485 else
474 { 486 {
475 STRLEN cl; 487 STRLEN cl;
476 to_utf8_fold (path, dstp, &cl); 488 to_utf8_fold (path, dstp, &cl);
477 dstp += cl; 489 dstp += cl;
478 path += is_utf8_char (path); 490 path += is_utf8_char (path);
479 } 491 }
492#endif
480 } 493 }
481 494
482 RETVAL = newSVpvn ((const char *)dst, dstp - dst); 495 RETVAL = newSVpvn ((const char *)dst, dstp - dst);
483} 496}
484 OUTPUT: 497 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines