chiark / gitweb /
*** empty log message ***
authorjames <james>
Fri, 15 Feb 2008 18:16:36 +0000 (18:16 +0000)
committerjames <james>
Fri, 15 Feb 2008 18:16:36 +0000 (18:16 +0000)
src/lockfile.c
src/lockfile.h

index cc0ad4276b164e7c35fdaabc0be04b61dc73f6d5..aa39f7b3c2f18104b3c30e4dec647cb39cd1411e 100644 (file)
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.4  2008/02/15 18:16:48  james
+ * *** empty log message ***
+ *
  * Revision 1.3  2008/02/15 18:16:35  james
  * *** empty log message ***
  *
@@ -75,8 +78,9 @@ filelist_add (Filelist * fl, char *fn)
   if (i >= FILE_LIST_MAX_LEN)
     return;
 
-  for (fle=fl->head;fle;fle=fle->next) 
-       if (!strcmp(fle->name,fn)) return;
+  for (fle = fl->head; fle; fle = fle->next)
+    if (!strcmp (fle->name, fn))
+      return;
 
   fle = malloc (sizeof (Filelist_ent));
 
@@ -94,15 +98,17 @@ filelist_free (Filelist * fl)
   free (fl);
 }
 
-void filelist_print(Filelist *fl,FILE *f)
+void
+filelist_print (Filelist * fl, FILE * f)
 {
-Filelist_ent *fle;
-if (!fl) {
-  fprintf(f,"(empty list)\n");
-  return;
-}
-  for (fle=fl->head;fle;fle=fle->next) 
-  fprintf(f,"%s\n",fle->name);
+  Filelist_ent *fle;
+  if (!fl)
+    {
+      fprintf (f, "(empty list)\n");
+      return;
+    }
+  for (fle = fl->head; fle; fle = fle->next)
+    fprintf (f, "%s\n", fle->name);
 }
 
 
@@ -189,7 +195,7 @@ lockfile_add_places (Filelist * fl, char *leaf)
   char *lock_dirs[] =
     { "/var/lock/uucp", "/var/spool/lock", "/var/spool/uucp", "/etc/locks",
     "/usr/spool/uucp", "/var/spool/locks", "/usr/spool/lock",
-      "/usr/spool/locks",
+    "/usr/spool/locks",
     "/usr/spool/uucp/LCK"
   };
   int i;
@@ -281,9 +287,10 @@ lockfile_check_dir_for_dev (Filelist * fl, char *dir, dev_t dev)
 
   d = opendir (dir);
 
-  if (!d) return;
+  if (!d)
+    return;
 
-   while ((de = readdir (d)))
+  while ((de = readdir (d)))
     {
       strcpy (buf, dir);
       strcat (buf, de->d_name);
@@ -302,7 +309,7 @@ lockfile_check_dir_for_dev (Filelist * fl, char *dir, dev_t dev)
 }
 
 Filelist *
-lockfile_make_list(char *device)
+lockfile_make_list (char *device)
 {
   struct stat dev_stat;
   Filelist *ret = NULL;
@@ -326,46 +333,50 @@ lockfile_make_list(char *device)
   return ret;
 }
 
-void lockfile_remove_stale(Filelist *fl)
+void
+lockfile_remove_stale (Filelist * fl)
 {
 
 
 }
 
 
-Filelist *lockfile_lock(Filelist *fl)
+Filelist *
+lockfile_lock (Filelist * fl)
 {
-Filelist *ret;
-Filelist_ent *fle;
+  Filelist *ret;
+  Filelist_ent *fle;
 
-ret=filelist_new();
+  ret = filelist_new ();
 
-lockfile_remove_stale(fl);
+  lockfile_remove_stale (fl);
 
-for (fle=fl->head;fle;fle=fle->next) {
-       if (lockfile_make(fle->name)) {
-               fprintf(stderr,"Failed to get lockfile %s\n",fle->name);
-               filelist_free(ret);
-               return NULL;
-       }
-       filelist_add(ret,fle->name);
-}
+  for (fle = fl->head; fle; fle = fle->next)
+    {
+      if (lockfile_make (fle->name))
+        {
+          fprintf (stderr, "Failed to get lockfile %s\n", fle->name);
+          filelist_free (ret);
+          return NULL;
+        }
+      filelist_add (ret, fle->name);
+    }
 
-return ret;
+  return ret;
 }
 
 #if 1
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
 {
-Filelist *fl=lockfile_make_list("/dev/ttyS0");
-Filelist *fll;
-Filelist_ent *fle;
+  Filelist *fl = lockfile_make_list ("/dev/ttyS0");
+  Filelist *fll;
+  Filelist_ent *fle;
 
-filelist_print(fl,stdout);
+  filelist_print (fl, stdout);
 
-fll=lockfile_lock(fl);
+  fll = lockfile_lock (fl);
 
-filelist_print(fll,stdout);
+  filelist_print (fll, stdout);
 }
 #endif
-
index 03d5ed31ef56f3f34bcb86d319ca86ca348e22c5..c8b77f2f6bc1bc66403e02442d08753fb297ae35 100644 (file)
@@ -12,6 +12,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2008/02/15 18:16:36  james
+ * *** empty log message ***
+ *
  * Revision 1.2  2008/02/15 16:48:56  james
  * *** empty log message ***
  *
 #ifndef __LOCKFILE_H__
 #define __LOCKFILE_H__
 
+#define FILE_LIST_MAX_LEN 1024
+
 typedef struct Filelist_ent {
-       char name[1024];
+       char name[FILE_LIST_MAX_LEN];
        struct Filelist_ent *next;
 } Filelist_ent;