diff options
Diffstat (limited to 'contrib/notmuch-deliver/numlib')
-rw-r--r-- | contrib/notmuch-deliver/numlib/Makefile.am | 29 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/atotimet.c | 14 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/atouidt.c | 15 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/changeuidgid.c | 111 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/numlib.h | 97 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strdevt.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strgidt.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strhdevt.c | 29 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strhinot.c | 29 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strhpidt.c | 29 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strhtimet.c | 29 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strinot.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strofft.c | 37 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strpidt.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strsize.c | 62 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strsizet.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/strtimet.c | 26 | ||||
-rw-r--r-- | contrib/notmuch-deliver/numlib/struidt.c | 26 |
18 files changed, 0 insertions, 663 deletions
diff --git a/contrib/notmuch-deliver/numlib/Makefile.am b/contrib/notmuch-deliver/numlib/Makefile.am deleted file mode 100644 index 3d0c2b2c..00000000 --- a/contrib/notmuch-deliver/numlib/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# $Id: Makefile.am,v 1.12 2007/06/30 15:40:53 mrsam Exp $ -# -# Copyright 1998 - 2004 Double Precision, Inc. See COPYING for -# distribution information. - - -CLEANFILES=$(noinst_DATA) -noinst_LTLIBRARIES=\ - libnumlib.la - -noinst_HEADERS=\ - numlib.h -libnumlib_la_SOURCES=\ - atotimet.c \ - atouidt.c \ - changeuidgid.c \ - strdevt.c \ - strgidt.c \ - strhdevt.c \ - strhinot.c \ - strhpidt.c \ - strhtimet.c \ - strinot.c \ - strofft.c \ - strpidt.c \ - strsize.c \ - strsizet.c \ - strtimet.c \ - struidt.c diff --git a/contrib/notmuch-deliver/numlib/atotimet.c b/contrib/notmuch-deliver/numlib/atotimet.c deleted file mode 100644 index d494fd22..00000000 --- a/contrib/notmuch-deliver/numlib/atotimet.c +++ /dev/null @@ -1,14 +0,0 @@ -/* -** Copyright 2003 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: atotimet.c,v 1.1 2003/08/03 03:09:19 mrsam Exp $"; - -LIBMAIL_STRIMPL(time_t, libmail_strtotime_t, libmail_atotime_t) diff --git a/contrib/notmuch-deliver/numlib/atouidt.c b/contrib/notmuch-deliver/numlib/atouidt.c deleted file mode 100644 index 3c01ecf5..00000000 --- a/contrib/notmuch-deliver/numlib/atouidt.c +++ /dev/null @@ -1,15 +0,0 @@ -/* -** Copyright 2003 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: atouidt.c,v 1.1 2004/01/11 02:47:33 mrsam Exp $"; - -LIBMAIL_STRIMPL(uid_t, libmail_strtouid_t, libmail_atouid_t) -LIBMAIL_STRIMPL(gid_t, libmail_strtogid_t, libmail_atogid_t) diff --git a/contrib/notmuch-deliver/numlib/changeuidgid.c b/contrib/notmuch-deliver/numlib/changeuidgid.c deleted file mode 100644 index 56793927..00000000 --- a/contrib/notmuch-deliver/numlib/changeuidgid.c +++ /dev/null @@ -1,111 +0,0 @@ -/* -** Copyright 1998 - 2002 Double Precision, Inc. See COPYING for -** distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include <sys/types.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <grp.h> -#include <pwd.h> -#include <errno.h> - -#include "numlib.h" - -static const char rcsid[]="$Id: changeuidgid.c,v 1.2 2003/01/05 04:01:17 mrsam Exp $"; - -void libmail_changegroup(gid_t gid) -{ - if ( setgid(gid)) - { - perror("setgid"); - exit(1); - } - -#if HAVE_SETGROUPS - if ( getuid() == 0 && setgroups(1, &gid) ) - { - perror("setgroups"); - exit(1); - } -#endif -} - -void libmail_changeuidgid(uid_t uid, gid_t gid) -{ - libmail_changegroup(gid); - if ( setuid(uid)) - { - perror("setuid"); - exit(1); - } -} - -void libmail_changeusername(const char *uname, const gid_t *forcegrp) -{ -struct passwd *pw; -uid_t changeuid; -gid_t changegid; - -/* uname might be a pointer returned from a previous called to getpw(), -** and libc has a problem getting it back. -*/ -char *p=malloc(strlen(uname)+1); - - if (!p) - { - perror("malloc"); - exit(1); - } - strcpy(p, uname); - - errno=ENOENT; - if ((pw=getpwnam(p)) == 0) - { - free(p); - perror("getpwnam"); - exit(1); - } - free(p); - - changeuid=pw->pw_uid; - - if ( !forcegrp ) forcegrp= &pw->pw_gid; - - changegid= *forcegrp; - - if ( setgid( changegid )) - { - perror("setgid"); - exit(1); - } - -#if HAVE_INITGROUPS - if ( getuid() == 0 && initgroups(pw->pw_name, changegid) ) - { - perror("initgroups"); - exit(1); - } -#else -#if HAVE_SETGROUPS - if ( getuid() == 0 && setgroups(1, &changegid) ) - { - perror("setgroups"); - exit(1); - } -#endif -#endif - - if (setuid(changeuid)) - { - perror("setuid"); - exit(1); - } -} diff --git a/contrib/notmuch-deliver/numlib/numlib.h b/contrib/notmuch-deliver/numlib/numlib.h deleted file mode 100644 index 3ed81ee4..00000000 --- a/contrib/notmuch-deliver/numlib/numlib.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef numlib_h -#define numlib_h - -/* -** Copyright 1998 - 2003 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -static const char numlib_h_rcsid[]="$Id: numlib.h,v 1.10 2004/01/11 02:47:33 mrsam Exp $"; - -#ifdef HAVE_CONFIG_H -#include "config.h" /* VPATH build */ -#endif - -#include <sys/types.h> -#include <time.h> - -#define NUMBUFSIZE 60 - -/* Convert various system types to decimal */ - -char *libmail_str_time_t(time_t, char *); -char *libmail_str_off_t(off_t, char *); -char *libmail_str_pid_t(pid_t, char *); -char *libmail_str_dev_t(dev_t, char *); -char *libmail_str_ino_t(ino_t, char *); -char *libmail_str_uid_t(uid_t, char *); -char *libmail_str_gid_t(gid_t, char *); -char *libmail_str_size_t(size_t, char *); - -char *libmail_str_sizekb(unsigned long, char *); /* X Kb or X Mb */ - -/* Convert selected system types to hex */ - -char *libmail_strh_time_t(time_t, char *); -char *libmail_strh_pid_t(pid_t, char *); -char *libmail_strh_ino_t(ino_t, char *); -char *libmail_strh_dev_t(dev_t, char *); - -/* And, now let's do the reverse */ - -time_t libmail_strtotime_t(const char **); -time_t libmail_atotime_t(const char *); - -uid_t libmail_strtouid_t(const char **); -uid_t libmail_atouid_t(const char *); - -gid_t libmail_strtogid_t(const char **); -gid_t libmail_atogid_t(const char *); - - /* Common macros: */ - -#define LIBMAIL_STRIMPL(type, f1, f2) \ -\ -type f1(const char **p)\ -{\ - type n=0;\ - while ( **p >= '0' && **p <= '9') n=n*10 + (char)(*(*p)++ - '0');\ - return n;\ -}\ -\ -type f2(const char *p)\ -{\ - return f1(&p);\ -} - - -/* -** The following functions are used by root to reset its user and group id -** to the authenticated user's. Various functions are provided to handle -** various situations. -*/ - -void libmail_changegroup(gid_t); /* Set the group id only. Also clear any - ** auxiliary group ids */ - -void libmail_changeuidgid(uid_t, gid_t); - /* Set both user id and group id. Also clear - ** aux group ids */ - -void libmail_changeusername(const char *, const gid_t *); - /* - ** Set the userid to the indicate user's. If second argument is - ** not null, it points to the groupid to set. If it's null, the - ** group id is taken from the passwd file. Auxiliary IDs are set - ** to any aux IDs set for the user in the group file. If there are - ** no aux group IDs for the user, any AUX ids are cleared. - */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/contrib/notmuch-deliver/numlib/strdevt.c b/contrib/notmuch-deliver/numlib/strdevt.c deleted file mode 100644 index 2e542d54..00000000 --- a/contrib/notmuch-deliver/numlib/strdevt.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 2003 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strdevt.c,v 1.1 2003/01/26 03:22:40 mrsam Exp $"; - -char *libmail_str_dev_t(dev_t t, char *arg) -{ - char buf[NUMBUFSIZE]; - char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strgidt.c b/contrib/notmuch-deliver/numlib/strgidt.c deleted file mode 100644 index 89472e3b..00000000 --- a/contrib/notmuch-deliver/numlib/strgidt.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strgidt.c,v 1.4 2003/01/05 04:01:17 mrsam Exp $"; - -char *libmail_str_gid_t(gid_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strhdevt.c b/contrib/notmuch-deliver/numlib/strhdevt.c deleted file mode 100644 index 98e25e53..00000000 --- a/contrib/notmuch-deliver/numlib/strhdevt.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright 1998 - 2003 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strhdevt.c,v 1.2 2003/03/12 02:45:56 mrsam Exp $"; - -static const char xdigit[]="0123456789ABCDEF"; - -char *libmail_strh_dev_t(dev_t t, char *arg) -{ -char buf[sizeof(t)*2+1]; -char *p=buf+sizeof(buf)-1; -unsigned i; - - *p=0; - for (i=0; i<sizeof(t)*2; i++) - { - *--p= xdigit[t & 15]; - t=t / 16; - } - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strhinot.c b/contrib/notmuch-deliver/numlib/strhinot.c deleted file mode 100644 index fa640915..00000000 --- a/contrib/notmuch-deliver/numlib/strhinot.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strhinot.c,v 1.5 2003/03/12 02:45:56 mrsam Exp $"; - -static const char xdigit[]="0123456789ABCDEF"; - -char *libmail_strh_ino_t(ino_t t, char *arg) -{ -char buf[sizeof(t)*2+1]; -char *p=buf+sizeof(buf)-1; -unsigned i; - - *p=0; - for (i=0; i<sizeof(t)*2; i++) - { - *--p= xdigit[t & 15]; - t=t / 16; - } - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strhpidt.c b/contrib/notmuch-deliver/numlib/strhpidt.c deleted file mode 100644 index 2723af0b..00000000 --- a/contrib/notmuch-deliver/numlib/strhpidt.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strhpidt.c,v 1.5 2003/03/12 02:45:56 mrsam Exp $"; - -static const char xdigit[]="0123456789ABCDEF"; - -char *libmail_strh_pid_t(pid_t t, char *arg) -{ -char buf[sizeof(t)*2+1]; -char *p=buf+sizeof(buf)-1; -unsigned i; - - *p=0; - for (i=0; i<sizeof(t)*2; i++) - { - *--p= xdigit[t & 15]; - t=t / 16; - } - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strhtimet.c b/contrib/notmuch-deliver/numlib/strhtimet.c deleted file mode 100644 index b86b05a2..00000000 --- a/contrib/notmuch-deliver/numlib/strhtimet.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strhtimet.c,v 1.5 2003/03/12 02:45:56 mrsam Exp $"; - -static const char xdigit[]="0123456789ABCDEF"; - -char *libmail_strh_time_t(time_t t, char *arg) -{ -char buf[sizeof(t)*2+1]; -char *p=buf+sizeof(buf)-1; -unsigned i; - - *p=0; - for (i=0; i<sizeof(t)*2; i++) - { - *--p= xdigit[t & 15]; - t=t / 16; - } - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strinot.c b/contrib/notmuch-deliver/numlib/strinot.c deleted file mode 100644 index eb544c3c..00000000 --- a/contrib/notmuch-deliver/numlib/strinot.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strinot.c,v 1.4 2003/01/05 04:01:17 mrsam Exp $"; - -char *libmail_str_ino_t(ino_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strofft.c b/contrib/notmuch-deliver/numlib/strofft.c deleted file mode 100644 index d93edcbe..00000000 --- a/contrib/notmuch-deliver/numlib/strofft.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -** Copyright 1998 - 2002 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strofft.c,v 1.5 2003/01/05 04:01:17 mrsam Exp $"; - -char *libmail_str_off_t(off_t t, char *arg) -{ - char buf[NUMBUFSIZE]; - char *p=buf+sizeof(buf)-1; - int isneg=0; - - if (t < 0) - { - t= -t; - isneg=1; - } - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - - if (isneg) - *--p='-'; - - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strpidt.c b/contrib/notmuch-deliver/numlib/strpidt.c deleted file mode 100644 index 12ee9ce1..00000000 --- a/contrib/notmuch-deliver/numlib/strpidt.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strpidt.c,v 1.4 2003/01/05 04:01:17 mrsam Exp $"; - -char *libmail_str_pid_t(pid_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strsize.c b/contrib/notmuch-deliver/numlib/strsize.c deleted file mode 100644 index 0a7dcaa8..00000000 --- a/contrib/notmuch-deliver/numlib/strsize.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Copyright 2001 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strsize.c,v 1.2 2003/01/05 04:01:17 mrsam Exp $"; - -static void cat_n(char *buf, unsigned long n) -{ -char bb[NUMBUFSIZE+1]; -char *p=bb+sizeof(bb)-1; - - *p=0; - do - { - *--p = "0123456789"[n % 10]; - n=n/10; - } while (n); - strcat(buf, p); -} - -char *libmail_str_sizekb(unsigned long n, char *sizebuf) -{ - /* If size is less than 1K bytes, display it as 0.xK */ - - if (n < 1024) - { - strcpy(sizebuf, "0."); - cat_n(sizebuf, (int)(10 * n / 1024 )); - strcat(sizebuf, "K"); - } - /* If size is less than 1 meg, display is as xK */ - - else if (n < 1024 * 1024) - { - *sizebuf=0; - cat_n(sizebuf, (unsigned long)(n+512)/1024); - strcat(sizebuf, "K"); - } - - /* Otherwise, display in megabytes */ - - else - { - unsigned long nm=(double)n / (1024.0 * 1024.0) * 10; - - *sizebuf=0; - cat_n( sizebuf, nm / 10); - strcat(sizebuf, "."); - cat_n( sizebuf, nm % 10); - strcat(sizebuf, "M"); - } - - return (sizebuf); -} - diff --git a/contrib/notmuch-deliver/numlib/strsizet.c b/contrib/notmuch-deliver/numlib/strsizet.c deleted file mode 100644 index d4ec92d3..00000000 --- a/contrib/notmuch-deliver/numlib/strsizet.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strsizet.c,v 1.4 2003/01/05 04:01:18 mrsam Exp $"; - -char *libmail_str_size_t(size_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/strtimet.c b/contrib/notmuch-deliver/numlib/strtimet.c deleted file mode 100644 index be7e051b..00000000 --- a/contrib/notmuch-deliver/numlib/strtimet.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: strtimet.c,v 1.4 2003/01/05 04:01:18 mrsam Exp $"; - -char *libmail_str_time_t(time_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} diff --git a/contrib/notmuch-deliver/numlib/struidt.c b/contrib/notmuch-deliver/numlib/struidt.c deleted file mode 100644 index 50f3f742..00000000 --- a/contrib/notmuch-deliver/numlib/struidt.c +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Copyright 1998 - 2000 Double Precision, Inc. -** See COPYING for distribution information. -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include "numlib.h" -#include <string.h> - -static const char rcsid[]="$Id: struidt.c,v 1.4 2003/01/05 04:01:18 mrsam Exp $"; - -char *libmail_str_uid_t(uid_t t, char *arg) -{ -char buf[NUMBUFSIZE]; -char *p=buf+sizeof(buf)-1; - - *p=0; - do - { - *--p= '0' + (t % 10); - t=t / 10; - } while(t); - return (strcpy(arg, p)); -} |