From: Adam Dickmeiss Date: Fri, 24 Nov 1995 11:31:35 +0000 (+0000) Subject: Commands add & del read filenames from stdin if source directory is X-Git-Tag: ZEBRA.1.0~668 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=94134a7a5eff3cea5c2971836f7da89ac7ba7791;p=idzebra-moved-to-github.git Commands add & del read filenames from stdin if source directory is empty. Match criteria supports 'constant' strings. --- diff --git a/index/extract.c b/index/extract.c index 56bc949..413b6eb 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.30 1995-11-22 17:19:16 adam + * Revision 1.31 1995-11-24 11:31:35 adam + * Commands add & del read filenames from stdin if source directory is + * empty. + * Match criteria supports 'constant' strings. + * + * Revision 1.30 1995/11/22 17:19:16 adam * Record management uses the bfile system. * * Revision 1.29 1995/11/21 15:01:14 adam @@ -573,15 +578,15 @@ static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup, else if (*s == '$') { int spec_len; - char special[32]; + char special[64]; const char *spec_src = NULL; const char *s1 = ++s; while (*s1 && *s1 != ' ' && *s1 != '\t') s1++; spec_len = s1 - s; - if (spec_len > 31) - spec_len = 31; + if (spec_len > 63) + spec_len = 63; memcpy (special, s, spec_len); special[spec_len] = '\0'; s = s1; @@ -599,8 +604,25 @@ static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup, if (spec_src) { strcpy (dst, spec_src); - dst += strlen(spec_src); + dst += strlen (spec_src); + } + } + else if (*s == '\"' || *s == '\'') + { + int stopMarker = *s++; + char tmpString[64]; + int i = 0; + + while (*s && *s != stopMarker) + { + if (i < 63) + tmpString[i++] = *s; } + if (*s) + s++; + tmpString[i] = '\0'; + strcpy (dst, tmpString); + dst += strlen (tmpString); } else { @@ -639,7 +661,7 @@ int fileExtract (SYSNO *sysno, const char *fname, struct recordGroup *rGroup, else sprintf (gprefix, "%s.", rGroup->groupName); - logf (LOG_DEBUG, "fileExtractAdd %s", fname); + logf (LOG_DEBUG, "fileExtract %s", fname); /* determine file extension */ for (i = strlen(fname); --i >= 0; ) @@ -710,25 +732,27 @@ int fileExtract (SYSNO *sysno, const char *fname, struct recordGroup *rGroup, /* perform match if sysno not known and if match criteria is specified */ matchStr = NULL; - if (!sysno && file_match) + if (!sysno) { - char *rinfo; - + sysnotmp = 0; sysno = &sysnotmp; - matchStr = fileMatchStr(&reckeys, rGroup, fname, file_type, - file_match); - if (matchStr) + if (file_match) { - rinfo = dict_lookup (matchDict, matchStr); - if (rinfo) - memcpy (sysno, rinfo+1, sizeof(*sysno)); + char *rinfo; + + matchStr = fileMatchStr(&reckeys, rGroup, fname, file_type, + file_match); + if (matchStr) + { + rinfo = dict_lookup (matchDict, matchStr); + if (rinfo) + memcpy (sysno, rinfo+1, sizeof(*sysno)); + } else - *sysno = 0; - } - else - { - logf (LOG_WARN, "Record not inserted"); - return 0; + { + logf (LOG_WARN, "Record not inserted"); + return 0; + } } } diff --git a/index/trav.c b/index/trav.c index 4ea6fb6..4ac3629 100644 --- a/index/trav.c +++ b/index/trav.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: trav.c,v $ - * Revision 1.11 1995-11-22 17:19:19 adam + * Revision 1.12 1995-11-24 11:31:37 adam + * Commands add & del read filenames from stdin if source directory is + * empty. + * Match criteria supports 'constant' strings. + * + * Revision 1.11 1995/11/22 17:19:19 adam * Record management uses the bfile system. * * Revision 1.10 1995/11/21 15:01:16 adam @@ -90,6 +95,14 @@ static void repositoryExtractR (int deleteFlag, char *rep, } +static void stdinExtractR (int deleteFlag, struct recordGroup *rGroup) +{ + char tmppath[256]; + + while (scanf ("%s", tmppath) == 1) + fileExtract (NULL, tmppath, rGroup, deleteFlag); +} + static void repositoryUpdateR (struct dirs_info *di, struct dirs_entry *dst, const char *base, char *src, struct recordGroup *rGroup) @@ -230,7 +243,10 @@ void repositoryDelete (struct recordGroup *rGroup) assert (rGroup->path); strcpy (src, rGroup->path); - repositoryExtractR (1, src, rGroup); + if (*src == '\0') + stdinExtractR (1, rGroup); + else + repositoryExtractR (1, src, rGroup); } void repositoryAdd (struct recordGroup *rGroup) @@ -239,6 +255,9 @@ void repositoryAdd (struct recordGroup *rGroup) assert (rGroup->path); strcpy (src, rGroup->path); - repositoryExtractR (0, src, rGroup); + if (*src == '\0') + stdinExtractR (0, rGroup); + else + repositoryExtractR (0, src, rGroup); }