From 4e506c9aefe5b89970ae6894d05ad53c81af0d83 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 6 May 2005 02:43:04 +0000 Subject: use installed dietlibc, not our forked cvs version --- mdk-stage1/dietlibc/libugly/asctime.c | 7 - mdk-stage1/dietlibc/libugly/asctime_r.c | 29 ---- mdk-stage1/dietlibc/libugly/asprintf.c | 19 --- mdk-stage1/dietlibc/libugly/ctime.c | 5 - mdk-stage1/dietlibc/libugly/difftime.c | 8 - mdk-stage1/dietlibc/libugly/dirfd.c | 8 - mdk-stage1/dietlibc/libugly/endmntent.c | 7 - mdk-stage1/dietlibc/libugly/facilitynames.c | 32 ---- mdk-stage1/dietlibc/libugly/freeaddrinfo.c | 11 -- mdk-stage1/dietlibc/libugly/ftime.c | 15 -- mdk-stage1/dietlibc/libugly/gai_strerror.c | 13 -- mdk-stage1/dietlibc/libugly/getaddrinfo.c | 140 ---------------- mdk-stage1/dietlibc/libugly/gethostent.c | 116 ------------- mdk-stage1/dietlibc/libugly/getmntent.c | 31 ---- mdk-stage1/dietlibc/libugly/getnameinfo.c | 46 ------ mdk-stage1/dietlibc/libugly/getprotobyname.c | 12 -- mdk-stage1/dietlibc/libugly/getprotobyname_r.c | 17 -- mdk-stage1/dietlibc/libugly/getprotobynumber.c | 12 -- mdk-stage1/dietlibc/libugly/getprotobynumber_r.c | 13 -- mdk-stage1/dietlibc/libugly/getprotoent.c | 10 -- mdk-stage1/dietlibc/libugly/getprotoent_r.c | 78 --------- mdk-stage1/dietlibc/libugly/getservbyname.c | 12 -- mdk-stage1/dietlibc/libugly/getservbyname_r.c | 18 --- mdk-stage1/dietlibc/libugly/getservbyport.c | 12 -- mdk-stage1/dietlibc/libugly/getservbyport_r.c | 13 -- mdk-stage1/dietlibc/libugly/getservent.c | 10 -- mdk-stage1/dietlibc/libugly/getservent_r.c | 91 ----------- mdk-stage1/dietlibc/libugly/gmtime.c | 6 - mdk-stage1/dietlibc/libugly/gmtime_r.c | 35 ---- mdk-stage1/dietlibc/libugly/grantpt.c | 13 -- mdk-stage1/dietlibc/libugly/hasmntopt.c | 18 --- mdk-stage1/dietlibc/libugly/iconv.c | 71 -------- mdk-stage1/dietlibc/libugly/iconv_close.c | 7 - mdk-stage1/dietlibc/libugly/iconv_open.c | 28 ---- mdk-stage1/dietlibc/libugly/isleap.c | 8 - mdk-stage1/dietlibc/libugly/localtime.c | 6 - mdk-stage1/dietlibc/libugly/localtime_r.c | 25 --- mdk-stage1/dietlibc/libugly/logging.c | 197 ----------------------- mdk-stage1/dietlibc/libugly/mktime.c | 53 ------ mdk-stage1/dietlibc/libugly/netent.c | 130 --------------- mdk-stage1/dietlibc/libugly/openpty.c | 54 ------- mdk-stage1/dietlibc/libugly/pclose.c | 11 -- mdk-stage1/dietlibc/libugly/popen.c | 38 ----- mdk-stage1/dietlibc/libugly/prioritynames.c | 22 --- mdk-stage1/dietlibc/libugly/protoent_buf.c | 5 - mdk-stage1/dietlibc/libugly/ptsname.c | 17 -- mdk-stage1/dietlibc/libugly/putpwent.c | 19 --- mdk-stage1/dietlibc/libugly/servent_buf.c | 5 - mdk-stage1/dietlibc/libugly/setenv.c | 19 --- mdk-stage1/dietlibc/libugly/setmntent.c | 7 - mdk-stage1/dietlibc/libugly/strftime.c | 118 -------------- mdk-stage1/dietlibc/libugly/strndup.c | 10 -- mdk-stage1/dietlibc/libugly/strsignal.c | 10 -- mdk-stage1/dietlibc/libugly/system.c | 75 --------- mdk-stage1/dietlibc/libugly/time_table_spd.c | 18 --- mdk-stage1/dietlibc/libugly/timezone.c | 3 - mdk-stage1/dietlibc/libugly/tzfile.c | 107 ------------ mdk-stage1/dietlibc/libugly/unlockpt.c | 10 -- mdk-stage1/dietlibc/libugly/unsetenv.c | 6 - mdk-stage1/dietlibc/libugly/utent.c | 103 ------------ mdk-stage1/dietlibc/libugly/wtent.c | 30 ---- 61 files changed, 2069 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/difftime.c delete mode 100644 mdk-stage1/dietlibc/libugly/dirfd.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/freeaddrinfo.c delete mode 100644 mdk-stage1/dietlibc/libugly/ftime.c delete mode 100644 mdk-stage1/dietlibc/libugly/gai_strerror.c delete mode 100644 mdk-stage1/dietlibc/libugly/getaddrinfo.c delete mode 100644 mdk-stage1/dietlibc/libugly/gethostent.c delete mode 100644 mdk-stage1/dietlibc/libugly/getmntent.c delete mode 100644 mdk-stage1/dietlibc/libugly/getnameinfo.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotobyname.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotobyname_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotobynumber.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotobynumber_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotoent.c delete mode 100644 mdk-stage1/dietlibc/libugly/getprotoent_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservbyname.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservbyname_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservbyport.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservbyport_r.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservent.c delete mode 100644 mdk-stage1/dietlibc/libugly/getservent_r.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/grantpt.c delete mode 100644 mdk-stage1/dietlibc/libugly/hasmntopt.c delete mode 100644 mdk-stage1/dietlibc/libugly/iconv.c delete mode 100644 mdk-stage1/dietlibc/libugly/iconv_close.c delete mode 100644 mdk-stage1/dietlibc/libugly/iconv_open.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/netent.c delete mode 100644 mdk-stage1/dietlibc/libugly/openpty.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/protoent_buf.c delete mode 100644 mdk-stage1/dietlibc/libugly/ptsname.c delete mode 100644 mdk-stage1/dietlibc/libugly/putpwent.c delete mode 100644 mdk-stage1/dietlibc/libugly/servent_buf.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/strndup.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/timezone.c delete mode 100644 mdk-stage1/dietlibc/libugly/tzfile.c delete mode 100644 mdk-stage1/dietlibc/libugly/unlockpt.c delete mode 100644 mdk-stage1/dietlibc/libugly/unsetenv.c delete mode 100644 mdk-stage1/dietlibc/libugly/utent.c delete mode 100644 mdk-stage1/dietlibc/libugly/wtent.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 43c5e2cb2..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 9db1f67c7..000000000 --- a/mdk-stage1/dietlibc/libugly/asprintf.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include -#include "dietwarning.h" - -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_start (arg_ptr, format); - if ((*s=malloc(n+1))) { - n=vsnprintf(*s,n+1,format,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/difftime.c b/mdk-stage1/dietlibc/libugly/difftime.c deleted file mode 100644 index fc71363c7..000000000 --- a/mdk-stage1/dietlibc/libugly/difftime.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "../dietwarning.h" - -double difftime(time_t time1, time_t time2) { - return (double)time1 - (double)time2; -} - -link_warning("difftime","warning: difftime introduces an unnecessary floating point dependency. Don't use it!") diff --git a/mdk-stage1/dietlibc/libugly/dirfd.c b/mdk-stage1/dietlibc/libugly/dirfd.c deleted file mode 100644 index 8d5af8b9a..000000000 --- a/mdk-stage1/dietlibc/libugly/dirfd.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "dietdirent.h" -#define _BSD_SOURCE -#include - -int dirfd(DIR* dirp) { - return dirp->fd; -} 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/freeaddrinfo.c b/mdk-stage1/dietlibc/libugly/freeaddrinfo.c deleted file mode 100644 index 72a13f5e1..000000000 --- a/mdk-stage1/dietlibc/libugly/freeaddrinfo.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -void freeaddrinfo(struct addrinfo *res) { - while (res) { - struct addrinfo *duh; - duh=res; - res=res->ai_next; - free(duh); - } -} diff --git a/mdk-stage1/dietlibc/libugly/ftime.c b/mdk-stage1/dietlibc/libugly/ftime.c deleted file mode 100644 index 3aa2d15c3..000000000 --- a/mdk-stage1/dietlibc/libugly/ftime.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -int ftime(struct timeb *tp) { - struct timeval tv; - struct timezone tz; - int ret=gettimeofday(&tv,&tz); - tp->time = tv.tv_sec; - tp->millitm = tv.tv_usec/1000; - tp->timezone = tz.tz_minuteswest; - tp->dstflag = tz.tz_dsttime; - return ret; -} - diff --git a/mdk-stage1/dietlibc/libugly/gai_strerror.c b/mdk-stage1/dietlibc/libugly/gai_strerror.c deleted file mode 100644 index 9dc4f5dde..000000000 --- a/mdk-stage1/dietlibc/libugly/gai_strerror.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -const char* gai_strerror(int error) { - switch (error) { - case EAI_FAMILY: return "family not supported"; - case EAI_SOCKTYPE: return "socket type not supported"; - case EAI_NONAME: return "unknown host"; - case EAI_SERVICE: return "unknown service"; - case EAI_MEMORY: return "memory allocation failure"; - case EAI_AGAIN: return "temporary failure"; - } - return "DNS error. Sorry."; -} diff --git a/mdk-stage1/dietlibc/libugly/getaddrinfo.c b/mdk-stage1/dietlibc/libugly/getaddrinfo.c deleted file mode 100644 index a4675d92b..000000000 --- a/mdk-stage1/dietlibc/libugly/getaddrinfo.c +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -/* XXX TODO FIXME */ - -int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) { - struct addrinfo **tmp; - int family; - tmp=res; *res=0; - if (hints) { - if (hints->ai_family && hints->ai_family != PF_INET6 && hints->ai_family != PF_INET) return EAI_FAMILY; - if (hints->ai_socktype && hints->ai_socktype != SOCK_STREAM && hints->ai_socktype != SOCK_DGRAM) return EAI_SOCKTYPE; - } - for (family=PF_INET6; ; family=PF_INET) { - if (!hints || hints->ai_family==family || hints->ai_family==AF_UNSPEC) { /* IPv6 addresses are OK */ - struct hostent h; - struct hostent *H; - int herrno=0; - char buf[4096]; - int lookupok=0; - h.h_addr_list=(char**)buf+16; - if (node) { - if (inet_pton(family,node,buf)>0) { - h.h_name=(char*)node; - h.h_addr_list[0]=buf; - lookupok=1; - } else if ((!hints || !(hints->ai_flags&AI_NUMERICHOST)) && - !gethostbyname2_r(node,family,&h,buf,4096,&H,&herrno)) { - lookupok=1; - } else { - if (herrno==TRY_AGAIN) { freeaddrinfo(*res); return EAI_AGAIN; } - } - } else { - h.h_name=0; - h.h_addr_list[0]=buf; - memset(buf,0,16); - if (!hints || !(hints->ai_flags&AI_PASSIVE)) { - if (family==AF_INET) { - buf[0]=127; buf[3]=1; - } else - buf[15]=1; - } - lookupok=1; - } - if (lookupok) { - struct ai_v6 { - struct addrinfo ai; - union { - struct sockaddr_in6 ip6; - struct sockaddr_in ip4; - } ip; - char name[1]; - } *foo; - unsigned short port; - int len=sizeof(struct ai_v6)+(h.h_name?strlen(h.h_name):0); - if (!(foo=malloc(len))) goto error; - foo->ai.ai_next=0; - foo->ai.ai_socktype=SOCK_STREAM; - foo->ai.ai_protocol=IPPROTO_TCP; - foo->ai.ai_addrlen=family==PF_INET6?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in); - foo->ai.ai_addr=(struct sockaddr*)&foo->ip; - if (family==PF_INET6) { - memset(&foo->ip,0,sizeof(foo->ip)); - memmove(&foo->ip.ip6.sin6_addr,h.h_addr_list[0],16); - } else { - memmove(&foo->ip.ip4.sin_addr,h.h_addr_list[0],4); - } - foo->ip.ip6.sin6_family=foo->ai.ai_family=family; - if (h.h_name) { - foo->ai.ai_canonname=foo->name; - memmove(foo->name,h.h_name,strlen(h.h_name)+1); - } else - foo->ai.ai_canonname=0; - if (!hints || hints->ai_socktype!=SOCK_DGRAM) { /* TCP is OK */ - char *x; - port=htons(strtol(service?service:"0",&x,0)); - if (*x) { /* service is not numeric :-( */ - struct servent* se; - if ((se=getservbyname(service,"tcp"))) { /* found a service. */ - port=se->s_port; - blah1: - if (family==PF_INET6) - foo->ip.ip6.sin6_port=port; - else - foo->ip.ip4.sin_port=port; - if (!*tmp) *tmp=&(foo->ai); else (*tmp)->ai_next=&(foo->ai); - if (!(foo=malloc(len))) goto error; - memmove(foo,*tmp,len); - tmp=&(*tmp)->ai_next; - foo->ai.ai_addr=(struct sockaddr*)&foo->ip; - if (foo->ai.ai_canonname) - foo->ai.ai_canonname=foo->name; - } else { - freeaddrinfo(*res); - return EAI_SERVICE; - } - } else goto blah1; - } - foo->ai.ai_socktype=SOCK_DGRAM; - foo->ai.ai_protocol=IPPROTO_UDP; - if (!hints || hints->ai_socktype!=SOCK_STREAM) { /* UDP is OK */ - char *x; - port=htons(strtol(service?service:"0",&x,0)); - if (*x) { /* service is not numeric :-( */ - struct servent* se; - if ((se=getservbyname(service,"udp"))) { /* found a service. */ - port=se->s_port; - blah2: - if (family==PF_INET6) - foo->ip.ip6.sin6_port=port; - else - foo->ip.ip4.sin_port=port; - if (!*tmp) *tmp=&(foo->ai); else (*tmp)->ai_next=&(foo->ai); - if (!(foo=malloc(len))) goto error; - memmove(foo,*tmp,len); - tmp=&(*tmp)->ai_next; - foo->ai.ai_addr=(struct sockaddr*)&foo->ip; - foo->ai.ai_canonname=foo->name; - } else { - freeaddrinfo(*res); - return EAI_SERVICE; - } - } else goto blah2; - } - free(foo); - } - } - if (family==PF_INET) break; - } - if (*res==0) return EAI_NONAME; /* kludge kludge... */ - return 0; -error: - freeaddrinfo(*res); - return EAI_MEMORY; -} diff --git a/mdk-stage1/dietlibc/libugly/gethostent.c b/mdk-stage1/dietlibc/libugly/gethostent.c deleted file mode 100644 index fe92beacf..000000000 --- a/mdk-stage1/dietlibc/libugly/gethostent.c +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dietfeatures.h" - -static char* hostmap=0; -static unsigned int hostlen; - -static char *cur; - -/* ::1 localhost6 alias1 alias2 # internet protocol, pseudo protocol number */ -struct hostent* gethostent_r(char* buf, int len) { - char *dest; - struct hostent* pe=(struct hostent*)buf; - char* last; - char* max=buf+len; - int aliasidx; - if (!hostmap) { - int hostfd=open(_PATH_HOSTS,O_RDONLY); - if (hostfd<0) return 0; - hostlen=lseek(hostfd,0,SEEK_END); - hostmap=mmap(0,hostlen,PROT_READ|PROT_WRITE,MAP_PRIVATE,hostfd,0); - if ((long)hostmap==(-1)) { close(hostfd); hostmap=0; goto error; } - close(hostfd); hostfd=-1; - cur=hostmap; - } - last=hostmap+hostlen; -again: - if ((size_t)lenh_name=0; - pe->h_aliases=(char**)dest; pe->h_aliases[0]=0; dest+=10*sizeof(char*); - pe->h_addr_list=(char**)dest; dest+=2*sizeof(char**); - if (cur>=last) return 0; - if (*cur=='#' || *cur=='\n') goto parseerror; - /* first, the ip number */ - pe->h_name=cur; - while (cur=last) return 0; - if (*cur=='\n') goto parseerror; - { - char save=*cur; - *cur=0; - pe->h_addr_list[0]=dest; - pe->h_addr_list[1]=0; - if (max-dest<16) goto nospace; - if (inet_pton(AF_INET6,pe->h_name,dest)>0) { - pe->h_addrtype=AF_INET6; - pe->h_length=16; - dest+=16; - } else if (inet_pton(AF_INET,pe->h_name,dest)>0) { - pe->h_addrtype=AF_INET; - pe->h_length=4; - dest+=4; - } else { - *cur=save; - goto parseerror; - } - *cur=save; - } - ++cur; - /* now the aliases */ - for (aliasidx=0;aliasidx<9;++aliasidx) { - while (curh_aliases[aliasidx]=cur; - while (curh_aliases[aliasidx]; - int len=cur-from; - if (max-desth_aliases[aliasidx]=dest; - memmove(dest,from,(size_t)(cur-from)); - dest+=len; - *dest=0; ++dest; - } - if (*cur=='\n') { ++cur; ++aliasidx; break; } - if (cur>=last || !isblank(*cur)) break; - cur++; - } - pe->h_aliases[aliasidx]=0; - pe->h_name=pe->h_aliases[0]; - pe->h_aliases++; - return pe; -parseerror: - while (cur -#include -#include -#include - -struct mntent *getmntent(FILE *filep) { - static struct mntent m; - static char buf[1024]; - do { - char *tmp=buf; - int num; - if (!fgets(buf,1024,filep)) return 0; -/* "/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!=' ' && *tmp!='\t') continue; break; - case 5: m.mnt_passno=strtol(tmp,&tmp,0); if (*tmp=='\n') return &m; break; - } - while (*tmp && *tmp!=' ' && *tmp!='\n' && *tmp!='\t') ++tmp; - if (*tmp) { - if (num<4) *tmp++=0; - while (*tmp==' ' || *tmp=='\t') ++tmp; - } else - continue; - } - } while (1); -} diff --git a/mdk-stage1/dietlibc/libugly/getnameinfo.c b/mdk-stage1/dietlibc/libugly/getnameinfo.c deleted file mode 100644 index 40883ba09..000000000 --- a/mdk-stage1/dietlibc/libugly/getnameinfo.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include - -extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase); - -int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, - size_t hostlen, char *serv, size_t servlen, int flags) { - sa_family_t f=((struct sockaddr_storage *)sa)->ss_family; - (void)salen; /* shut gcc up about unused salen */ - if (host && hostlen>0) { /* user wants me to resolve the host name */ - register const char*addr=(f==AF_INET6)?(char*)&((struct sockaddr_in6*)sa)->sin6_addr: - (char*)&((struct sockaddr_in*)sa)->sin_addr; - if (flags&NI_NUMERICHOST) { - if (!inet_ntop(f,addr,host,hostlen)) - return EAI_NONAME; - } else { - char buf[4096]; - struct hostent h; - struct hostent *H; - int herrno; - if (gethostbyaddr_r(addr,f==AF_INET6?16:4,f,&h,buf,4096,&H,&herrno)) { - switch (herrno) { - case TRY_AGAIN: return EAI_AGAIN; - case NO_DATA: - case HOST_NOT_FOUND: return EAI_NONAME; - } - } - strncpy(host,h.h_name,hostlen-1); - host[hostlen-1]=0; - } - } - if (serv && servlen>0) { - register short int port=(f==AF_INET6)?((struct sockaddr_in6*)sa)->sin6_port:((struct sockaddr_in*)sa)->sin_port; - if (flags&NI_NUMERICSERV) { - __ltostr(serv,servlen,ntohs(port),10,0); - } else { - struct servent *s; - if (!(s=getservbyport(port,flags&NI_DGRAM?"udp":"tcp"))) - return EAI_SERVICE; - } - } - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotobyname.c b/mdk-stage1/dietlibc/libugly/getprotobyname.c deleted file mode 100644 index 1de348791..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotobyname.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -extern struct protoent __protoent_pw; -extern char __protoent_buf[1000]; - -struct protoent *getprotobyname(const char *name) { - struct protoent* tmp; - if (getprotobyname_r(name,&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp)==0) - return tmp; - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotobyname_r.c b/mdk-stage1/dietlibc/libugly/getprotobyname_r.c deleted file mode 100644 index 3b1219aa7..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotobyname_r.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -extern int getprotobyname_r(const char* name, - struct protoent *res, char *buf, size_t buflen, - struct protoent **res_sig) { - while (!getprotoent_r(res,buf,buflen,res_sig)) { - int i; - if (!strcmp(res->p_name,name)) goto found; - for (i=0; res->p_aliases[i]; ++i) - if (!strcmp(res->p_aliases[i],name)) goto found; - } - *res_sig=0; -found: - endprotoent(); - return *res_sig?0:-1; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotobynumber.c b/mdk-stage1/dietlibc/libugly/getprotobynumber.c deleted file mode 100644 index 6170753e2..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotobynumber.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -extern struct protoent __protoent_pw; -extern char __protoent_buf[1000]; - -struct protoent *getprotobynumber(int proto) { - struct protoent* tmp; - if (getprotobynumber_r(proto,&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp)==0) - return tmp; - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c b/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c deleted file mode 100644 index 2ca439fc6..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotobynumber_r.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -extern int getprotobynumber_r(int proto, - struct protoent *res, char *buf, size_t buflen, - struct protoent **res_sig) { - while (!getprotoent_r(res,buf,buflen,res_sig)) - if (proto==res->p_proto) goto found; - *res_sig=0; -found: - endprotoent(); - return *res_sig?0:-1; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotoent.c b/mdk-stage1/dietlibc/libugly/getprotoent.c deleted file mode 100644 index 3f0fd4d41..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotoent.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -extern struct protoent __protoent_pw; -extern char __protoent_buf[1000]; - -struct protoent *getprotoent(void) { - struct protoent* tmp; - getprotoent_r(&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp); - return tmp; -} diff --git a/mdk-stage1/dietlibc/libugly/getprotoent_r.c b/mdk-stage1/dietlibc/libugly/getprotoent_r.c deleted file mode 100644 index aa9af79c3..000000000 --- a/mdk-stage1/dietlibc/libugly/getprotoent_r.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include -#include "parselib.h" - -static struct state __ps; - -void setprotoent(int stayopen) { - (void)stayopen; - __prepare_parse(_PATH_PROTOCOLS,&__ps); -} - -void endprotoent(void) { - __end_parse(&__ps); -} - -#define ALIASES 16 - -/* "igmp 2 IGMP # internet group management protocol" */ -int getprotoent_r(struct protoent *res, char *buf, size_t buflen, - struct protoent **res_sig) { - size_t i,j,n,g; - unsigned long l; - if (!__ps.buffirst) setprotoent(0); - if (!__ps.buffirst) goto error; - if (__ps.cur>=__ps.buflen) goto error; - res->p_aliases=(char**)buf; -/* getprotoent */ -again: - n=ALIASES*sizeof(char*); g=0; - for (i=0; i<3; ++i) { - char found; - __ps.cur+=__parse_ws(&__ps); - if (__ps.cur>=__ps.buflen) { if (i==2) break; else goto error; } - j=__parse_nws(&__ps); - if (!isblank(found=__ps.buffirst[__ps.cur+j])) { - if (i==2) break; /* it's ok, no (more) aliases necessary */ -parseerror: - while (__ps.cur+j<__ps.buflen) { - if (__ps.buffirst[__ps.cur+j]=='\n') { - __ps.cur+=j+1; - goto again; - } - ++j; - } - } - switch (i) { - case 0: - res->p_name=buf+n; -copy: - if ((size_t)buflen<=n+j) goto error; - memcpy(buf+n,__ps.buffirst+__ps.cur,j); - buf[n+j]=0; - n+=j+1; - if ((found=='\n' || found=='#') && i==1) i=3; - break; - case 1: - if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror; - res->p_proto=l; - break; - case 2: - res->p_aliases[g]=buf+n; - ++g; - if (g==(ALIASES-1)) break; - --i; /* again */ - goto copy; - } - __ps.cur+=j+1; - } - res->p_aliases[g]=0; - *res_sig=res; - return 0; -error: - *res_sig=0;/* the glibc people should be taken behind the barn and shot */ - return -1; -} diff --git a/mdk-stage1/dietlibc/libugly/getservbyname.c b/mdk-stage1/dietlibc/libugly/getservbyname.c deleted file mode 100644 index f1c74eaa9..000000000 --- a/mdk-stage1/dietlibc/libugly/getservbyname.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -extern struct servent __servent_pw; -extern char __servent_buf[1000]; - -struct servent *getservbyname(const char *name, const char *proto) { - struct servent* tmp; - if (getservbyname_r(name,proto,&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp)==0) - return tmp; - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/getservbyname_r.c b/mdk-stage1/dietlibc/libugly/getservbyname_r.c deleted file mode 100644 index f523a01ca..000000000 --- a/mdk-stage1/dietlibc/libugly/getservbyname_r.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -extern int getservbyname_r(const char* name,const char* proto, - struct servent *res, char *buf, size_t buflen, - struct servent **res_sig) { - while (!getservent_r(res,buf,buflen,res_sig)) { - int i; - if (proto && strcmp(res->s_proto,proto)) continue; - if (!strcmp(res->s_name,name)) goto found; - for (i=0; res->s_aliases[i]; ++i) - if (!strcmp(res->s_aliases[i],name)) goto found; - } - *res_sig=0; -found: - endservent(); - return *res_sig?0:-1; -} diff --git a/mdk-stage1/dietlibc/libugly/getservbyport.c b/mdk-stage1/dietlibc/libugly/getservbyport.c deleted file mode 100644 index 2821deb63..000000000 --- a/mdk-stage1/dietlibc/libugly/getservbyport.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -extern struct servent __servent_pw; -extern char __servent_buf[1000]; - -struct servent *getservbyport(int port, const char *proto) { - struct servent* tmp; - if (getservbyport_r(port,proto,&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp)==0) - return tmp; - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/getservbyport_r.c b/mdk-stage1/dietlibc/libugly/getservbyport_r.c deleted file mode 100644 index 9c0f21bdf..000000000 --- a/mdk-stage1/dietlibc/libugly/getservbyport_r.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -extern int getservbyport_r(int port,const char* proto, - struct servent *res, char *buf, size_t buflen, - struct servent **res_sig) { - while (!getservent_r(res,buf,buflen,res_sig)) - if (port==res->s_port && !strcmp(res->s_proto,proto)) goto ok; - *res_sig=0; -ok: - endservent(); - return *res_sig?0:-1; -} diff --git a/mdk-stage1/dietlibc/libugly/getservent.c b/mdk-stage1/dietlibc/libugly/getservent.c deleted file mode 100644 index 9eabc972a..000000000 --- a/mdk-stage1/dietlibc/libugly/getservent.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -extern struct servent __servent_pw; -extern char __servent_buf[1000]; - -struct servent *getservent(void) { - struct servent* tmp; - getservent_r(&__servent_pw,__servent_buf,sizeof(__servent_buf),&tmp); - return tmp; -} diff --git a/mdk-stage1/dietlibc/libugly/getservent_r.c b/mdk-stage1/dietlibc/libugly/getservent_r.c deleted file mode 100644 index 33db6f31d..000000000 --- a/mdk-stage1/dietlibc/libugly/getservent_r.c +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "parselib.h" - -static struct state __ps; - -void setservent(int stayopen) { - (void)stayopen; - __prepare_parse(_PATH_SERVICES,&__ps); -} - -void endservent(void) { - __end_parse(&__ps); -} - -#define ALIASES 16 - -/* "tcpmux 1/tcp # TCP port multiplexer (RFC1078)" */ -int getservent_r(struct servent *res, char *buf, size_t buflen, - struct servent **res_sig) { - size_t i,j,n,g; - unsigned long l; - if (!__ps.buffirst) setservent(0); - if (!__ps.buffirst) goto error; - if (__ps.cur>=__ps.buflen) goto error; - res->s_aliases=(char**)buf; -/* getservent */ -again: - n=ALIASES*sizeof(char*); g=0; - for (i=0; i<3; ++i) { - char found; - __ps.cur+=__parse_ws(&__ps); - if (__ps.cur>=__ps.buflen) { if (i==2) break; else goto error; } - j=__parse_nws(&__ps); - if (!isblank(found=__ps.buffirst[__ps.cur+j])) { - if (i==2 && found=='#') break; - if (found=='#' || (i>1 && found!='\n')) { -parseerror: - while (__ps.cur+j<__ps.buflen) { - if (__ps.buffirst[__ps.cur+j]=='\n') { - __ps.cur+=j+1; - goto again; - } - ++j; - } - goto error; - } - } - switch (i) { - case 0: - res->s_name=buf+n; -copy: - if (!j) goto parseerror; - if ((size_t)buflen<=n+j) goto error; - memcpy(buf+n,__ps.buffirst+__ps.cur,j); - buf[n+j]=0; - n+=j+1; - if ((found=='\n' || found=='#') && i==1) i=3; - break; - case 1: - { - int k; - k=scan_ulong(__ps.buffirst+__ps.cur,&l); - if (__ps.buffirst[__ps.cur+k]!='/') { - goto parseerror; - } - res->s_port=htons(l); - res->s_proto=buf+n; - j-=k+1; __ps.cur+=k+1; - goto copy; - } - case 2: - res->s_aliases[g]=buf+n; - ++g; - if (g==(ALIASES-1)) break; - --i; /* again */ - goto copy; - } - __ps.cur+=j+1; - } - res->s_aliases[g]=0; - *res_sig=res; - return 0; -error: - *res_sig=0;/* the glibc people should be taken behind the barn and shot */ - return -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 6bc0bb5b2..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 short __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/grantpt.c b/mdk-stage1/dietlibc/libugly/grantpt.c deleted file mode 100644 index 0aa903b29..000000000 --- a/mdk-stage1/dietlibc/libugly/grantpt.c +++ /dev/null @@ -1,13 +0,0 @@ -#define _XOPEN_SOURCE -#include -#include -#include -#include - -int grantpt (int fd) { - struct stat st; - if ((fstat(fd, &st))<0) return -1; - if ((chmod((char*)ptsname(fd), st.st_mode | S_IRUSR | S_IWUSR | S_IWGRP))<0) - return -1; - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/hasmntopt.c b/mdk-stage1/dietlibc/libugly/hasmntopt.c deleted file mode 100644 index 2a547feee..000000000 --- a/mdk-stage1/dietlibc/libugly/hasmntopt.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -char *hasmntopt(const struct mntent *mnt, const char *opt) { - char *s=mnt->mnt_opts; - char *c; - int len=strlen(opt); - if (!s) return 0; - for (c=s;;) { - if (!(c=strstr(c,opt))) break; - if (c==s || c[-1]==',') { - if (c[len]==0 || c[len]==',' || c[len]=='=') - return c; - } - c+=len+1; - } - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/iconv.c b/mdk-stage1/dietlibc/libugly/iconv.c deleted file mode 100644 index 45be5d91d..000000000 --- a/mdk-stage1/dietlibc/libugly/iconv.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "dietfeatures.h" -#include -#include "dieticonv.h" -#include - -size_t iconv(iconv_t cd, const char* * inbuf, size_t * - inbytesleft, char* * outbuf, size_t * outbytesleft) { - size_t converted=0,i,j,k; - int bits; - if (!inbuf || !*inbuf) return 0; - while (*inbytesleft) { - unsigned int v=0; - v=*(unsigned char*)*inbuf; - i=j=1; - switch (ic_from(cd)) { - case UCS_2: - v=ntohs(*(unsigned short*)*inbuf); - i=2; - break; - case UCS_4: - v=ntohs(*(unsigned int*)*inbuf); - i=4; - case ISO_8859_1: - break; - case UTF_8: - if (!(v&0x80)) break; - for (i=0xC0; i!=0xFC; i=(i>>1)+0x80) - if ((v&((i>>1)|0x80))==i) { - v&=~i; - break; - } - for (i=1; ((*inbuf)[i]&0xc0)==0x80; ++i) - v=(v<<6)|((*inbuf)[i]&0x3f); -/* printf("got %u in %u bytes, buflen %u\n",v,i,*inbytesleft); */ - break; - } - switch (ic_to(cd)) { - case ISO_8859_1: - **outbuf=(unsigned char)v; - break; - case UCS_2: - *(unsigned short*)*outbuf=htons(v); - j=2; - break; - case UCS_4: - *(unsigned int*)*outbuf=htonl(v); - j=4; - break; - case UTF_8: - if (v>0x04000000) { bits=30; **outbuf=0xFC; j=6; } else - if (v>0x00200000) { bits=24; **outbuf=0xF8; j=5; } else - if (v>0x00010000) { bits=18; **outbuf=0xF0; j=4; } else - if (v>0x00000800) { bits=12; **outbuf=0xE0; j=3; } else - if (v>0x00000080) { bits=6; **outbuf=0xC0; j=2; } else - { bits=0; **outbuf=0; } - **outbuf |= (unsigned char)(v>>bits); - if (*outbytesleft>bits)&0x3F); - } - break; - } - *inbuf+=i; *inbytesleft-=i; ++converted; - *outbuf+=j; *outbytesleft-=j; - } - return converted; -} diff --git a/mdk-stage1/dietlibc/libugly/iconv_close.c b/mdk-stage1/dietlibc/libugly/iconv_close.c deleted file mode 100644 index 7d5d4c4b9..000000000 --- a/mdk-stage1/dietlibc/libugly/iconv_close.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "dieticonv.h" - -int iconv_close(iconv_t cd) { - (void)cd; /* shut gcc up about unused cd */ - return 0; -} diff --git a/mdk-stage1/dietlibc/libugly/iconv_open.c b/mdk-stage1/dietlibc/libugly/iconv_open.c deleted file mode 100644 index eabab4273..000000000 --- a/mdk-stage1/dietlibc/libugly/iconv_open.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include "dietfeatures.h" -#include -#include -#include "dieticonv.h" - -static enum charset parsecharset(const char* s) { - if (!strcasecmp(s,"UTF-8")) return UTF_8; else - if (!strcasecmp(s,"UCS-2") || !strcasecmp(s,"UCS2")) return UCS_2; else - if (!strcasecmp(s,"UCS-4") || !strcasecmp(s,"UCS4")) return UCS_4; else - if (!strcasecmp(s,"ISO-8859-1")) return ISO_8859_1; else - if (!strcasecmp(s,"US-ASCII")) return ISO_8859_1; else - return INVALID; -} - -iconv_t iconv_open(const char* tocode, const char* fromcode) { - int f,t; - - f=parsecharset(fromcode); - t=parsecharset(tocode); - - if (f==INVALID || t==INVALID) { - errno=EINVAL; - return (iconv_t)(-1); - } - return (f|t<<16); -} diff --git a/mdk-stage1/dietlibc/libugly/isleap.c b/mdk-stage1/dietlibc/libugly/isleap.c deleted file mode 100644 index d83712792..000000000 --- a/mdk-stage1/dietlibc/libugly/isleap.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -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 5d420303c..000000000 --- a/mdk-stage1/dietlibc/libugly/localtime_r.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "dietfeatures.h" -#include -#include - -#ifdef WANT_TZFILE_PARSER -extern void __maplocaltime(void); -extern time_t __tzfile_map(time_t t, int *isdst); -#else -extern long int timezone; -extern int daylight; -#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); - timezone=tz.tz_minuteswest*60L; - tmp=*t+timezone; -#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 680a1f850..000000000 --- a/mdk-stage1/dietlibc/libugly/logging.c +++ /dev/null @@ -1,197 +0,0 @@ -#include -#include "dietfeatures.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define _PATH_CONSOLE "/dev/console" -#define BUF_SIZE 2048 /* messagebuffer size (>= 200) */ - -#define MAX_LOGTAG 1000 - -/* 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 __libc_closelog(void); -void __libc_closelog(void) -{ - closelog_intern(); - - LogTag[0]=0; - LogType = SOCK_DGRAM; -} -void closelog(void) __attribute__((weak,alias("__libc_closelog"))); - -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) { - int old_errno=errno; - if(connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) { - int saved_errno=errno; - close(LogFile); - LogFile = -1; - if((LogType == SOCK_DGRAM) && (saved_errno == EPROTOTYPE)) { - /* retry with SOCK_STREAM instead of SOCK_DGRAM */ - LogType = SOCK_STREAM; - errno=old_errno; - continue; - } - } - else connected = 1; - } - break; - } -} - -/* has to be secured against multiple, simultanious call's in threaded environment */ -void __libc_openlog(const char *ident, int option, int facility); -void __libc_openlog(const char *ident, int option, int facility) -{ - if (ident) { - strncpy(LogTag,ident,MAX_LOGTAG); - LogTag[MAX_LOGTAG-1]=0; - } - openlog_intern(option, facility); -} -void openlog(const char *ident, int option, int facility) __attribute__((weak,alias("__libc_openlog"))); - -int setlogmask(int mask) -{ - int old = LogMask; - if (mask) LogMask = mask; - return old; -} - -void __libc_vsyslog(int priority, const char *format, va_list arg_ptr); -void __libc_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; - int saved_errno = errno; - - /* 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 { - errno=saved_errno; - 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 vsyslog(int priority, const char *format, va_list arg_ptr) __attribute__((weak,alias("__libc_vsyslog"))); - -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 348068e1d..000000000 --- a/mdk-stage1/dietlibc/libugly/mktime.c +++ /dev/null @@ -1,53 +0,0 @@ -#include - -extern const short __spm []; - -time_t mktime ( register struct tm* const t ) -{ - register time_t day; - register time_t i; - - if ( t->tm_year < 70 ) - return (time_t) -1; - - day = t->tm_yday = __spm [t->tm_mon] + t->tm_mday-1 + ( __isleap (t->tm_year+1900) & (t->tm_mon > 1) ); - - for ( i = 70; i < t->tm_year; i++ ) - day += 365 + __isleap (i+1900); - - /* day is now the number of days since 'Jan 1 1970' */ - i = 7; - t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */ - - i = 24; - day *= i; - i = 60; - return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec; -} - -#if 0 - -#include - -main() -{ - int i, j, k; - static char *s[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; - - for (i=70; i<200; i++) - for (j=0; j<12; j++) - for (k=1; k<=31; k++) { - struct tm t; - double x; - t.tm_year = i; - t.tm_mon = j; - t.tm_mday = k; - t.tm_hour = 0; - t.tm_min = 0; - t.tm_sec = 0; - x = mktime (&t); - printf ("%4d.%5.0f %2u.%02u.%04u %s\n", (int)floor(x/86400), x-86400.*(int)floor(x/86400), k, j+1, 1900+i, s[t.tm_wday] ); - } - -} -#endif diff --git a/mdk-stage1/dietlibc/libugly/netent.c b/mdk-stage1/dietlibc/libugly/netent.c deleted file mode 100644 index 4710d0fe6..000000000 --- a/mdk-stage1/dietlibc/libugly/netent.c +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "dietfeatures.h" -#include -#include - -static int netfd=-1; -static char* netmap; -static unsigned int netlen; - -static char* aliases[10]; - -static char *cur; - -/* loopback 127.0.0.0 lo # comment */ -struct netent *getnetent(void) { - static struct netent ne; - char *last; - int aliasidx; - if (netfd<0) { - netfd=open(_PATH_NETWORKS,O_RDONLY); - if (netfd<0) return 0; - fcntl (netfd, F_SETFD, FD_CLOEXEC); - netlen=lseek(netfd,0,SEEK_END); - netmap=mmap(0,netlen,PROT_READ|PROT_WRITE,MAP_PRIVATE,netfd,0); - if ((long)netmap==(-1)) goto error; - cur=netmap; - } - last=netmap+netlen; -again: - ne.n_name=0; - ne.n_aliases=aliases; aliases[0]=0; - ne.n_addrtype=AF_INET; - ne.n_net=0; - if (cur>=last) return 0; - if (*cur=='#' || *cur=='\n') goto parseerror; - /* first, the primary name */ - if (!isalpha(*cur)) goto parseerror; - ne.n_name=cur; - ne.n_aliases=aliases; - while (cur=last) return 0; - if (*cur=='\n') goto parseerror; - *cur=0; cur++; - /* second, the ip */ - while (cur=last) return 0; - /* now the aliases */ - for (aliasidx=0;aliasidx<10;++aliasidx) { - while (cur=last || !isblank(*cur)) break; - *cur++=0; - } - aliases[aliasidx]=0; - return ≠ -parseerror: - while (curn_net && type==s->n_addrtype) - return s; - } - return 0; -} - -void endnetent(void) { - if (netmap!=(char*)-1) munmap(netmap,netlen); - if (netfd!=-1) close(netfd); - netmap=(char*)-1; - netfd=-1; -} - -void setnetent(int stayopen) { - (void)stayopen; - endnetent(); -} - -struct netent *getnetbyname(const char *name) { - struct netent *s; - setnetent(0); - for (s=getnetent(); s; s=getnetent()) { - char **tmp; -#if 0 - write(1,"found ",6); - write(1,s->s_name,strlen(s->s_name)); - write(1,"/",1); - write(1,s->s_proto,strlen(s->s_proto)); - write(1,"\n",1); - if (!strcmp(s->s_name,"ssh")) { - write(2,"ssh!\n",5); - } -#endif - if (!strcmp(name,s->n_name)) - return s; - tmp=s->n_aliases; - while (*tmp) - if (!strcmp(name,*tmp++)) return s; - } - return 0; -} - diff --git a/mdk-stage1/dietlibc/libugly/openpty.c b/mdk-stage1/dietlibc/libugly/openpty.c deleted file mode 100644 index 8d06f329c..000000000 --- a/mdk-stage1/dietlibc/libugly/openpty.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase); - -int openpty(int *amaster, int *aslave, char *name, struct termios - *termp, struct winsize *winp) { - int fd; - char buf[20]; -#if 0 - This is what glibc does: - open("/dev/ptmx", O_RDWR) = 4 - statfs("/dev/pts", {f_type=0x1cd1, f_bsize=1024, f_blocks=0, f_bfree=0, f_files=0, f_ffree=0, f_namelen=255}) = 0 - ioctl(4, TCGETS, {B38400 opost isig icanon echo ...}) = 0 - ioctl(4, 0x80045430, [0]) = 0 - stat("/dev/pts/0", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 - statfs("/dev/pts/0", {f_type=0x1cd1, f_bsize=1024, f_blocks=0, f_bfree=0, f_files=0, f_ffree=0, f_namelen=255}) = 0 - ioctl(4, 0x40045431, [0]) = 0 - ioctl(4, TCGETS, {B38400 opost isig icanon echo ...}) = 0 - ioctl(4, 0x80045430, [0]) = 0 - stat("/dev/pts/0", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 - open("/dev/pts/0", O_RDWR|O_NOCTTY) = 5 -#endif - if ((fd=open("/dev/ptmx",O_RDWR))<0) return -1; -#if 0 - if (ioctl(fd,TCGETS,&ts)<0) goto kaputt; -#endif - { - int unlock=0; - while (ioctl(fd,TIOCSPTLCK, &unlock)<0) if (errno!=EINTR) goto kaputt; - } - { - int ptyno; - while (ioctl(fd,TIOCGPTN,&ptyno)<0) if (errno!=EINTR) goto kaputt; - strcpy(buf,"/dev/pts/"); - __ltostr(buf+9,10,ptyno,10,0); - } - *aslave=open(buf,O_RDWR|O_NOCTTY); - if (*aslave<0) goto kaputt; - *amaster=fd; - if (name) strcpy(name,buf); - if (termp) - while (tcsetattr(*aslave,TCSAFLUSH,termp) && errno==EINTR); - if (winp) while (ioctl(*aslave, TIOCSWINSZ, winp) && errno==EINTR); - return 0; -kaputt: - close(fd); - return -1; -} 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 aa9a2cde0..000000000 --- a/mdk-stage1/dietlibc/libugly/popen.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "dietstdio.h" -#include -#include -#include "binshstr.h" - -extern char **environ; - -FILE *popen(const char *command, const char *type) { - int pfd[2]; - int fd0; - FILE* f; - pid_t pid; - - if (pipe(pfd)<0) return 0; - fd0=(*type=='r'); - if (!(f=fdopen(pfd[!fd0],type))) { - close(pfd[0]); /* malloc failed */ - close(pfd[1]); - return 0; - } - if ((pid=fork())<0) { - close(pfd[0]); - close(pfd[1]); - return 0; - } - if (!pid) { /* child */ - const char *argv[]={__sh,"-c",0,0}; - close(pfd[!fd0]); close(fd0); - dup2(pfd[fd0],fd0); close(pfd[fd0]); - argv[2]=command; - execve(__binsh,(char*const*)argv,environ); - _exit(127); - } - close(pfd[fd0]); - fcntl (pfd[!fd0], F_SETFD, FD_CLOEXEC); - 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/protoent_buf.c b/mdk-stage1/dietlibc/libugly/protoent_buf.c deleted file mode 100644 index 0e303a5d4..000000000 --- a/mdk-stage1/dietlibc/libugly/protoent_buf.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -struct protoent __protoent_pw; -char __protoent_buf[1000]; - diff --git a/mdk-stage1/dietlibc/libugly/ptsname.c b/mdk-stage1/dietlibc/libugly/ptsname.c deleted file mode 100644 index a332faf6c..000000000 --- a/mdk-stage1/dietlibc/libugly/ptsname.c +++ /dev/null @@ -1,17 +0,0 @@ -#define _XOPEN_SOURCE -#include -#include -#include -#include - -# define MAX_FDS 4 - -char *ptsname(int fd) { - static char buffer[9+MAX_FDS]; /* Ahh..great */ - int pty; - - strcpy(buffer,"/dev/pts/"); - if ((ioctl(fd, TIOCGPTN, &pty)) == -1) return 0; - __ltostr(buffer+9, MAX_FDS, pty, 10, 0); - return buffer; -} diff --git a/mdk-stage1/dietlibc/libugly/putpwent.c b/mdk-stage1/dietlibc/libugly/putpwent.c deleted file mode 100644 index f192c5934..000000000 --- a/mdk-stage1/dietlibc/libugly/putpwent.c +++ /dev/null @@ -1,19 +0,0 @@ -/* man, what a crook! */ - -#include -#include -#include -#include -#include "dietwarning.h" - -int putpwent(const struct passwd *p, FILE *stream) { - if (p && stream) { - fprintf(stream,"%s:%s:%d:%d:%s:%s:%s\n", p->pw_name, p->pw_passwd, - p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); - return 0; - } - (*__errno_location())=EINVAL; - return -1; -} - -link_warning("putpwent","putpwent is garbage, don't use!") diff --git a/mdk-stage1/dietlibc/libugly/servent_buf.c b/mdk-stage1/dietlibc/libugly/servent_buf.c deleted file mode 100644 index b9e992adf..000000000 --- a/mdk-stage1/dietlibc/libugly/servent_buf.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -struct servent __servent_pw; -char __servent_buf[1000]; - diff --git a/mdk-stage1/dietlibc/libugly/setenv.c b/mdk-stage1/dietlibc/libugly/setenv.c deleted file mode 100644 index c65910471..000000000 --- a/mdk-stage1/dietlibc/libugly/setenv.c +++ /dev/null @@ -1,19 +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) { - if (getenv(name)) { - if (!overwrite) return 0; - unsetenv(name); - } - { - char *c=malloc(strlen(name)+strlen(value)+3); - 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 365d0c84f..000000000 --- a/mdk-stage1/dietlibc/libugly/strftime.c +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include "dietfeatures.h" - -static const char sweekdays [7] [4] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; -static const char weekdays [7] [10] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" -}; -static const char smonths [12] [4] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; -static const char* months [12] = { - "January", "February", "March", "April", smonths[5-1], "June", - "July", "August", "September", "October", "November", "December" -}; -static const char ampm [4] [3] = { - "am", "pm", - "AM", "PM" -}; - -static int i2a ( char* dest,unsigned int x ) -{ - int div = 10; - *dest++ = x/div + '0'; - *dest++ = x%div + '0'; - *dest++ = '\0'; - return 2; -} - -size_t strftime ( char* dst, size_t max, const char* format, const struct tm* tm ) -{ - char* p = dst; - const char* src; - unsigned int no; - char buf [5]; - - - for ( ; *format != '\0'; format++ ) { - if (*format == '%') { - if (*++format == '%') { - *p++ = '%'; - } - else -again: - switch (*format) { -// case '%': *p++ = '%'; break; // reduce size of jump table - case 'n': *p++ = '\n'; break; - case 't': *p++ = '\t'; break; - case 'O': case 'E': ++format; goto again; - case 'c': src = "%b %a %d %k:%M:%S %Z %Y"; goto _strf; - case 'r': src = "%I:%M:%S %p"; goto _strf; - case 'R': src = "%H:%M"; goto _strf; - case 'x': src = "%b %a %d"; goto _strf; - case 'X': src = "%k:%M:%S"; goto _strf; - case 'D': src = "%m/%d/%y"; goto _strf; - case 'T': src = "%H:%M:%S"; - _strf: p += strftime (p, (size_t)(dst+max-p), src, tm); break; - case 'a': src = sweekdays [tm->tm_wday]; goto _str; - case 'A': src = weekdays [tm->tm_wday]; goto _str; - case 'h': - case 'b': src = smonths [tm->tm_mon]; goto _str; - case 'B': src = months [tm->tm_mon]; goto _str; - case 'p': src = ampm [tm->tm_hour > 12 ? 3 : 2]; goto _str; - case 'P': src = ampm [tm->tm_hour > 12 ? 1 : 0]; goto _str; - case 'C': no = tm->tm_year/100 + 19; goto _no; - case 'd': no = tm->tm_mday; goto _no; - case 'e': no = tm->tm_mday; goto _nos; - case 'H': no = tm->tm_hour; goto _no; - case 'I': no = tm->tm_hour % 12; goto _no; - case 'j': no = tm->tm_yday; goto _no; - case 'k': no = tm->tm_hour; goto _nos; - case 'l': no = tm->tm_hour % 12; goto _nos; - case 'm': no = tm->tm_mon + 1; goto _no; - case 'M': no = tm->tm_min; goto _no; - case 'S': no = tm->tm_sec; goto _no; - case 'u': no = tm->tm_wday ? tm->tm_wday : 7; goto _no; - case 'w': no = tm->tm_wday; goto _no; - case 'U': no = (tm->tm_yday - tm->tm_wday + 7) / 7; goto _no; - case 'W': no = (tm->tm_yday - (tm->tm_wday - 1 + 7) % 7 + 7) / 7; goto _no; - case 'Z': -#ifdef WANT_TZFILE_PARSER - tzset(); src = tzname[0]; -#else - src = "[unknown timezone]"; -#endif - goto _str; - case 'Y': i2a ( buf+0, (unsigned int)(tm->tm_year / 100 + 19) ); - i2a ( buf+2, (unsigned int)(tm->tm_year % 100) ); - src = buf; - goto _str; - case 'y': no = tm->tm_year % 100; goto _no; - _no: i2a ( buf, no ); /* append number 'no' */ - src = buf; - goto _str; - _nos: i2a ( buf, no ); /* the same, but '0'->' ' */ - if (buf[0] == '0') - buf[0] = ' '; - src = buf; - _str: while (*src && p < dst+max) /* append string */ - *p++ = *src++; - break; - }; - } else { - *p++ = *format; - } - - if (p >= dst+max) - break; - } - - *p = '\0'; - return p - dst; -} - - diff --git a/mdk-stage1/dietlibc/libugly/strndup.c b/mdk-stage1/dietlibc/libugly/strndup.c deleted file mode 100644 index 7f912d4c6..000000000 --- a/mdk-stage1/dietlibc/libugly/strndup.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -char *strndup(const char *s,size_t n) { - char *tmp=(char *)malloc(n+1); - if (!tmp) return 0; - strncpy(tmp,s,n); - tmp[n]=0; - return tmp; -} diff --git a/mdk-stage1/dietlibc/libugly/strsignal.c b/mdk-stage1/dietlibc/libugly/strsignal.c deleted file mode 100644 index d72777571..000000000 --- a/mdk-stage1/dietlibc/libugly/strsignal.c +++ /dev/null @@ -1,10 +0,0 @@ -#define _GNU_SOURCE -#include -#include - -const char* strsignal(int sig) { - if (sig<=SIGRTMAX) - return sys_siglist[sig]; - 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 714aad056..000000000 --- a/mdk-stage1/dietlibc/libugly/system.c +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include -#include -#include "dietwarning.h" -#include "dietfeatures.h" -#include "binshstr.h" - -extern char **environ; - -int __libc_system (const char *line); - -int __libc_system (const char *line) -{ - struct sigaction sa, intr, quit; - sigset_t block,omask; - 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; -undo: - sigaction (SIGINT, &intr, (struct sigaction*)0); - errno=save; - return -1; - } - sigemptyset(&block); - sigaddset(&block,SIGCHLD); - if (sigprocmask(SIG_BLOCK,&block,&omask)<0) { - save=errno; - sigaction (SIGQUIT, &quit, (struct sigaction*)0); - goto undo; - } - - pid=fork(); - if (pid>0) - { /* parent */ - int n; - do - n=waitpid(pid, &ret, 0); - while ((n==-1) && (errno==EINTR)); - if (n!=pid) ret=-1; - } - else if (!pid) - { /* child */ - const char *nargs[4]; - nargs[0] = __sh; - nargs[1] = "-c"; - nargs[2] = line; - nargs[3] = 0; - - sigaction(SIGINT, &intr, (struct sigaction*)0); - sigaction(SIGQUIT, &quit, (struct sigaction*)0); - sigprocmask(SIG_SETMASK,&omask,0); - - execve(__binsh,(char *const *)nargs, environ); - _exit(127); - } - save = errno; - sigaction (SIGINT, &intr, (struct sigaction *)0); - sigaction (SIGQUIT, &quit, (struct sigaction *)0); - sigprocmask(SIG_SETMASK,&omask,0); - 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 6850d76c4..000000000 --- a/mdk-stage1/dietlibc/libugly/time_table_spd.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -/* days per month -- nonleap! */ -const short __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/timezone.c b/mdk-stage1/dietlibc/libugly/timezone.c deleted file mode 100644 index e8a94a906..000000000 --- a/mdk-stage1/dietlibc/libugly/timezone.c +++ /dev/null @@ -1,3 +0,0 @@ - -long int timezone; -int daylight; diff --git a/mdk-stage1/dietlibc/libugly/tzfile.c b/mdk-stage1/dietlibc/libugly/tzfile.c deleted file mode 100644 index e0e8f7846..000000000 --- a/mdk-stage1/dietlibc/libugly/tzfile.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "dietfeatures.h" -#include -#include -#include -#include -#include - -/* #include */ - -char* tzname[2]={"GMT","GMT"}; - -#ifdef WANT_TZFILE_PARSER -static char *tzfile=0; -static int tzlen=-1; - -void __maplocaltime(void); -void __maplocaltime(void) { - 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_PRIVATE,fd,0))==MAP_FAILED) return; - close(fd); - if (ntohl(*(int*)tzfile) != 0x545a6966) return; - tzlen=len; -} - -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); -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; i0); - for (i=0; i= t) { - char* tz=tmp; -/* printf("match at %d\n",i); */ - tmp+=tzh_timecnt*4; - i=tmp[i-1]; -/* printf("using index %d\n",i); */ - tmp+=tzh_timecnt; - tz+=tzh_timecnt*5+tzh_leapcnt*4+tzh_typecnt*6; - tmp+=i*6; -/* printf("(%lu,%d,%d)\n",ntohl(*(int*)tmp),tmp[4],tmp[5]); */ - *isdst=tmp[4]; - tzname[0]=tz+tmp[5]; - timezone=-(__myntohl(tmp)); - return t-timezone; - } - } - return t; -} - -void tzset(void) { - int isdst; - __maplocaltime(); - __tzfile_map(time(0),&isdst); -} - -#else -void tzset(void) __attribute__((weak,alias("__nop"))); -#endif diff --git a/mdk-stage1/dietlibc/libugly/unlockpt.c b/mdk-stage1/dietlibc/libugly/unlockpt.c deleted file mode 100644 index e0246ed8e..000000000 --- a/mdk-stage1/dietlibc/libugly/unlockpt.c +++ /dev/null @@ -1,10 +0,0 @@ -#define _XOPEN_SOURCE -#include -#include -#include - -int unlockpt (int fd) { - int foo; - /* hehe, that one is easy */ - return (ioctl (fd, TIOCSPTLCK, &foo)); -} 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); -} - diff --git a/mdk-stage1/dietlibc/libugly/utent.c b/mdk-stage1/dietlibc/libugly/utent.c deleted file mode 100644 index d8d5d1ba7..000000000 --- a/mdk-stage1/dietlibc/libugly/utent.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include - -static const char *utmp_file_name = _PATH_UTMP; -static int fd = -1; - -static int lock_record(int type) { - struct flock fl; - fl.l_whence = SEEK_CUR; - fl.l_start = 0; - fl.l_len = sizeof(struct utmp); - fl.l_pid = 0; - fl.l_type = type; - return fcntl(fd, F_SETLKW, &fl); -} - -static int unlock_record() { - struct flock fl; - fl.l_whence = SEEK_CUR; - fl.l_start = -sizeof(struct utmp); - fl.l_len = sizeof(struct utmp); - fl.l_pid = 0; - fl.l_type = F_UNLCK; - return fcntl(fd, F_SETLK, &fl); -} - -void utmpname(const char *file) { - if (file) - utmp_file_name = file; - else - utmp_file_name = _PATH_UTMP; -} - -void setutent() { - if (fd<0) fd = open(utmp_file_name,O_RDWR); - if (fd<0) fd = open(utmp_file_name,O_RDONLY); - fcntl (fd, F_SETFD, FD_CLOEXEC); - lseek(fd,0,SEEK_SET); -} - -void endutent() { - if (fd<0) return; - close(fd); fd=-1; -} - -struct utmp *getutent(void) { - static struct utmp getutent_tmp; - int ret; - - if (fd<0) { - setutent(); - if (fd<0) return 0; - } - if (lock_record(F_RDLCK)) return 0; - ret=read(fd, &getutent_tmp, sizeof(struct utmp)); - unlock_record(); - if (ret<1) return 0; - return &getutent_tmp; -} - -struct utmp *getutid(struct utmp *ut) { - struct utmp *tmp; - - while ((tmp = getutent())) { - if (ut->ut_type && (ut->ut_type <= OLD_TIME)) { - if (ut->ut_type == tmp->ut_type) break; - } - if ((ut->ut_type >= INIT_PROCESS) && (ut->ut_type <= DEAD_PROCESS)) { - if (!strncmp(ut->ut_id,tmp->ut_id,4)) break; - } - } - return tmp; -} - -struct utmp *getutline(struct utmp *ut) { - struct utmp *tmp; - - while ((tmp = getutent())) { - if ((tmp->ut_type == USER_PROCESS) || (tmp->ut_type == LOGIN_PROCESS)) { - if (!strncmp(ut->ut_line,tmp->ut_line,UT_LINESIZE)) break; - } - } - return tmp; -} - -void pututline(struct utmp *ut) { - struct utmp *tmp; - - if ((tmp = getutid(ut))) { - lseek(fd, - (off_t)sizeof(struct utmp), SEEK_CUR); - if (lock_record(F_WRLCK)) return; - write(fd, ut, sizeof(struct utmp)); - } - else { - lseek(fd, 0, SEEK_END); - if (lock_record(F_WRLCK)) return; - write(fd, ut, (off_t)sizeof(struct utmp)); - } - unlock_record(); -} - diff --git a/mdk-stage1/dietlibc/libugly/wtent.c b/mdk-stage1/dietlibc/libugly/wtent.c deleted file mode 100644 index 1ca7c3202..000000000 --- a/mdk-stage1/dietlibc/libugly/wtent.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include - -void updwtmp(const char *wtmp_file, const struct utmp *ut) { - int fd = open(wtmp_file, O_WRONLY|O_APPEND); - if (fd<0) return; - fcntl (fd, F_SETFD, FD_CLOEXEC); - write(fd, ut, sizeof(struct utmp)); - close(fd); -} - -void logwtmp(const char *line, const char *name, const char *host) { - struct utmp ut; - - memset(&ut, 0, sizeof(struct utmp)); - - ut.ut_pid = getpid (); - ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS; - - memccpy (ut.ut_line, line, 0, sizeof ut.ut_line); - memccpy (ut.ut_name, name, 0, sizeof ut.ut_name); - memccpy (ut.ut_host, host, 0, sizeof ut.ut_host); - - gettimeofday (&ut.ut_tv, NULL); - - updwtmp (_PATH_WTMP, &ut); -} - -- cgit v1.2.1