+ case MIME_MAGIC_REGEX :
+ DEBUG_printf(("5mime_check_rules: regex(%d, \"%s\")", rules->offset,
+ rules->value.stringv));
+
+ /*
+ * Load the buffer if necessary...
+ */
+
+ if (fb->offset < 0 || rules->offset < fb->offset ||
+ (rules->offset + rules->length) > (fb->offset + fb->length))
+ {
+ /*
+ * Reload file buffer...
+ */
+
+ cupsFileSeek(fb->fp, rules->offset);
+ fb->length = cupsFileRead(fb->fp, (char *)fb->buffer,
+ sizeof(fb->buffer));
+ fb->offset = rules->offset;
+
+ DEBUG_printf(("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length));
+
+ DEBUG_printf(("5mime_check_rules: loaded %d byte fb->buffer at %d, starts "
+ "with \"%c%c%c%c\".",
+ fb->length, fb->offset, fb->buffer[0], fb->buffer[1],
+ fb->buffer[2], fb->buffer[3]));
+ }
+
+ /*
+ * Compare the buffer against the string. If the file is too
+ * short then don't compare - it can't match...
+ */
+
+ if (fb->length > 0)
+ {
+ char temp[MIME_MAX_BUFFER + 1];
+ /* Temporary buffer */
+
+ memcpy(temp, fb->buffer, (size_t)fb->length);
+ temp[fb->length] = '\0';
+ result = !regexec(&(rules->value.rev), temp, 0, NULL, 0);
+ }
+
+ DEBUG_printf(("5mime_check_rules: result=%d", result));
+ break;
+