… | |
… | |
451 | && data[ 6] == 0x1a |
451 | && data[ 6] == 0x1a |
452 | && data[ 7] == 0x0a) |
452 | && data[ 7] == 0x0a) |
453 | RETVAL = "image/png"; |
453 | RETVAL = "image/png"; |
454 | else if (data_len >= sizeof (jxl_header) && memcmp (data, jxl_header, sizeof (jxl_header)) == 0) |
454 | else if (data_len >= sizeof (jxl_header) && memcmp (data, jxl_header, sizeof (jxl_header)) == 0) |
455 | RETVAL = "image/jxl"; |
455 | RETVAL = "image/jxl"; |
|
|
456 | else if (data_len >= 13 |
|
|
457 | && data[0] == 'G' |
|
|
458 | && data[1] == 'I' |
|
|
459 | && data[2] == 'F' |
|
|
460 | && data[3] == '8' |
|
|
461 | //&& (data[4] == '7' || data[4] == '9') |
|
|
462 | && data[5] == 'a') |
|
|
463 | { |
|
|
464 | RETVAL = "image/gif"; |
|
|
465 | |
|
|
466 | // now see if its animated - we require the netscape application header for this |
|
|
467 | int ofs = 13; |
|
|
468 | |
|
|
469 | if (data[10] & 0x80) |
|
|
470 | ofs += (1 << ((data[10] & 7) + 1)) * 3; |
|
|
471 | |
|
|
472 | if (data_len >= ofs + 2 + 1 + 11) |
|
|
473 | { |
|
|
474 | |
|
|
475 | // skip a graphic control extension block. we assume |
|
|
476 | // there is at most one such block - while the NAB |
|
|
477 | // has to come firstz, some files do not obey this |
|
|
478 | if (data[ofs] == 0x21 && data[ofs + 1] == 0xf9) |
|
|
479 | ofs += 3 + data[ofs + 2] + 1; |
|
|
480 | |
|
|
481 | if (data_len >= ofs + 2 + 1 + 11) |
|
|
482 | if (!memcmp (data + ofs, "\x21\xff\x0bNETSCAPE2.0", sizeof ("\x21\xff\x0bNETSCAPE2.0") - 1)) |
|
|
483 | RETVAL = "video/gif"; |
|
|
484 | } |
|
|
485 | } |
|
|
486 | |
456 | else |
487 | else |
457 | XSRETURN_UNDEF; |
488 | XSRETURN_UNDEF; |
458 | } |
489 | } |
459 | OUTPUT: |
490 | OUTPUT: |
460 | RETVAL |
491 | RETVAL |
… | |
… | |
851 | CODE: |
882 | CODE: |
852 | { |
883 | { |
853 | STRLEN plen; |
884 | STRLEN plen; |
854 | U8 *path = (U8 *)SvPV (pathsv, plen); |
885 | U8 *path = (U8 *)SvPV (pathsv, plen); |
855 | U8 *pend = path + plen; |
886 | U8 *pend = path + plen; |
856 | U8 dst [plen * 6 * 3], *dstp = dst; |
887 | U8 dst [plen * 8 * 3], *dstp = dst; |
857 | |
888 | |
858 | while (path < pend) |
889 | while (path < pend) |
859 | { |
890 | { |
860 | U8 ch = *path; |
891 | U8 ch = *path; |
861 | |
892 | |
… | |
… | |
863 | *dstp++ = *path++; |
894 | *dstp++ = *path++; |
864 | else if (ch >= 'A' && ch <= 'Z') |
895 | else if (ch >= 'A' && ch <= 'Z') |
865 | *dstp++ = *path++ + ('a' - 'A'); |
896 | *dstp++ = *path++ + ('a' - 'A'); |
866 | else if (ch >= '0' && ch <= '9') |
897 | else if (ch >= '0' && ch <= '9') |
867 | { |
898 | { |
|
|
899 | /* version sort, up to 8 digits */ |
868 | STRLEN el, nl = 0; |
900 | STRLEN el, nl = 0; |
869 | while (*path >= '0' && *path <= '9' && path < pend) |
901 | while (*path >= '0' && *path <= '9' && path < pend) |
870 | path++, nl++; |
902 | path++, nl++; |
871 | |
903 | |
872 | for (el = nl; el < 6; el++) |
904 | for (el = nl; el < 8; el++) |
873 | *dstp++ = '0'; |
905 | *dstp++ = '0'; |
874 | |
906 | |
875 | memcpy (dstp, path - nl, nl); |
907 | memcpy (dstp, path - nl, nl); |
876 | dstp += nl; |
908 | dstp += nl; |
877 | } |
909 | } |