]> diplodocus.org Git - nmh/blobdiff - sbr/crawl_folders.c
ssequal.c: Move interface to own file.
[nmh] / sbr / crawl_folders.c
index 004e8cf2f4b545212a7ebf7dad338be716d5bcd0..9f1327ce038ef81563dbcc80bb4b03f15329410e 100644 (file)
@@ -1,21 +1,19 @@
-
-/*
- * crawl_folders.c -- crawl folder hierarchy
+/* crawl_folders.c -- crawl folder hierarchy
  *
  * This code is Copyright (c) 2008, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/crawl_folders.h>
-#include <h/utils.h>
+#include "h/mh.h"
+#include "error.h"
+#include "h/crawl_folders.h"
+#include "h/utils.h"
 
 struct crawl_context {
     int max;                   /* how many folders we currently can hold in
                                 * the array `folders', increased by
                                 * CRAWL_NUMFOLDERS at a time */
-    int total;                 /* how many `folders' actually has */
     char **folders;            /* the array of folders */
     int start;
     int foldp;
@@ -29,7 +27,7 @@ struct crawl_context {
 static void
 add_folder (char *fold, struct crawl_context *crawl)
 {
-    register int i, j;
+    int i, j;
 
     /* if necessary, reallocate the space for folder names */
     if (crawl->foldp >= crawl->max) {
@@ -47,7 +45,6 @@ add_folder (char *fold, struct crawl_context *crawl)
            return;
        }
 
-    crawl->total++;
     crawl->folders[crawl->foldp++] = fold;
 }
 
@@ -66,9 +63,9 @@ add_children (char *name, struct crawl_context *crawl)
     }
 
     if (strcmp (name, ".") == 0) {
-       prefix = getcpy ("");
+       prefix = mh_xstrdup("");
     } else {
-       prefix = concat (name, "/", (void *)NULL);
+       prefix = concat(name, "/", NULL);
     }
 
     while ((dp = readdir (dd))) {
@@ -85,7 +82,7 @@ add_children (char *name, struct crawl_context *crawl)
        if (!strcmp (dp->d_name, ".") || !strcmp (dp->d_name, "..")) {
            continue;
        }
-       child = concat (prefix, dp->d_name, (void *)NULL);
+       child = concat(prefix, dp->d_name, NULL);
        /* If we have no d_type or d_type is DT_LNK or DT_UNKNOWN, stat the
         * child to see what it is. */
        if (child_is_folder == -1) {
@@ -138,7 +135,7 @@ crawl_folders (char *dir, crawl_callback_t *callback, void *baton)
     struct crawl_context *crawl;
     NEW(crawl);
     crawl->max = CRAWL_NUMFOLDERS;
-    crawl->total = crawl->start = crawl->foldp = 0;
+    crawl->start = crawl->foldp = 0;
     crawl->folders = mh_xmalloc (crawl->max * sizeof(*crawl->folders));
 
     crawl_folders_body (crawl, dir, callback, baton);