]> err.no Git - dpkg/commitdiff
Fix coding style
authorGuillem Jover <guillem@debian.org>
Wed, 21 May 2008 18:24:53 +0000 (21:24 +0300)
committerGuillem Jover <guillem@debian.org>
Sun, 20 Jul 2008 14:34:01 +0000 (17:34 +0300)
src/filters.c
src/filters.h

index 98002a19b582fb84a84b23d2bedf1d7d6718f0bb..88aeb719e3016a8044ed42b5c2c838805152b54c 100644 (file)
 #include "main.h"
 
 static struct filterlist *filters = NULL;
-  static struct filterlist **filtertail = &filters;
-
-static void loadfilter(const char *fn) {
-  FILE *file;
-  char linebuf[1024];
-
-  file = fopen(fn, "r");
-  if (!file) {
-    warningf(_("failed to open filter file `%.255s' for reading"), fn);
-    return;
-  }
-
-  while (fgets(linebuf, sizeof(linebuf), file)) {
-    struct filterlist *filter;
-
-    filter = m_malloc(sizeof(struct filterlist));
-    memset(filter, 0, sizeof(struct filterlist));
-
-    if (linebuf[0] == '#' || linebuf[0] == '\n') {
-      continue;
-    }
-
-    if (linebuf[strlen(linebuf) - 1] == '\n')
-      linebuf[strlen(linebuf) - 1] = '\0';
-
-    if (linebuf[0] == '+') {
-      filter->positive = 1;
-    } else if (linebuf[0] == '-') {
-      filter->positive = 0;
-    } else {
-      warningf(_("Invalid filter line: `%.255s'"), linebuf);
-      free(filter);
-      continue;
-    }
-
-    filter->filterstring = strdup(&linebuf[1]);
-    if (!filter->filterstring) {
-      ohshite(_("Error allocating memory for filter entry"));
-    }
-
-    *filtertail = filter;
-    filtertail = &filter->next;
-  }
-
-  if (ferror(file))
-    ohshite(_("read error in configuration file `%.255s'"), fn);
-
-  if (fclose(file))
-    ohshite(_("error closing configuration file `%.255s'"), fn);
+static struct filterlist **filtertail = &filters;
+
+static void
+loadfilter(const char *fn)
+{
+       FILE *file;
+       char linebuf[1024];
+
+       file = fopen(fn, "r");
+       if (!file) {
+               warningf(_("failed to open filter file '%.255s' for reading"),
+                        fn);
+               return;
+       }
+
+       while (fgets(linebuf, sizeof(linebuf), file)) {
+               struct filterlist *filter;
+
+               filter = m_malloc(sizeof(struct filterlist));
+               memset(filter, 0, sizeof(struct filterlist));
+
+               if (linebuf[0] == '#' || linebuf[0] == '\n')
+                       continue;
+
+               if (linebuf[strlen(linebuf) - 1] == '\n')
+                       linebuf[strlen(linebuf) - 1] = '\0';
+
+               if (linebuf[0] == '+')
+                       filter->positive = 1;
+               else if (linebuf[0] == '-')
+                       filter->positive = 0;
+               else {
+                       warningf(_("invalid filter line: '%.255s'"), linebuf);
+                       free(filter);
+                       continue;
+               }
+
+               filter->filterstring = strdup(&linebuf[1]);
+               if (!filter->filterstring)
+                       ohshite(_("error allocating memory for filter entry"));
+
+               *filtertail = filter;
+               filtertail = &filter->next;
+       }
+
+       if (ferror(file))
+               ohshite(_("read error in configuration file '%.255s'"), fn);
+
+       if (fclose(file))
+               ohshite(_("error closing configuration file '%.255s'"), fn);
 }
 
-void loadfilters(void) {
-  struct dirent *dent;
-  char *dirname = CONFIGDIR "/filters.d";
-  DIR *dir = opendir(dirname);
-  if (!dir) {
-    if (errno == ENOENT)
-      return;
-    else
-      ohshite(_("Error opening filters.d"));
-  }
-
-  while ((dent = readdir(dir)) != NULL) {
-    struct stat statbuf;
-    char *file = m_malloc(strlen(dirname) + 1 + strlen(dent->d_name) + 1);
-    sprintf(file, "%s/%s", dirname, dent->d_name);
-    if (stat(file, &statbuf) != 0) {
-      ohshite(_("Error stating file"));
-    }
-    if (S_ISREG(statbuf.st_mode)) {
-      loadfilter(file);
-    }
-    free(file);
-  }
-  closedir(dir);
+void
+loadfilters(void)
+{
+       struct dirent *dent;
+       char *dirname = CONFIGDIR "/filters.d";
+       DIR *dir = opendir(dirname);
+
+       if (!dir) {
+               if (errno == ENOENT)
+                       return;
+               else
+                       ohshite(_("error opening filters.d"));
+       }
+
+       while ((dent = readdir(dir)) != NULL) {
+               struct stat statbuf;
+               char *file = m_malloc(strlen(dirname) + 1 +
+                                     strlen(dent->d_name) + 1);
+
+               sprintf(file, "%s/%s", dirname, dent->d_name);
+               if (stat(file, &statbuf) != 0)
+                       ohshite(_("error stating file '%s'"), file);
+               if (S_ISREG(statbuf.st_mode))
+                       loadfilter(file);
+               free(file);
+       }
+       closedir(dir);
 }
 
-int filter_should_skip(struct TarInfo *ti) {
-  int remove = 0;
-  if (filters) {
-    struct filterlist *f;
-
-    /* Last match wins */
-    for (f = filters; f != NULL; f = f->next) {
-      debug(dbg_eachfile, "tarobject comparing '%s' and '%s'", &ti->Name[1], f->filterstring);
-      if (fnmatch(f->filterstring, &ti->Name[1], 0) == 0) {
-       if (f->positive == 0) {
-         remove = 1;
-         debug(dbg_eachfile, "do_filter removing %s", ti->Name);
-       } else {
-         remove = 0;
-         debug(dbg_eachfile, "do_filter including %s", ti->Name);
+static int
+do_filter_should_skip(struct TarInfo *ti)
+{
+       int remove = 0;
+       struct filterlist *f;
+
+       /* Last match wins. */
+       for (f = filters; f != NULL; f = f->next) {
+               debug(dbg_eachfile, "tarobject comparing '%s' and '%s'",
+                     &ti->Name[1], f->filterstring);
+
+               if (fnmatch(f->filterstring, &ti->Name[1], 0) == 0) {
+                       if (f->positive == 0) {
+                               remove = 1;
+                               debug(dbg_eachfile, "do_filter removing %s",
+                                     ti->Name);
+                       } else {
+                               remove = 0;
+                               debug(dbg_eachfile, "do_filter including %s",
+                                     ti->Name);
+                       }
+               }
        }
-      }
-    }
-
-    if (remove) {
-      for (f = filters; f != NULL; f = f->next) {
-       char *pattern;
-
-       pattern = m_malloc(strlen(ti->Name) + 1);
-       strcpy(pattern, &ti->Name[1]);
-       strcat(pattern, "*");
-
-       debug(dbg_eachfile,
-             "tarobject seeing if '%s' needs to be reincluded", &ti->Name[1]);
-       if ((f->positive == 1) &&
-           (ti->Type == Directory) &&
-           (fnmatch(pattern, f->filterstring, 0) == 0)) {
-         remove = 0;
-         debug(dbg_eachfile, "tarobject reincluding %s", ti->Name);
+
+       if (remove) {
+               for (f = filters; f != NULL; f = f->next) {
+                       char *pattern;
+
+                       pattern = m_malloc(strlen(ti->Name) + 1);
+                       strcpy(pattern, &ti->Name[1]);
+                       strcat(pattern, "*");
+
+                       debug(dbg_eachfile,
+                             "tarobject seeing if '%s' needs to be reincluded",
+                             &ti->Name[1]);
+                       if ((f->positive == 1) &&
+                           (ti->Type == Directory) &&
+                           (fnmatch(pattern, f->filterstring, 0) == 0)) {
+                               remove = 0;
+                               debug(dbg_eachfile, "tarobject reincluding %s",
+                                     ti->Name);
+                       }
+               }
        }
-      }
-    }
-  }
-  return remove;
+
+       return remove;
+}
+
+int
+filter_should_skip(struct TarInfo *ti)
+{
+       if (filters)
+               return do_filter_should_skip(ti);
+       else
+               return 0;
 }
+
index 540337ce346bbf2d167949691a49132b67472c5c..993f52860fc90e11c1bd0b3db1ef24948e11c79b 100644 (file)
@@ -14,9 +14,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifndef DPKG_FILTERS_H
@@ -28,9 +28,9 @@ void loadfilters(void);
 int filter_should_skip(struct TarInfo *ti);
 
 struct filterlist {
-  int positive;
-  char *filterstring;
-  struct filterlist *next;
+       int positive;
+       char *filterstring;
+       struct filterlist *next;
 };
 
 #endif