Author: durner Date: 2006-06-24 06:23:32 -0700 (Sat, 24 Jun 2006) New Revision: 3030
Modified: Extractor/src/plugins/mimeextractor.c Log: add SVG detection Modified: Extractor/src/plugins/mimeextractor.c =================================================================== --- Extractor/src/plugins/mimeextractor.c 2006-06-23 15:05:28 UTC (rev 3029) +++ Extractor/src/plugins/mimeextractor.c 2006-06-24 13:23:32 UTC (rev 3030) @@ -1,6 +1,6 @@ /* This file is part of libextractor. - (C) 2002, 2003 Vidyut Samanta and Christian Grothoff + (C) 2002, 2003, 2006 Vidyut Samanta and Christian Grothoff libextractor is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -126,6 +126,45 @@ } /** + * Detect SVG + */ +static int svgMatcher(char *data, + size_t len, + ExtraPattern *arg) { + enum {XMLSTART, XMLCLOSE, SVGSTART, ABORT, OK} state; + size_t i; + + i = 0; + state = XMLSTART; + + while (i < len && state != ABORT) { + switch (state) { + case XMLSTART: + if (i + 6 >= len) + state = ABORT; + else if (memcmp(data + i, "<?xml", 5) == 0 && isspace(*(data + i + 5))) + state = XMLCLOSE; + break; + case XMLCLOSE: + if (i + 2 >= len) + state = ABORT; + else if (memcmp(data + i, "?>", 2) == 0) + state = SVGSTART; + break; + case SVGSTART: + if (i + 5 >= len) + state = ABORT; + else if (memcmp(data + i, "<svg", 4) == 0 && isspace(*(data + i + 4))) + state = OK; + } + + i++; + } + + return state == OK; +} + +/** * Use this detector, if the simple header-prefix matching is * sufficient. **/ @@ -236,6 +275,7 @@ { "#!/bin/csh", 10, "application/x-shellscript", DEFAULT}, { "#!/bin/tcsh", 11, "application/x-shellscript", DEFAULT}, { "#!/bin/perl", 11, "application/x-perl", DEFAULT}, + { "", 0, "image/svg+xml", svgMatcher, NULL}, {NULL, 0, NULL, DISABLED}, }; _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn