X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=dotlock.c;h=8f1f3083546e7d67c35dcf5066f353529e1ef0c9;hp=f89fb1f556e9c28bd5fc8391a0389b72d169a8f9;hb=e7a772dca1b86e4036d25038ee67aa34dd217c07;hpb=efe9a0bac26a7dabf3953ea0597ce06b3dcb21fe diff --git a/dotlock.c b/dotlock.c index f89fb1f..8f1f308 100644 --- a/dotlock.c +++ b/dotlock.c @@ -8,30 +8,10 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include +#include -#include -#include -#include -#include #include -#include -#include -#include -#include - -#ifndef _POSIX_PATH_MAX -#include -#endif - #include "dotlock.h" -#include "config.h" #ifdef HAVE_GETOPT_H #include @@ -55,12 +35,6 @@ # endif -# ifndef HAVE_SNPRINTF -extern int snprintf (char *, size_t, const char *, ...); -# endif - -#include - static int DotlockFlags; static int Retry = MAXLOCKATTEMPT; @@ -94,7 +68,9 @@ static int dotlock_unlink (const char *); static int dotlock_lock (const char *); -#define check_flags(a) if (a & DL_FL_ACTIONS) usage (argv[0]) +#define check_flags(a) \ + if (a & (DL_FL_TRY|DL_FL_UNLOCK|DL_FL_UNLINK)) \ + usage(argv[0]) int main (int argc, char **argv) { @@ -111,7 +87,7 @@ int main (int argc, char **argv) /* determine the system's host name */ uname (&utsname); - if (!(Hostname = strdup (utsname.nodename))) /* __MEM_CHECKED__ */ + if (!(Hostname = strdup(utsname.nodename))) return DL_EX_ERROR; if ((p = strchr (Hostname, '.'))) *p = '\0'; @@ -273,7 +249,7 @@ static void END_PRIVILEGED (void) static void usage (const char *av0) { - fprintf (stderr, "dotlock [Mutt-ng %s]\n", VERSION); + fprintf (stderr, "dotlock [Madmutt %s]\n", VERSION); fprintf (stderr, "usage: %s [-t|-f|-u|-d] [-p] [-r ] file\n", av0); fputs ("\noptions:" @@ -502,7 +478,7 @@ static int dotlock_lock (const char *frealpath) { char lockfile[_POSIX_PATH_MAX + LONG_STRING]; char nfslockfile[_POSIX_PATH_MAX + LONG_STRING]; - size_t prev_size = 0; + ssize_t prev_size = 0; int fd; int count = 0; int hard_count = 0;