440
440
pTpe->data.field.eDateFormat = tplFmtRFC3164Date;
441
441
} else if(!strcmp((char*)Buf, "date-rfc3339")) {
442
442
pTpe->data.field.eDateFormat = tplFmtRFC3339Date;
443
} else if(!strcmp((char*)Buf, "date-subseconds")) {
444
pTpe->data.field.eDateFormat = tplFmtSecFrac;
443
445
} else if(!strcmp((char*)Buf, "lowercase")) {
444
446
pTpe->data.field.eCaseConv = tplCaseConvLower;
445
447
} else if(!strcmp((char*)Buf, "uppercase")) {
517
519
++p; /* eat ':' */
518
520
#ifdef FEATURE_REGEXP
520
522
/* APR: R found! regex alarm ! :) */
521
523
++p; /* eat ':' */
525
/* first come the regex type */
528
if(p[0] == 'B' && p[1] == 'R' && p[2] == 'E' && (p[3] == ',' || p[3] == ':')) {
529
pTpe->data.field.typeRegex = TPL_REGEX_BRE;
530
p += 3; /* eat indicator sequence */
531
} else if(p[0] == 'E' && p[1] == 'R' && p[2] == 'E' && (p[3] == ',' || p[3] == ':')) {
532
pTpe->data.field.typeRegex = TPL_REGEX_ERE;
533
p += 3; /* eat indicator sequence */
535
errmsg.LogError(0, NO_ERRCODE, "error: invalid regular expression type, rest of line %s",
540
/* now check for submatch ID */
541
pTpe->data.field.iSubMatchToUse = 0;
543
/* in this case a number follows, which indicates which match
544
* shall be used. This must be a single digit.
547
if(isdigit((int) *p)) {
548
pTpe->data.field.iSubMatchToUse = *p - '0';
553
/* now pull what to do if we do not find a match */
556
if(p[0] == 'D' && p[1] == 'F' && p[2] == 'L' && p[3] == 'T'
557
&& (p[4] == ',' || p[4] == ':')) {
558
pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_DFLTSTR;
559
p += 4; /* eat indicator sequence */
560
} else if(p[0] == 'B' && p[1] == 'L' && p[2] == 'A' && p[3] == 'N' && p[4] == 'K'
561
&& (p[5] == ',' || p[5] == ':')) {
562
pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_BLANK;
563
p += 5; /* eat indicator sequence */
564
} else if(p[0] == 'F' && p[1] == 'I' && p[2] == 'E' && p[3] == 'L' && p[4] == 'D'
565
&& (p[5] == ',' || p[5] == ':')) {
566
pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_WHOLE_FIELD;
567
p += 5; /* eat indicator sequence */
568
} else if(p[0] == 'Z' && p[1] == 'E' && p[2] == 'R' && p[3] == 'O'
569
&& (p[4] == ',' || p[4] == ':')) {
570
pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_ZERO;
571
p += 4; /* eat indicator sequence */
572
} else if(p[0] == ',') { /* empty, use default */
573
pTpe->data.field.nomatchAction = TPL_REGEX_NOMATCH_USE_DFLTSTR;
574
/* do NOT eat indicator sequence, as this was already eaten - the
575
* comma itself is already part of the next field.
578
errmsg.LogError(0, NO_ERRCODE, "error: invalid regular expression type, rest of line %s",
583
/* now check for match ID */
584
pTpe->data.field.iMatchToUse = 0;
586
/* in this case a number follows, which indicates which match
587
* shall be used. This must be a single digit.
590
if(isdigit((int) *p)) {
591
pTpe->data.field.iMatchToUse = *p - '0';
524
597
/* There is something more than an R , this is invalid ! */
525
598
/* Complain on extra characters */
526
errmsg.LogError(NO_ERRCODE, "error: invalid character in frompos after \"R\", property: '%%%s'",
599
errmsg.LogError(0, NO_ERRCODE, "error: invalid character in frompos after \"R\", property: '%%%s'",
529
602
pTpe->data.field.has_regex = 1;
603
dbgprintf("we have a regexp and use match #%d, submatch #%d\n",
604
pTpe->data.field.iMatchToUse, pTpe->data.field.iSubMatchToUse);
532
607
/* now we fall through the "regular" FromPos code */
622
697
/* Now i compile the regex */
623
698
/* Remember that the re is an attribute of the Template entry */
624
699
if((iRetLocal = objUse(regexp, LM_REGEXP_FILENAME)) == RS_RET_OK) {
625
dbgprintf("compile data.field.re ptr: %p (pTpe %p)\n", (&(pTpe->data.field.re)), pTpe);
626
if(regexp.regcomp(&(pTpe->data.field.re), (char*) regex_char, 0) != 0) {
701
iOptions = (pTpe->data.field.typeRegex == TPL_REGEX_ERE) ? REG_EXTENDED : 0;
702
if(regexp.regcomp(&(pTpe->data.field.re), (char*) regex_char, iOptions) != 0) {
627
703
dbgprintf("error: can not compile regex: '%s'\n", regex_char);
628
704
pTpe->data.field.has_regex = 2;