Commands add & del read filenames from stdin if source directory is
[idzebra-moved-to-github.git] / index / trav.c
index c929e51..4ac3629 100644 (file)
@@ -4,7 +4,15 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: trav.c,v $
- * Revision 1.10  1995-11-21 15:01:16  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
  * New general match criteria implemented.
  * New feature: document groups.
  *
@@ -56,7 +64,8 @@ static int repComp (const char *a, const char *b, size_t len)
     return memcmp (a, b, len);
 }
 
-static void repositoryExtractR (char *rep, struct recordGroup *rGroup)
+static void repositoryExtractR (int deleteFlag, char *rep,
+                                struct recordGroup *rGroup)
 {
     struct dir_entry *e;
     int i;
@@ -75,10 +84,10 @@ static void repositoryExtractR (char *rep, struct recordGroup *rGroup)
         switch (e[i].kind)
         {
         case dirs_file:
-            fileExtract (NULL, rep, rGroup, 0);
+            fileExtract (NULL, rep, rGroup, deleteFlag);
             break;
         case dirs_dir:
-            repositoryExtractR (rep, rGroup);
+            repositoryExtractR (deleteFlag, rep, rGroup);
             break;
         }
     }
@@ -86,6 +95,14 @@ static void repositoryExtractR (char *rep, struct recordGroup *rGroup)
 
 }
 
+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)
@@ -220,11 +237,27 @@ void repositoryUpdate (struct recordGroup *rGroup)
     dict_close (dict);
 }
 
-void repositoryExtract (struct recordGroup *rGroup)
+void repositoryDelete (struct recordGroup *rGroup)
+{
+    char src[256];
+
+    assert (rGroup->path);
+    strcpy (src, rGroup->path);
+    if (*src == '\0')
+       stdinExtractR (1, rGroup);
+    else
+       repositoryExtractR (1, src, rGroup);
+}
+
+void repositoryAdd (struct recordGroup *rGroup)
 {
     char src[256];
 
     assert (rGroup->path);
     strcpy (src, rGroup->path);
-    repositoryExtractR (src, rGroup);
+    if (*src == '\0')
+       stdinExtractR (0, rGroup);
+    else
+       repositoryExtractR (0, src, rGroup);
 }
+