X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Futils.c;h=69d2a9383f0117ee05a5d017037b91e72fed6141;hb=aefcf5ac90dee434d605167b6a719c58c0ffcf03;hp=580363a950dec0ee7f77afb1681c60f2880217b3;hpb=cc593def97b4f6f271fad15805b61c4773c4e30a;p=ppp.git diff --git a/pppd/utils.c b/pppd/utils.c index 580363a..69d2a93 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -17,7 +17,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: utils.c,v 1.14 2001/05/23 03:39:14 paulus Exp $" +#define RCSID "$Id: utils.c,v 1.19 2002/10/27 12:56:26 fcusack Exp $" #include #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -208,6 +209,28 @@ vslprintf(buf, buflen, fmt, args) neg = 0; ++fmt; switch (c) { + case 'l': + c = *fmt++; + switch (c) { + case 'd': + val = va_arg(args, long); + if (val < 0) { + neg = 1; + val = -val; + } + base = 10; + break; + case 'u': + val = va_arg(args, unsigned long); + base = 10; + break; + default: + *buf++ = '%'; --buflen; + *buf++ = 'l'; --buflen; + --fmt; /* so %lz outputs %lz etc. */ + continue; + } + break; case 'd': i = va_arg(args, int); if (i < 0) { @@ -790,12 +813,12 @@ dump_packet(const char *tag, unsigned char *p, int len) return; } - dbglog("%s %P", tag, p - PPP_HDRLEN, len + PPP_HDRLEN); + dbglog("%s %P", tag, p, len); } /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR -#ifdef _linux_ +#ifdef __linux__ #define LOCK_DIR "/var/lock" #else #ifdef SVR4 @@ -820,7 +843,7 @@ lock(dev) result = mklock (dev, (void *) 0); if (result == 0) { - strlcpy(lock_file, sizeof(lock_file), dev); + strlcpy(lock_file, dev, sizeof(lock_file)); return 0; } @@ -851,9 +874,20 @@ lock(dev) major(sbuf.st_rdev), minor(sbuf.st_rdev)); #else char *p; + char lockdev[MAXPATHLEN]; + + if ((p = strstr(dev, "dev/")) != NULL) { + dev = p + 4; + strncpy(lockdev, dev, MAXPATHLEN-1); + lockdev[MAXPATHLEN-1] = 0; + while ((p = strrchr(lockdev, '/')) != NULL) { + *p = '_'; + } + dev = lockdev; + } else + if ((p = strrchr(dev, '/')) != NULL) + dev = p + 1; - if ((p = strrchr(dev, '/')) != NULL) - dev = p + 1; slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev); #endif