From c7681947b501455947618f1694df12fbb3c1d367 Mon Sep 17 00:00:00 2001 From: Mystery Man Date: Mon, 10 Mar 2003 13:52:45 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'V9_1_19mdk'. --- mdk-stage1/dietlibc/libugly/asctime.c | 7 - mdk-stage1/dietlibc/libugly/asctime_r.c | 29 ---- mdk-stage1/dietlibc/libugly/asprintf.c | 22 --- mdk-stage1/dietlibc/libugly/ctime.c | 5 - mdk-stage1/dietlibc/libugly/daemon.c | 35 ----- mdk-stage1/dietlibc/libugly/endmntent.c | 7 - mdk-stage1/dietlibc/libugly/facilitynames.c | 32 ---- mdk-stage1/dietlibc/libugly/getmntent.c | 30 ---- mdk-stage1/dietlibc/libugly/getprotoent.c | 130 ----------------- mdk-stage1/dietlibc/libugly/gmtime.c | 6 - mdk-stage1/dietlibc/libugly/gmtime_r.c | 35 ----- mdk-stage1/dietlibc/libugly/isleap.c | 6 - mdk-stage1/dietlibc/libugly/localtime.c | 6 - mdk-stage1/dietlibc/libugly/localtime_r.c | 21 --- mdk-stage1/dietlibc/libugly/logging.c | 211 --------------------------- mdk-stage1/dietlibc/libugly/mktime.c | 21 --- mdk-stage1/dietlibc/libugly/pclose.c | 11 -- mdk-stage1/dietlibc/libugly/popen.c | 32 ---- mdk-stage1/dietlibc/libugly/prioritynames.c | 22 --- mdk-stage1/dietlibc/libugly/setenv.c | 17 --- mdk-stage1/dietlibc/libugly/setmntent.c | 7 - mdk-stage1/dietlibc/libugly/strftime.c | 182 ----------------------- mdk-stage1/dietlibc/libugly/strsignal.c | 92 ------------ mdk-stage1/dietlibc/libugly/system.c | 69 --------- mdk-stage1/dietlibc/libugly/time_table_spd.c | 17 --- mdk-stage1/dietlibc/libugly/tzfile.c | 86 ----------- mdk-stage1/dietlibc/libugly/unsetenv.c | 6 - 27 files changed, 1144 deletions(-) delete mode 100644 mdk-stage1/dietlibc/libugly/asctime.c delete mode 100644 mdk-stage1/dietlibc/libugly/asctime_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/asprintf.c delete mode 100644 mdk-stage1/dietlibc/libugly/ctime.c delete mode 100644 mdk-stage1/dietlibc/libugly/daemon.c delete mode 100644 mdk-stage1/dietlibc/libugly/endmntent.c delete mode 100644 mdk-stage1/dietlibc/libugly/facilitynames.c delete mode 100644 mdk-stage1/dietlibc/libugly/getmntent.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotoent.c delete mode 100644 mdk-stage1/dietlibc/libugly/gmtime.c delete mode 100644 mdk-stage1/dietlibc/libugly/gmtime_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/isleap.c delete mode 100644 mdk-stage1/dietlibc/libugly/localtime.c delete mode 100644 mdk-stage1/dietlibc/libugly/localtime_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/logging.c delete mode 100644 mdk-stage1/dietlibc/libugly/mktime.c delete mode 100644 mdk-stage1/dietlibc/libugly/pclose.c delete mode 100644 mdk-stage1/dietlibc/libugly/popen.c delete mode 100644 mdk-stage1/dietlibc/libugly/prioritynames.c delete mode 100644 mdk-stage1/dietlibc/libugly/setenv.c delete mode 100644 mdk-stage1/dietlibc/libugly/setmntent.c delete mode 100644 mdk-stage1/dietlibc/libugly/strftime.c delete mode 100644 mdk-stage1/dietlibc/libugly/strsignal.c delete mode 100644 mdk-stage1/dietlibc/libugly/system.c delete mode 100644 mdk-stage1/dietlibc/libugly/time_table_spd.c delete mode 100644 mdk-stage1/dietlibc/libugly/tzfile.c delete mode 100644 mdk-stage1/dietlibc/libugly/unsetenv.c (limited to 'mdk-stage1/dietlibc/libugly') diff --git a/mdk-stage1/dietlibc/libugly/asctime.c b/mdk-stage1/dietlibc/libugly/asctime.c deleted file mode 100644 index e1fcc8706..000000000 --- a/mdk-stage1/dietlibc/libugly/asctime.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -static char buf[25]; - -char *asctime(const struct tm *timeptr) { - return asctime_r(timeptr,buf); -} diff --git a/mdk-stage1/dietlibc/libugly/asctime_r.c b/mdk-stage1/dietlibc/libugly/asctime_r.c deleted file mode 100644 index 46325927c..000000000 --- a/mdk-stage1/dietlibc/libugly/asctime_r.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -static const char days[] = "Sun Mon Tue Wed Thu Fri Sat "; -static const char months[] = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "; - -static void num2str(char *c,int i) { - c[0]=i/10+'0'; - c[1]=i%10+'0'; -} - -char *asctime_r(const struct tm *t, char *buf) { - /* "Wed Jun 30 21:49:08 1993\n" */ - *(int*)buf=*(int*)(days+(t->tm_wday<<2)); - *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2)); - num2str(buf+8,t->tm_mday); - if (buf[8]=='0') buf[8]=' '; - buf[10]=' '; - num2str(buf+11,t->tm_hour); - if (buf[11]=='0') buf[11]=' '; - buf[13]=':'; - num2str(buf+14,t->tm_min); - buf[16]=':'; - num2str(buf+17,t->tm_sec); - buf[19]=' '; - num2str(buf+20,(t->tm_year+1900)/100); - num2str(buf+22,(t->tm_year+1900)%100); - buf[24]='\n'; - return buf; -} diff --git a/mdk-stage1/dietlibc/libugly/asprintf.c b/mdk-stage1/dietlibc/libugly/asprintf.c deleted file mode 100644 index d10c20b4a..000000000 --- a/mdk-stage1/dietlibc/libugly/asprintf.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -#include "dietwarning.h" - -extern int vsnprintf (char *str,size_t size,const char *format, va_list arg_ptr); - -int asprintf(char **s, const char *format,...) -{ - int n; - va_list arg_ptr; - va_start(arg_ptr, format); - n=vsnprintf(0,1000000,format,arg_ptr); - va_end (arg_ptr); - va_start (arg_ptr, format); - if ((*s=malloc(n+2))) { - n=vsnprintf(*s,n+1,format,arg_ptr); - va_end(arg_ptr); - return n; - } - return -1; -} diff --git a/mdk-stage1/dietlibc/libugly/ctime.c b/mdk-stage1/dietlibc/libugly/ctime.c deleted file mode 100644 index a0e12d673..000000000 --- a/mdk-stage1/dietlibc/libugly/ctime.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -char *ctime(const time_t *timep) { - return asctime(localtime(timep)); -} diff --git a/mdk-stage1/dietlibc/libugly/daemon.c b/mdk-stage1/dietlibc/libugly/daemon.c deleted file mode 100644 index 6748cc3c9..000000000 --- a/mdk-stage1/dietlibc/libugly/daemon.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include - -#include "daemon.h" - -int daemon (int nochdir,int noclose) -{ - int fd; - switch (fork ()) - { - case -1: - return (-1); - case 0: - break; - default: - _exit (0); - } - if (setsid () == -1) - return (-1); - if (!nochdir) chdir ("/"); - if (!noclose) - { - fd = open (_PATH_DEVNULL,O_RDWR,0); - if (fd == -1) return (-1); - dup2 (fd,STDIN_FILENO); - dup2 (fd,STDOUT_FILENO); - dup2 (fd,STDERR_FILENO); - close (fd); - } - return (0); -} - diff --git a/mdk-stage1/dietlibc/libugly/endmntent.c b/mdk-stage1/dietlibc/libugly/endmntent.c deleted file mode 100644 index 00ade38e5..000000000 --- a/mdk-stage1/dietlibc/libugly/endmntent.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int endmntent(FILE *filep) { - return fclose(filep); -} - diff --git a/mdk-stage1/dietlibc/libugly/facilitynames.c b/mdk-stage1/dietlibc/libugly/facilitynames.c deleted file mode 100644 index 8b0e1f21f..000000000 --- a/mdk-stage1/dietlibc/libugly/facilitynames.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#ifndef INTERNAL_MARK -#define INTERNAL_MARK 0x300 -#endif - -CODE facilitynames[] = - { - { "auth", LOG_AUTH }, - { "authpriv", LOG_AUTHPRIV }, - { "cron", LOG_CRON }, - { "daemon", LOG_DAEMON }, - { "ftp", LOG_FTP }, - { "kern", LOG_KERN }, - { "lpr", LOG_LPR }, - { "mail", LOG_MAIL }, - { "mark", INTERNAL_MARK }, /* INTERNAL */ - { "news", LOG_NEWS }, - { "security", LOG_AUTH }, /* DEPRECATED */ - { "syslog", LOG_SYSLOG }, - { "user", LOG_USER }, - { "uucp", LOG_UUCP }, - { "local0", LOG_LOCAL0 }, - { "local1", LOG_LOCAL1 }, - { "local2", LOG_LOCAL2 }, - { "local3", LOG_LOCAL3 }, - { "local4", LOG_LOCAL4 }, - { "local5", LOG_LOCAL5 }, - { "local6", LOG_LOCAL6 }, - { "local7", LOG_LOCAL7 }, - { 0, -1 } - }; diff --git a/mdk-stage1/dietlibc/libugly/getmntent.c b/mdk-stage1/dietlibc/libugly/getmntent.c deleted file mode 100644 index 250a77b7f..000000000 --- a/mdk-stage1/dietlibc/libugly/getmntent.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include - -struct mntent *getmntent(FILE *filep) { - static struct mntent m; - char buf[1024]; - do { - char *tmp=buf; - int num; - fgets(buf,1024,filep); -/* "/dev/ide/host0/bus0/target0/lun0/part2 / reiserfs defaults 1 1" */ - for (num=0; num<6; ++num) { - switch (num) { - case 0: m.mnt_fsname=tmp; break; - case 1: m.mnt_dir=tmp; break; - case 2: m.mnt_type=tmp; break; - case 3: m.mnt_opts=tmp; break; - case 4: m.mnt_freq=strtol(tmp,&tmp,0); if (*tmp!=' ') continue; break; - case 5: m.mnt_passno=strtol(tmp,&tmp,0); if (*tmp=='\n') return &m; break; - } - if ((tmp=strchr(tmp,' '))) { - if (num<4) *tmp++=0; - while (*tmp==' ') ++tmp; - } else - continue; - } - } while (1); -} diff --git a/mdk-stage1/dietlibc/libugly/getprotoent.c b/mdk-stage1/dietlibc/libugly/getprotoent.c deleted file mode 100644 index a648e2307..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotoent.c +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -static int protofd=-1; -static char* protomap; -static unsigned int protolen; - -static char* aliases[10]; - -static char *cur; - -/* ip 0 IP # internet protocol, pseudo protocol number */ -struct protoent *getprotoent(void) { - static struct protoent pe; - char *last; - int aliasidx; - if (protofd<0) { - protofd=open(_PATH_SERVICES,O_RDONLY); - if (protofd<0) return 0; - protolen=lseek(protofd,0,SEEK_END); - protomap=mmap(0,protolen,PROT_READ|PROT_WRITE,MAP_PRIVATE,protofd,0); - if ((long)protomap==(-1)) goto error; - cur=protomap; - } - last=protomap+protolen; -again: - pe.p_name=0; - pe.p_aliases=aliases; aliases[0]=0; - pe.p_proto=0; - if (cur>=last) return 0; - if (*cur=='#' || *cur=='\n') goto parseerror; - /* first, the primary name */ - if (!isalpha(*cur)) goto parseerror; - pe.p_name=cur; - pe.p_aliases=aliases; - while (cur=last) return 0; - if (*cur=='\n') goto parseerror; - *cur=0; cur++; - /* second, the protocol number */ - while (cur=last) return 0; - if (*cur=='\n') { *cur++=0; return &pe; } - *cur=0; cur++; - /* now the aliases */ - for (aliasidx=0;aliasidx<10;++aliasidx) { - while (cur=last || !isblank(*cur)) break; - *cur++=0; - } - aliases[aliasidx]=0; - return &pe; -parseerror: - while (curp_name,strlen(s->p_name)); - write(1,"/",1); - write(1,s->p_proto,strlen(s->p_proto)); - write(1,"\n",1); - if (!strcmp(name,"auth")) { - tmp=s->p_aliases; - write(1," aka ",5); - while (*tmp) { - write(1,*tmp,strlen(*tmp)); - write(1,", ",2); - ++tmp; - } - write(1,"\n",1); - } -#endif - if (!strcmp(name,s->p_name)) - return s; - tmp=s->p_aliases; - while (*tmp) - if (!strcmp(name,*tmp++)) return s; - } - return 0; -} - -struct protoent *getprotobynumber(int proto) { - struct protoent *s; - for (s=getprotoent(); s; s=getprotoent()) { - if (proto==s->p_proto) - return s; - } - return 0; -} - -void endprotoent(void) { - if (protomap!=(char*)-1) munmap(protomap,protolen); - if (protofd!=-1) close(protofd); - protomap=(char*)-1; - protofd=-1; -} - diff --git a/mdk-stage1/dietlibc/libugly/gmtime.c b/mdk-stage1/dietlibc/libugly/gmtime.c deleted file mode 100644 index d33af7972..000000000 --- a/mdk-stage1/dietlibc/libugly/gmtime.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -struct tm* gmtime(const time_t *t) { - static struct tm tmp; - return gmtime_r(t,&tmp); -} diff --git a/mdk-stage1/dietlibc/libugly/gmtime_r.c b/mdk-stage1/dietlibc/libugly/gmtime_r.c deleted file mode 100644 index c102d10fa..000000000 --- a/mdk-stage1/dietlibc/libugly/gmtime_r.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -/* seconds per day */ -#define SPD 24*60*60 - -extern unsigned int __spm[]; - -struct tm *gmtime_r(const time_t *timep, struct tm *r) { - time_t i; - register time_t work=*timep%(SPD); - r->tm_sec=work%60; work/=60; - r->tm_min=work%60; r->tm_hour=work/60; - work=*timep/(SPD); - r->tm_wday=(4+work)%7; - for (i=1970; ; ++i) { - register time_t k=__isleap(i)?366:365; - if (work>k) - work-=k; - else - break; - } - r->tm_year=i-1900; - r->tm_yday=work; - - r->tm_mday=1; - if (__isleap(i) && (work>58)) { - if (work==59) r->tm_mday=2; /* 29.2. */ - work-=1; - } - - for (i=11; i && __spm[i]>work; --i) ; - r->tm_mon=i; - r->tm_mday+=work-__spm[i]; - return r; -} diff --git a/mdk-stage1/dietlibc/libugly/isleap.c b/mdk-stage1/dietlibc/libugly/isleap.c deleted file mode 100644 index dcfa1ced6..000000000 --- a/mdk-stage1/dietlibc/libugly/isleap.c +++ /dev/null @@ -1,6 +0,0 @@ -int __isleap(int year) { - /* every fourth year is a leap year except for century years that are - * not divisible by 400. */ -/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */ - return (!(year%4) && ((year%100) || !(year%400))); -} diff --git a/mdk-stage1/dietlibc/libugly/localtime.c b/mdk-stage1/dietlibc/libugly/localtime.c deleted file mode 100644 index 6fa6acf8a..000000000 --- a/mdk-stage1/dietlibc/libugly/localtime.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -struct tm* localtime(const time_t* t) { - static struct tm tmp; - return localtime_r(t,&tmp); -} diff --git a/mdk-stage1/dietlibc/libugly/localtime_r.c b/mdk-stage1/dietlibc/libugly/localtime_r.c deleted file mode 100644 index d4bc073ce..000000000 --- a/mdk-stage1/dietlibc/libugly/localtime_r.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "dietfeatures.h" -#include -#include - -#ifdef WANT_TZFILE_PARSER -extern void __maplocaltime(); -extern time_t __tzfile_map(time_t t, int *isdst); -#endif - -struct tm* localtime_r(const time_t* t, struct tm* r) { - time_t tmp; -#ifdef WANT_TZFILE_PARSER - __maplocaltime(); - tmp=__tzfile_map(*t,&r->tm_isdst); -#else - struct timezone tz; - gettimeofday(0, &tz); - tmp=*t-tz.tz_minuteswest*60L; -#endif - return gmtime_r(&tmp,r); -} diff --git a/mdk-stage1/dietlibc/libugly/logging.c b/mdk-stage1/dietlibc/libugly/logging.c deleted file mode 100644 index 69c2c2337..000000000 --- a/mdk-stage1/dietlibc/libugly/logging.c +++ /dev/null @@ -1,211 +0,0 @@ -#include "dietfeatures.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define _PATH_CONSOLE "/dev/console" -#define BUF_SIZE 512 /* messagebuffer size (>= 200) */ - -#define MAX_LOGTAG 80 - -/* those have to be global *sigh* */ -static volatile int connected = 0; /* have done connect */ -static volatile int LogMask = 0xff; /* mask of priorities to be logged */ -static char LogTag[MAX_LOGTAG]; /* string to tag the entry with */ -static int LogFile = -1; /* fd for log */ -static int LogType = SOCK_DGRAM; /* type of socket connection */ -static int LogFacility = LOG_USER; /* default facility code */ -static int LogStat; /* status bits, set by openlog() */ -extern char *__progname; /* Program name, from crt0. */ -static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */ - -static void closelog_intern(void) -{ - if (!connected) return; - close(LogFile); - LogFile = -1; - connected = 0; -} - -void closelog(void) -{ - closelog_intern(); - - LogTag[0]=0; - LogType = SOCK_DGRAM; -} - -static void openlog_intern(int option, int facility) -{ - LogStat = option; - if (facility && ((facility & ~LOG_FACMASK) == 0)) - LogFacility = facility; - - /* yep, there is a continue inside ;) */ - while(1) { - if (LogFile == -1) { - SyslogAddr.sa_family = AF_UNIX; - strncpy(SyslogAddr.sa_data, _PATH_LOG, sizeof(SyslogAddr.sa_data)); - if (LogStat & LOG_NDELAY) - { - if ((LogFile = socket(AF_UNIX, LogType, 0)) == -1) return; - fcntl(LogFile, F_SETFD, 1); - } - } - if ((LogFile != -1) && !connected) { -#ifdef WANT_THREAD_SAFE - int old_errno = (*(__errno_location())); -#else - int old_errno=errno; -#endif - if(connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) { -#ifdef WANT_THREAD_SAFE - int saved_errno = (*(__errno_location())); -#else - int saved_errno=errno; -#endif - close(LogFile); - LogFile = -1; - if((LogType == SOCK_DGRAM) && (saved_errno == EPROTOTYPE)) { - /* retry with SOCK_STREAM instead of SOCK_DGRAM */ - LogType = SOCK_STREAM; -#ifdef WANT_THREAD_SAFE - (*(__errno_location()))=old_errno; -#else - errno=old_errno; -#endif - continue; - } - } - else connected = 1; - } - break; - } -} - -/* has to be secured against multiple, simultanious call's in threaded environment */ -void openlog(const char *ident, int option, int facility) -{ - if (ident) { - strncpy(LogTag,ident,MAX_LOGTAG); - LogTag[MAX_LOGTAG-1]=0; - } - openlog_intern(option, facility); -} - -int setlogmask(int mask) -{ - int old = LogMask; - if (mask) LogMask = mask; - return old; -} - -void vsyslog(int priority, const char *format, va_list arg_ptr) -{ - char buffer[BUF_SIZE]; - char time_buf[20]; - int buflen, headerlen; - time_t now; - struct tm now_tm; - pid_t pid; - int fd; - int sigpipe; - struct sigaction action, oldaction; - struct sigaction *oldaction_ptr = NULL; -#ifdef WANT_THREAD_SAFE - int saved_errno = (*(__errno_location())); -#else - int saved_errno = errno; -#endif - - /* check for invalid priority/facility bits */ - if (priority & ~(LOG_PRIMASK|LOG_FACMASK)) { - syslog(LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID, "syslog: unknown facility/priorityority: %x", priority); - priority &= LOG_PRIMASK|LOG_FACMASK; - } - - /* check priority against setlogmask */ - if ((LOG_MASK(LOG_PRI(priority)) && LogMask) == 0) return; - - /* Set default facility if none specified. */ - if ((priority & LOG_FACMASK) == 0) priority |= LogFacility; - - pid = getpid(); - time(&now); - strftime(time_buf, 20, "%h %e %T", localtime_r (&now, &now_tm)); - - if (LogStat & LOG_PID) - headerlen = snprintf(buffer, 130, "<%d>%s %s[%d]: ", priority, time_buf, LogTag, pid); - else - headerlen = snprintf(buffer, 130, "<%d>%s %s: ", priority, time_buf, LogTag); - - if (!LogTag[0]) { - if ((LogStat & LOG_PID) != LOG_PID) - headerlen = snprintf(buffer, 130, "<%d>%s (unknown)[%d]: ", priority, time_buf, pid); - strcat(buffer+headerlen, "syslog without openlog w/ ident, please check code!"); - buflen = 41; - } - else { -#ifdef WANT_THREAD_SAFE - (*(__errno_location()))=saved_errno; -#else - errno=saved_errno; -#endif - buflen = vsnprintf(buffer+headerlen, BUF_SIZE - headerlen, format, arg_ptr); - } - if (LogStat & LOG_PERROR) { - write(1, buffer+headerlen, buflen); - if (buffer[headerlen+buflen] != '\n') write(1,"\n", 1); - } - - /* prepare for broken connection */ - memset(&action, 0, sizeof(action)); - action.sa_handler = SIG_IGN; - sigemptyset(&action.sa_mask); - - if ((sigpipe = sigaction (SIGPIPE, &action, &oldaction))==0) - oldaction_ptr = &oldaction; - - if (!connected) openlog_intern(LogStat | LOG_NDELAY, 0); - - /* If we have a SOCK_STREAM connection, also send ASCII NUL as a - * record terminator. */ - if (LogType == SOCK_STREAM) buflen++; - - if (!connected || (send(LogFile, buffer, buflen+headerlen, 0) != buflen+headerlen)) { - if (LogType == SOCK_STREAM) buflen--; - closelog_intern(); - /* - * Output the message to the console; don't worry about blocking, - * if console blocks everything will. Make sure the error reported - * is the one from the syslogd failure. - */ - if ((LogStat & LOG_CONS) && - ((fd = open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)) - { - write(fd, buffer, buflen+headerlen); - write(fd, "\r\n", 2); - } - } - - if (sigpipe == 0) - sigaction(SIGPIPE, &oldaction, (struct sigaction *) NULL); -} - -void syslog(int priority, const char *format, ...) -{ - va_list arg_ptr; - va_start(arg_ptr, format); - vsyslog(priority, format, arg_ptr); - va_end(arg_ptr); -} diff --git a/mdk-stage1/dietlibc/libugly/mktime.c b/mdk-stage1/dietlibc/libugly/mktime.c deleted file mode 100644 index ee4dab6c1..000000000 --- a/mdk-stage1/dietlibc/libugly/mktime.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -/* seconds per day */ -#define SPD 24*60*60 - -extern unsigned int __spm[]; - -time_t mktime(struct tm *t) { - time_t x=0; - unsigned int i; - if (t->tm_year<70) return (time_t)(-1); - for (i=70; itm_year; ++i) { - x+=__isleap(i+1900)?366:365; - } - t->tm_yday=__spm[t->tm_mon] + t->tm_mday-1 + ((t->tm_mon>2) && __isleap(t->tm_year)?1:0); - x+=t->tm_yday; - /* x is now the number of days since Jan 1 1970 */ - t->tm_wday=(4+x)%7; - x = x*SPD + t->tm_hour*60*60 + t->tm_min*60 + t->tm_sec; - return x; -} diff --git a/mdk-stage1/dietlibc/libugly/pclose.c b/mdk-stage1/dietlibc/libugly/pclose.c deleted file mode 100644 index e33076c19..000000000 --- a/mdk-stage1/dietlibc/libugly/pclose.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "dietstdio.h" - -int pclose(FILE *f) { - int status; - fclose(f); - if (waitpid(f->popen_kludge,&status,0)>=0) - return status; - return -1; -} diff --git a/mdk-stage1/dietlibc/libugly/popen.c b/mdk-stage1/dietlibc/libugly/popen.c deleted file mode 100644 index e0e441495..000000000 --- a/mdk-stage1/dietlibc/libugly/popen.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "dietstdio.h" -#include - -extern char **environ; - -FILE *popen(const char *command, const char *type) { - int pfd[2]; - int fd0; - pid_t pid; - if (pipe(pfd)<0) return 0; - fd0=(*type=='r'); - if ((pid=vfork())<0) { - close(pfd[0]); - close(pfd[1]); - return 0; - } - if (!pid) { /* child */ - char *argv[]={"sh","-c",0,0}; - close(pfd[!fd0]); close(fd0); - dup2(pfd[fd0],fd0); close(pfd[fd0]); - argv[2]=(char*)command; - execve("/bin/sh",argv,environ); - _exit(255); - } - close(pfd[fd0]); - { - register FILE* f; - if ((f=fdopen(pfd[!fd0],type))) - f->popen_kludge=pid; - return f; - } -} diff --git a/mdk-stage1/dietlibc/libugly/prioritynames.c b/mdk-stage1/dietlibc/libugly/prioritynames.c deleted file mode 100644 index 87a99b76d..000000000 --- a/mdk-stage1/dietlibc/libugly/prioritynames.c +++ /dev/null @@ -1,22 +0,0 @@ -#include - -#ifndef INTERNAL_NOPRI -#define INTERNAL_NOPRI 0x10 -#endif - -CODE prioritynames[] = - { - { "alert", LOG_ALERT }, - { "crit", LOG_CRIT }, - { "debug", LOG_DEBUG }, - { "emerg", LOG_EMERG }, - { "err", LOG_ERR }, - { "error", LOG_ERR }, /* DEPRECATED */ - { "info", LOG_INFO }, - { "none", INTERNAL_NOPRI }, /* INTERNAL */ - { "notice", LOG_NOTICE }, - { "panic", LOG_EMERG }, /* DEPRECATED */ - { "warn", LOG_WARNING }, /* DEPRECATED */ - { "warning", LOG_WARNING }, - { 0, -1 } - }; diff --git a/mdk-stage1/dietlibc/libugly/setenv.c b/mdk-stage1/dietlibc/libugly/setenv.c deleted file mode 100644 index bf47cdb79..000000000 --- a/mdk-stage1/dietlibc/libugly/setenv.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -#include -link_warning("setenv","setenv calls malloc. Avoid it in small programs."); - -int setenv(const char *name, const char *value, int overwrite) { - char *c=malloc(strlen(name)+strlen(value)+3); - if (getenv(name)) { - if (!overwrite) return 0; - unsetenv(name); - } - strcpy(c,name); - strcat(c,"="); - strcat(c,value); - return putenv(c); -} diff --git a/mdk-stage1/dietlibc/libugly/setmntent.c b/mdk-stage1/dietlibc/libugly/setmntent.c deleted file mode 100644 index a91d3902b..000000000 --- a/mdk-stage1/dietlibc/libugly/setmntent.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -FILE *setmntent(const char *filename, const char *type) { - return fopen(filename,type); -} - diff --git a/mdk-stage1/dietlibc/libugly/strftime.c b/mdk-stage1/dietlibc/libugly/strftime.c deleted file mode 100644 index b7e750ab1..000000000 --- a/mdk-stage1/dietlibc/libugly/strftime.c +++ /dev/null @@ -1,182 +0,0 @@ -#include -#include - -static char *sweekdays[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; -static char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; -static char *smonths[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; -static char *months[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; -static char *ampm[]={"am","pm","AM","PM"}; - -static int i2a(char* dest,unsigned int x) { - register unsigned int tmp=x; - register int len=0; - *dest++=tmp/10+'0'; tmp=tmp%10; ++len; - *dest++=tmp+'0'; - return 2; -} - -static int i2as(char* dest,unsigned int x) { - int len=i2a(dest,x); - if (*dest=='0') *dest=' '; - return len; -} - -size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) { - char *t=s; - const char *src; - char buf[5]; - while (*format) { - switch (*format) { - case 0: break; - case '%': - switch (*++format) { - case '%': *t='%'; ++t; break; - case 'a': src=sweekdays[tm->tm_wday]; goto append; - case 'A': src=weekdays[tm->tm_wday]; goto append; - case 'h': - case 'b': src=smonths[tm->tm_mon]; goto append; - case 'B': src=months[tm->tm_mon]; goto append; - case 'c': t+=strftime(t,max-(t-s),"%b %a %d %k:%M:%S %Z %Y",tm); break; - case 'C': buf[i2a(buf,(tm->tm_year+1900)/100)]=0; src=buf; goto append; - case 'd': buf[i2a(buf,tm->tm_mday)]=0; src=buf; goto append; - case 'e': buf[i2as(buf,tm->tm_mday)]=0; src=buf; goto append; - case 'H': buf[i2a(buf,tm->tm_hour)]=0; src=buf; goto append; - case 'I': buf[i2a(buf,tm->tm_hour%12)]=0; src=buf; goto append; - case 'j': buf[i2a(buf,tm->tm_yday)]=0; src=buf; goto append; - case 'k': buf[i2as(buf,tm->tm_hour)]=0; src=buf; goto append; - case 'l': buf[i2as(buf,tm->tm_hour%12)]=0; src=buf; goto append; - case 'm': buf[i2a(buf,tm->tm_mon+1)]=0; src=buf; goto append; - case 'M': buf[i2a(buf,tm->tm_min)]=0; src=buf; goto append; - case 'n': *t='\n'; break; - case 'p': src=ampm[tm->tm_hour>11?3:2]; goto append; - case 'P': src=ampm[tm->tm_hour>11?1:0]; goto append; - case 'r': t+=strftime(t,max-(t-s),"%I:%M:%S %p",tm); break; - case 'R': t+=strftime(t,max-(t-s),"%H:%M",tm); break; - case 'S': buf[i2a(buf,tm->tm_sec)]=0; src=buf; goto append; - case 't': *t='\t'; break; - case 'T': t+=strftime(t,max-(t-s),"%H:%M:%S",tm); break; - case 'u': buf[i2a(buf,tm->tm_wday?tm->tm_wday:7)]=0; src=buf; goto append; - case 'w': buf[i2a(buf,tm->tm_wday)]=0; src=buf; goto append; - case 'x': t+=strftime(t,max-(t-s),"%b %a %d",tm); break; - case 'X': t+=strftime(t,max-(t-s),"%k:%M:%S",tm); break; - case 'y': buf[i2a(buf,tm->tm_year%100)]=0; src=buf; goto append; - case 'Y': i2a(buf,(tm->tm_year+1900)/100); buf[i2a(buf+2,(tm->tm_year%100))+2]=0; src=buf; goto append; - case 'Z': src="GMT"; goto append; /* hehe */ -append: - while (*src && t=s+max) break; - continue; - } - *t=0; return t-s; -} - - - -/* - %u The day of the week as a decimal, range 1 to 7, - Monday being 1. See also %w. (SU) - - %U The week number of the current year as a decimal - number, range 00 to 53, starting with the first - Sunday as the first day of week 01. See also %V and - %W. - - %V The ISO 8601:1988 week number of the current year - as a decimal number, range 01 to 53, where week 1 - is the first week that has at least 4 days in the - current year, and with Monday as the first day of - the week. See also %U and %W. (SU) - - %w The day of the week as a decimal, range 0 to 6, - Sunday being 0. See also %u. - - %W The week number of the current year as a decimal - number, range 00 to 53, starting with the first - Monday as the first day of week 01. - - %x The preferred date representation for the current - locale without the time. - - %X The preferred time representation for the current - locale without the date. - - %y The year as a decimal number without a century - (range 00 to 99). - - %Y The year as a decimal number including the century. - - %z The time-zone as hour offset from GMT. Required to - emit RFC822-conformant dates (using "%a, %d %b %Y - %H:%M:%S %z"). (GNU) - - %Z The time zone or name or abbreviation. - - %+ The date and time in date(1) format. (TZ) - - %% A literal `%' character. - - Some conversion specifiers can be modified by preceding - them by the E or O modifier to indicate that an alterna­ - tive format should be used. If the alternative format or - specification does not exist for the current locale, the - behaviour will be as if the unmodified conversion specifi­ - cation were used. (SU) The Single Unix Specification men­ - tions %Ec, %EC, %Ex, %EX, %Ry, %EY, %Od, %Oe, %OH, %OI, - %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the - effect of the O modifier is to use alternative numeric - symbols (say, roman numerals), and that of the E modifier - - - -GNU 29 March 1999 3 - - - - - -STRFTIME(3) Linux Programmer's Manual STRFTIME(3) - - - is to use a locale-dependent alternative representation. - - The broken-down time structure tm is defined in . - See also ctime(3). - - -RETURN VALUE - The strftime() function returns the number of characters - placed in the array s, not including the terminating NUL - character, provided the string, including the terminating - NUL, fits. Otherwise, it returns 0, and the contents of - the array is undefined. (Thus at least since libc 4.4.4; - very old versions of libc, such as libc 4.4.1, would - return max if the array was too small.) - - Note that the return value 0 does not necessarily indicate - an error; for example, in many locales %p yields an empty - string. - -ENVIRONMENT - The environment variables TZ and LC_TIME are used. - -CONFORMING TO - ANSI C, SVID 3, ISO 9899. There are strict inclusions - between the set of conversions given in ANSI C (unmarked), - those given in the Single Unix Specification (marked SU), - those given in Olson's timezone package (marked TZ), and - those given in glibc (marked GNU), except that %+ is not - supported in glibc2. On the other hand glibc2 has several - more extensions. POSIX.1 only refers to ANSI C; POSIX.2 - describes under date(1) several extensions that could - apply to strftime as well. - -SEE ALSO - date(1), time(2), ctime(3), setlocale(3), sprintf(3) - -*/ diff --git a/mdk-stage1/dietlibc/libugly/strsignal.c b/mdk-stage1/dietlibc/libugly/strsignal.c deleted file mode 100644 index 54314d2c7..000000000 --- a/mdk-stage1/dietlibc/libugly/strsignal.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -/* F....ng Kernel haeder is damn broken... */ -#ifndef _NSIG -#define _NSIG 64 -#endif -#include - -char * strsignal(int sig) { - if (sig==SIGHUP) - return "Hangup"; - else if (sig==SIGINT) - return "Interrupt"; - else if (sig==SIGQUIT) - return "Quit"; - else if (sig==SIGILL) - return "Illegal instruction"; - else if (sig==SIGTRAP) - return "Trace/breakpoint trap"; - else if (sig==SIGABRT) - return "Aborted"; - else if (sig==SIGFPE) - return "Floating point exception"; - else if (sig==SIGKILL) - return "Killed"; - else if (sig==SIGBUS) - return "Bus error"; - else if (sig==SIGSEGV) - return "Segmentation fault"; - else if (sig==SIGPIPE) - return "Broken pipe"; - else if (sig==SIGALRM) - return "Alarm clock"; - else if (sig==SIGTERM) - return "Terminated"; - else if (sig==SIGURG) - return "Urgent I/O condition"; - else if (sig==SIGSTOP) - return "Stopped (signal)"; - else if (sig==SIGTSTP) - return "Stopped"; - else if (sig==SIGCONT) - return "Continue"; - else if (sig==SIGCHLD) - return "Child exited"; - else if (sig==SIGTTIN) - return "Stopped (tty input)"; - else if (sig==SIGTTOU) - return "Stopped (tty output)"; - else if (sig==SIGIO) - return "I/O possible"; - else if (sig==SIGXCPU) - return "CPU time limit exceeded"; - else if (sig==SIGXFSZ) - return "File size limit exceeded"; - else if (sig==SIGVTALRM) - return "Virtual timer expired"; - else if (sig==SIGPROF) - return "Profiling timer expired"; - else if (sig==SIGWINCH) - return "Window changed"; - else if (sig==SIGUSR1) - return "User defined signal 1"; - else if (sig==SIGUSR2) - return "User defined signal 1"; -#ifdef SIGEMT - else if (sig==SIGEMT) - return "EMT trap"; -#endif -#ifdef SIGSYS - else if (sig==SIGSYS) - return "Bad system call"; -#endif -#ifdef SIGSTKFLT - else if (sig==SIGSTKFLT) - return "Stack fault"; -#endif -#ifdef SIGINFO - else if (sig==SIGINFO) - return "Information request"; -#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR!=SIGLOST)) - else if (sig==SIGPWR) - return "Power falure"; -#endif -#ifdef SIGLOST - else if (sig==SIGLOST) - return "Resource lost"; -#endif - else if ((sig>=SIGRTMIN)&&(sig<=SIGRTMAX)) - return "Real time signal"; - else - return "(unknown signal)"; -} diff --git a/mdk-stage1/dietlibc/libugly/system.c b/mdk-stage1/dietlibc/libugly/system.c deleted file mode 100644 index b9eea20eb..000000000 --- a/mdk-stage1/dietlibc/libugly/system.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -#include -#include "dietwarning.h" - -#define SHELL_PATH "/bin/sh" /* Path of the shell. */ -#define SHELL_NAME "sh" /* Name to give it. */ - -extern char **environ; - -int __libc_fork(); -int __libc_waitpid(int pid, int *status, int options); -int execve(const char*filename, char *const argv[], char *const envp[]); -void __set_errno(int errno); -int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); - -int __libc_system (const char *line) -{ - struct sigaction sa, intr, quit; - int save,pid,ret=-1; - - if (line == 0) return __libc_system("exit 0") == 0; - - sa.sa_handler = SIG_IGN; - sa.sa_flags = 0; - sigemptyset (&sa.sa_mask); - - if (sigaction(SIGINT, &sa, &intr)<0) return -1; - if (sigaction(SIGQUIT, &sa, &quit)<0) { - save = errno; - sigaction (SIGINT, &intr, (struct sigaction*)0); - __set_errno (save); - return -1; - } - - pid=__libc_fork(); - if (pid>0) - { /* parent */ - int n; - do - n=__libc_waitpid(pid, &ret, 0); - while ((n==-1) && (errno==EINTR)); - if (n!=pid) ret=-1; - } - else if (!pid) - { /* child */ - const char *nargs[4]; - nargs[0] = SHELL_NAME; - nargs[1] = "-c"; - nargs[2] = line; - nargs[3] = 0; - - sigaction(SIGINT, &intr, (struct sigaction*)0); - sigaction(SIGQUIT, &quit, (struct sigaction*)0); - - execve(SHELL_PATH,(char *const *)nargs, environ); - _exit(127); - } - save = errno; - sigaction (SIGINT, &intr, (struct sigaction *)0); - sigaction (SIGQUIT, &quit, (struct sigaction *)0); - __set_errno(save); - return ret; -} - -int system (const char *line) __attribute__((weak,alias("__libc_system"))); - -link_warning("system","warning: system() is a security risk. Use fork and execvp instead!") diff --git a/mdk-stage1/dietlibc/libugly/time_table_spd.c b/mdk-stage1/dietlibc/libugly/time_table_spd.c deleted file mode 100644 index bfe1cf86d..000000000 --- a/mdk-stage1/dietlibc/libugly/time_table_spd.c +++ /dev/null @@ -1,17 +0,0 @@ - -/* seconds per month -- nonleap! */ -const unsigned int __spm[12] = - { 0, - (31), - (31+28), - (31+28+31), - (31+28+31+30), - (31+28+31+30+31), - (31+28+31+30+31+30), - (31+28+31+30+31+30+31), - (31+28+31+30+31+30+31+31), - (31+28+31+30+31+30+31+31+30), - (31+28+31+30+31+30+31+31+30+31), - (31+28+31+30+31+30+31+31+30+31+30), - }; - diff --git a/mdk-stage1/dietlibc/libugly/tzfile.c b/mdk-stage1/dietlibc/libugly/tzfile.c deleted file mode 100644 index 5702d4bea..000000000 --- a/mdk-stage1/dietlibc/libugly/tzfile.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "dietfeatures.h" -#include -#include -#include -#include - -#include - -#ifdef WANT_TZFILE_PARSER -static char *tzfile=0; -static int tzlen=-1; - -void __maplocaltime() { - int fd; - unsigned int len; - if (tzlen>=0) return; - tzlen=0; - if ((fd=open("/etc/localtime",O_RDONLY))<0) return; - len=lseek(fd,0,SEEK_END); - if ((tzfile=mmap(0,len,PROT_READ,MAP_SHARED,fd,0))==MAP_FAILED) return; - close(fd); - if (ntohl(*(int*)tzfile) != 0x545a6966) return; - tzlen=len; -} - -char *tzset(void) __attribute__((weak,alias("__maplocaltime"))); - -static unsigned long __myntohl(const unsigned char* c) { - return (((unsigned long)c[0])<<24) + - (((unsigned long)c[1])<<16) + - (((unsigned long)c[2])<<8) + - ((unsigned long)c[3]); -} - -time_t __tzfile_map(time_t t, int *isdst) { - /* "TZif" plus 16 reserved bytes. */ - char *tmp; - int i; - int tzh_ttisgmtcnt, tzh_ttisstdcnt, tzh_leapcnt, tzh_timecnt, tzh_typecnt, tzh_charcnt; - *isdst=0; - if (!tzfile) return t; - tzh_ttisgmtcnt=ntohl(*(int*)(tzfile+20)); - tzh_ttisstdcnt=ntohl(*(int*)(tzfile+24)); - tzh_leapcnt=ntohl(*(int*)(tzfile+28)); - tzh_timecnt=ntohl(*(int*)(tzfile+32)); - tzh_typecnt=ntohl(*(int*)(tzfile+36)); - tzh_charcnt=ntohl(*(int*)(tzfile+40)); - -#if 0 - tmp=tzfile+20+6*4; - printf("ttisgmtcnt %d ttisstdcnt %d leapcnt %d timecnt %d typecnt %d charcnt %d\n",tzh_ttisgmtcnt,tzh_ttisstdcnt, tzh_leapcnt, tzh_timecnt, tzh_typecnt, tzh_charcnt); - printf("transition times: "); - for (i=0; i= t) { -/* printf("match at %d\n",i); */ - tmp+=tzh_timecnt*4; - i=tmp[i-1]; -/* printf("using index %d\n",i); */ - tmp+=tzh_timecnt; - tmp+=i*6; -/* printf("(%lu,%d,%d)\n",ntohl(*(int*)tmp),tmp[4],tmp[5]); */ - *isdst=tmp[4]; - return t+__myntohl(tmp); - } - return t; -} -#else -void tzset(void) __attribute__((weak,alias("return0"))); -#endif diff --git a/mdk-stage1/dietlibc/libugly/unsetenv.c b/mdk-stage1/dietlibc/libugly/unsetenv.c deleted file mode 100644 index 46e880271..000000000 --- a/mdk-stage1/dietlibc/libugly/unsetenv.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -void unsetenv(const char *name) { - putenv(name); -} - -- cgit v1.2.1