aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <>2008-02-15 18:16:48 +0000
committerjames <>2008-02-15 18:16:48 +0000
commit80588cc4e79b19ea5b73f100e66ab5e5102dfc65 (patch)
tree6c9a5f81c59a2575bbed6cf8af231e7694b6c779
parent6749d6db190c477885e0b5ea0d9bb4fddcdff12e (diff)
downloadsympathy-80588cc4e79b19ea5b73f100e66ab5e5102dfc65.tar.gz
sympathy-80588cc4e79b19ea5b73f100e66ab5e5102dfc65.tar.bz2
sympathy-80588cc4e79b19ea5b73f100e66ab5e5102dfc65.zip
*** empty log message ***
-rw-r--r--src/lockfile.c85
-rw-r--r--src/lockfile.h7
2 files changed, 54 insertions, 38 deletions
diff --git a/src/lockfile.c b/src/lockfile.c
index cc0ad42..aa39f7b 100644
--- a/src/lockfile.c
+++ b/src/lockfile.c
@@ -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
-
diff --git a/src/lockfile.h b/src/lockfile.h
index 03d5ed3..c8b77f2 100644
--- a/src/lockfile.h
+++ b/src/lockfile.h
@@ -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 ***
*
@@ -23,8 +26,10 @@
#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;