summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libcruft
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/libcruft')
-rw-r--r--mdk-stage1/dietlibc/libcruft/___div.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/__end_parse.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_1.c9
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_nws.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/__parse_ws.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/__prepare_parse.c19
-rw-r--r--mdk-stage1/dietlibc/libcruft/alphasort.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/alphasort64.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/bcopy.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/bzero.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/clock.c21
-rw-r--r--mdk-stage1/dietlibc/libcruft/dn_expand.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft.c181
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft2.c173
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft3.c3
-rw-r--r--mdk-stage1/dietlibc/libcruft/dnscruft4.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getdtablesize.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrent_r.c78
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrgid.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrgid_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrnam.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getgrnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyaddr.c35
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c2
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyaddr_r.c84
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyname.c34
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyname2.c36
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyname2_r.c55
-rw-r--r--mdk-stage1/dietlibc/libcruft/gethostbyname_r.c68
-rw-r--r--mdk-stage1/dietlibc/libcruft/getlogin.c6
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_data.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_long.c103
-rw-r--r--mdk-stage1/dietlibc/libcruft/getopt_long_only.c108
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpagesize.c15
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpass.c52
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwent_r.c65
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwnam.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwuid.c12
-rw-r--r--mdk-stage1/dietlibc/libcruft/getpwuid_r.c13
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspent.c10
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspent_r.c68
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspnam.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/getspnam_r.c14
-rw-r--r--mdk-stage1/dietlibc/libcruft/getusershell.c33
-rw-r--r--mdk-stage1/dietlibc/libcruft/grbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/h_errno.c1
-rw-r--r--mdk-stage1/dietlibc/libcruft/herrno_location.c8
-rw-r--r--mdk-stage1/dietlibc/libcruft/herror.c8
-rw-r--r--mdk-stage1/dietlibc/libcruft/hstrerror.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_addr.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_aton.c43
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_ntoa.c8
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_ntoa_r.c22
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_ntop.c77
-rw-r--r--mdk-stage1/dietlibc/libcruft/inet_pton.c102
-rw-r--r--mdk-stage1/dietlibc/libcruft/initgroups.c24
-rw-r--r--mdk-stage1/dietlibc/libcruft/killpg.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/localeconv.c15
-rw-r--r--mdk-stage1/dietlibc/libcruft/mkdtemp.c28
-rw-r--r--mdk-stage1/dietlibc/libcruft/mkstemp.c31
-rw-r--r--mdk-stage1/dietlibc/libcruft/mktemp.c17
-rw-r--r--mdk-stage1/dietlibc/libcruft/pwbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_init.c9
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_mkquery.c75
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_query.c95
-rw-r--r--mdk-stage1/dietlibc/libcruft/res_search.c35
-rw-r--r--mdk-stage1/dietlibc/libcruft/scan_ulong.c13
-rw-r--r--mdk-stage1/dietlibc/libcruft/scandir.c47
-rw-r--r--mdk-stage1/dietlibc/libcruft/scandir64.c47
-rw-r--r--mdk-stage1/dietlibc/libcruft/setegid.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/seteuid.c11
-rw-r--r--mdk-stage1/dietlibc/libcruft/setlocale.c7
-rw-r--r--mdk-stage1/dietlibc/libcruft/spbuf.c5
-rw-r--r--mdk-stage1/dietlibc/libcruft/sysconf.c43
-rw-r--r--mdk-stage1/dietlibc/libcruft/sysconf_cpus.c64
-rw-r--r--mdk-stage1/dietlibc/libcruft/tempnam.c32
-rw-r--r--mdk-stage1/dietlibc/libcruft/tmpnam.c31
81 files changed, 0 insertions, 2472 deletions
diff --git a/mdk-stage1/dietlibc/libcruft/___div.c b/mdk-stage1/dietlibc/libcruft/___div.c
deleted file mode 100644
index d359dc47b..000000000
--- a/mdk-stage1/dietlibc/libcruft/___div.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "dietwarning.h"
-#include <stdlib.h>
-
-div_t div(int numer, int denom) {
- div_t temp;
- temp.quot=numer/denom;
- temp.rem=numer%denom;
- return temp;
-}
-
-link_warning("div","warning: your code uses div(), which is completely superfluous!");
diff --git a/mdk-stage1/dietlibc/libcruft/__end_parse.c b/mdk-stage1/dietlibc/libcruft/__end_parse.c
deleted file mode 100644
index 6c36318b5..000000000
--- a/mdk-stage1/dietlibc/libcruft/__end_parse.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include "parselib.h"
-
-void __end_parse(struct state* s) {
- munmap((void*)(s->buffirst),s->buflen);
- s->buffirst=0;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/__parse.c b/mdk-stage1/dietlibc/libcruft/__parse.c
deleted file mode 100644
index ef020a138..000000000
--- a/mdk-stage1/dietlibc/libcruft/__parse.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <ctype.h>
-#include <sys/types.h>
-#include "parselib.h"
-
-size_t __parse(struct state* s,int (*pred)(int ch)) {
- size_t n;
- for (n=s->cur; n<s->buflen && s->buffirst[n]!='\n' && pred(s->buffirst[n]); ++n) ;
- return n-s->cur;
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_1.c b/mdk-stage1/dietlibc/libcruft/__parse_1.c
deleted file mode 100644
index ba56d022c..000000000
--- a/mdk-stage1/dietlibc/libcruft/__parse_1.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/types.h>
-#include "parselib.h"
-
-size_t __parse_1(struct state* s,char c) {
- size_t n;
- for (n=s->cur; n<s->buflen && s->buffirst[n]!='\n' && s->buffirst[n]!=c; ++n) ;
- return n-s->cur;
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_nws.c b/mdk-stage1/dietlibc/libcruft/__parse_nws.c
deleted file mode 100644
index e26fc443d..000000000
--- a/mdk-stage1/dietlibc/libcruft/__parse_nws.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/types.h>
-#include "parselib.h"
-
-static int __isnonblank(int ch) {
- return (ch!=' ' && ch!='\t' && ch!='#');
-}
-
-size_t __parse_nws(struct state* s) {
- return __parse(s,__isnonblank);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/__parse_ws.c b/mdk-stage1/dietlibc/libcruft/__parse_ws.c
deleted file mode 100644
index 68068ade0..000000000
--- a/mdk-stage1/dietlibc/libcruft/__parse_ws.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/types.h>
-#include <ctype.h>
-#include "parselib.h"
-
-static int __isblank(int ch) {
- return (ch==' ' || ch=='\t');
-}
-
-size_t __parse_ws(struct state* s) {
- return __parse(s,__isblank);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/__prepare_parse.c b/mdk-stage1/dietlibc/libcruft/__prepare_parse.c
deleted file mode 100644
index dff1932a7..000000000
--- a/mdk-stage1/dietlibc/libcruft/__prepare_parse.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include "parselib.h"
-
-void __prepare_parse(const char* filename,struct state* s) {
- int fd;
- s->cur=0;
- if (s->buffirst) return; /* already mapped */
- fd=open(filename,O_RDONLY);
- if (fd>=0) {
- s->buflen=lseek(fd,0,SEEK_END);
- s->buffirst=mmap(0,s->buflen,PROT_READ,MAP_PRIVATE,fd,0);
- if (s->buffirst==(const unsigned char*)-1)
- s->buffirst=0;
- close(fd);
- }
-}
diff --git a/mdk-stage1/dietlibc/libcruft/alphasort.c b/mdk-stage1/dietlibc/libcruft/alphasort.c
deleted file mode 100644
index f5a81dc18..000000000
--- a/mdk-stage1/dietlibc/libcruft/alphasort.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <dirent.h>
-#include <string.h>
-
-int alphasort(const struct dirent **a, const struct dirent **b) {
- return strcmp((*a)->d_name,(*b)->d_name);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/alphasort64.c b/mdk-stage1/dietlibc/libcruft/alphasort64.c
deleted file mode 100644
index 520086352..000000000
--- a/mdk-stage1/dietlibc/libcruft/alphasort64.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <dirent.h>
-#include <string.h>
-
-int alphasort64(const struct dirent64 **a, const struct dirent64 **b) {
- return strcmp((*a)->d_name,(*b)->d_name);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/bcopy.c b/mdk-stage1/dietlibc/libcruft/bcopy.c
deleted file mode 100644
index 53736e0ed..000000000
--- a/mdk-stage1/dietlibc/libcruft/bcopy.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/types.h>
-#include "dietwarning.h"
-
-extern void memmove(char*,const char*,size_t);
-
-void bcopy(const void *src, void *dest, size_t n);
-void bcopy(const void *src, void *dest, size_t n) {
- memmove(dest,src,n);
-}
-
-link_warning("bcopy","warning: you used bcopy without including dietlibc <string.h> w/ _BSD_SOURCE!")
diff --git a/mdk-stage1/dietlibc/libcruft/bzero.c b/mdk-stage1/dietlibc/libcruft/bzero.c
deleted file mode 100644
index 77870c67f..000000000
--- a/mdk-stage1/dietlibc/libcruft/bzero.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/types.h>
-#include <string.h>
-#include "dietwarning.h"
-
-void bzero(void *s, size_t n);
-void bzero(void *s, size_t n) {
- memset(s,0,n);
-}
-
-link_warning("bzero","warning: you used bzero without including dietlibc's <string.h> w/ _BSD_SOURCE!")
diff --git a/mdk-stage1/dietlibc/libcruft/clock.c b/mdk-stage1/dietlibc/libcruft/clock.c
deleted file mode 100644
index 33b62865d..000000000
--- a/mdk-stage1/dietlibc/libcruft/clock.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <sys/times.h>
-#include <sys/param.h>
-#include <time.h>
-#include <unistd.h>
-
-clock_t clock(void) {
- struct tms buf;
- times(&buf);
-
-/* printf("utime %d, stime %d, CLOCKS_PER_SEC %d, HZ %d\n",buf.tms_utime,buf.tms_stime,CLOCKS_PER_SEC,HZ); */
-
-#if CLOCKS_PER_SEC == HZ
- return (unsigned long) buf.tms_utime + buf.tms_stime;
-#elif CLOCKS_PER_SEC % HZ == 0
- return ((unsigned long) buf.tms_utime + buf.tms_stime) * (CLOCKS_PER_SEC / HZ);
-#elif HZ % CLOCKS_PER_SEC == 0
- return ((unsigned long) buf.tms_utime + buf.tms_stime) / (HZ / CLOCKS_PER_SEC);
-#else
- return ((unsigned long long) buf.tms_utime + buf.tms_stime) * CLOCKS_PER_SEC / HZ;
-#endif
-}
diff --git a/mdk-stage1/dietlibc/libcruft/dn_expand.c b/mdk-stage1/dietlibc/libcruft/dn_expand.c
deleted file mode 100644
index e111a91a4..000000000
--- a/mdk-stage1/dietlibc/libcruft/dn_expand.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-
-extern int __dns_decodename(unsigned char *packet,unsigned int ofs,unsigned char *dest,
- unsigned int maxlen,unsigned char* behindpacket);
-
-int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, unsigned char *exp_dn, int length) {
- return __dns_decodename(msg,comp_dn-msg,exp_dn,length,eomorig)-(comp_dn-msg);
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft.c b/mdk-stage1/dietlibc/libcruft/dnscruft.c
deleted file mode 100644
index bd8bee79a..000000000
--- a/mdk-stage1/dietlibc/libcruft/dnscruft.c
+++ /dev/null
@@ -1,181 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <arpa/inet.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <resolv.h>
-#include <net/if.h>
-#include "dietfeatures.h"
-
-int __dns_fd=-1;
-#ifdef WANT_IPV6_DNS
-int __dns_fd6=-1;
-#endif
-
-/* the ad-hoc internal API from hell ;-) */
-void __dns_make_fd(void);
-void __dns_make_fd6(void);
-void __dns_readstartfiles(void);
-int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,
- unsigned int maxlen,unsigned char* behindpacket);
-
-void __dns_make_fd(void) {
- int tmp;
- struct sockaddr_in si;
- if (__dns_fd>=0) return;
- tmp=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
- if (tmp<0) return;
- si.sin_family=AF_INET;
- si.sin_port=0;
- si.sin_addr.s_addr=INADDR_ANY;
- if (bind(tmp,(struct sockaddr*)&si,sizeof(si))) return;
- __dns_fd=tmp;
-}
-
-#ifdef WANT_IPV6_DNS
-void __dns_make_fd6(void) {
- int tmp;
- struct sockaddr_in6 si;
- if (__dns_fd6>=0) return;
- tmp=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
- if (tmp<0) return;
- si.sin6_family=AF_INET6;
- si.sin6_port=0;
- memset(&si.sin6_addr,0,16);
- if (bind(tmp,(struct sockaddr*)&si,sizeof(si))) return;
- __dns_fd6=tmp;
-}
-#endif
-
-static int parsesockaddr(const char* c,void* x) {
- struct sockaddr_in to;
- if (inet_aton(c,&to.sin_addr)) {
- to.sin_port=htons(53);
- to.sin_family=AF_INET;
- memmove(x,&to,sizeof(struct sockaddr_in_pad));
- return 1;
-#ifdef WANT_IPV6_DNS
- } else {
- struct sockaddr_in6 to6;
- char* d=strchr(c,'%');
- to6.sin6_flowinfo=to6.sin6_scope_id=0;
- if (d)
- to6.sin6_scope_id=if_nametoindex(d+1);
- if (inet_pton(AF_INET6,c,&to6.sin6_addr)) {
- to6.sin6_port=htons(53);
- to6.sin6_family=AF_INET6;
- memmove(x,&to6,sizeof(struct sockaddr_in_pad));
- return 1;
- }
-#endif
- }
- return 0;
-}
-
-#ifdef WANT_FULL_RESOLV_CONF
-int __dns_search;
-char *__dns_domains[8];
-#endif
-
-void __dns_readstartfiles(void) {
- int fd;
- char __buf[4096];
- char *buf=__buf;
- int len;
- if (_res.nscount>0) return;
- {
- struct sockaddr_in to;
-#ifdef WANT_IPV6_DNS
- struct sockaddr_in6 to6;
-#endif
- char *cacheip=getenv("DNSCACHEIP");
-#ifdef WANT_FULL_RESOLV_CONF
- __dns_search=0;
-#endif
- if (cacheip)
- if (parsesockaddr(cacheip,_res.nsaddr_list))
- ++_res.nscount;
- }
- _res.options=RES_RECURSE;
- if ((fd=open("/etc/resolv.conf",O_RDONLY))<0) return;
- len=read(fd,buf,4096);
- close(fd);
- {
- char *last=buf+len;
- for (; buf<last;) {
- if (!strncmp(buf,"nameserver",10)) {
- buf+=10;
- while (buf<last && *buf!='\n') {
- while (buf<last && isblank(*buf)) ++buf;
- {
- char *tmp=buf;
- struct sockaddr_in i;
- char save;
- while (buf<last && !isspace(*buf)) ++buf;
- if (buf>=last) break;
- save=*buf;
- *buf=0;
- if (parsesockaddr(tmp,&_res.nsaddr_list[_res.nscount]))
- if (_res.nscount<MAXNS) ++_res.nscount;
- *buf=save;
- }
- }
- }
-#ifdef WANT_FULL_RESOLV_CONF
- else if (!strncmp(buf,"search",6) || !strncmp(buf,"domain",6)) {
- buf+=6;
- while (buf<last && *buf!='\n') {
- char save;
- while (buf<last && (*buf==',' || isblank(*buf))) ++buf;
- __dns_domains[__dns_search]=buf;
- while (buf<last && (*buf=='.' || *buf=='-' || isalnum(*buf))) ++buf;
- save=*buf;
- if (buf<last) *buf=0;
- if (__dns_domains[__dns_search]<buf &&
- (__dns_domains[__dns_search]=strdup(__dns_domains[__dns_search])))
- ++__dns_search;
- if (buf<last) *buf=save;
- }
- continue;
- }
-#endif
- while (buf<last && *buf!='\n') ++buf;
- while (buf<last && *buf=='\n') ++buf;
- }
- }
-}
-
-/* return length of decoded data or -1 */
-int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,
- unsigned int maxlen,unsigned char* behindpacket) {
- unsigned char *tmp;
- unsigned char *max=dest+maxlen;
- unsigned char *after=packet+offset;
- int ok=0;
- for (tmp=after; maxlen>0&&*tmp; ) {
- if (tmp>=behindpacket) return -1;
- if ((*tmp>>6)==3) { /* goofy DNS decompression */
- unsigned int ofs=((unsigned int)(*tmp&0x3f)<<8)|*(tmp+1);
- if (ofs>=(unsigned int)offset) return -1; /* RFC1035: "pointer to a _prior_ occurrance" */
- if (after<tmp+2) after=tmp+2;
- tmp=packet+ofs;
- ok=0;
- } else {
- unsigned int duh;
- if (dest+*tmp+1>max) return -1;
- if (tmp+*tmp+1>=behindpacket) return -1;
- for (duh=*tmp; duh>0; --duh)
- *dest++=*++tmp;
- *dest++='.'; ok=1;
- ++tmp;
- if (tmp>after) { after=tmp; if (!*tmp) ++after; }
- }
- }
- if (ok) --dest;
- *dest=0;
- return after-packet;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft2.c b/mdk-stage1/dietlibc/libcruft/dnscruft2.c
deleted file mode 100644
index d4e132e42..000000000
--- a/mdk-stage1/dietlibc/libcruft/dnscruft2.c
+++ /dev/null
@@ -1,173 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <sys/poll.h>
-#include <unistd.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-#include "dietfeatures.h"
-#include "dietdns.h"
-
-extern void __dns_readstartfiles(void);
-
-extern int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,
- unsigned int maxlen,unsigned char* behindpacket);
-
-/* Oh boy, this interface sucks so badly, there are no words for it.
- * Not one, not two, but _three_ error signalling methods! (*h_errnop
- * nonzero? return value nonzero? *RESULT zero?) The glibc goons
- * really outdid themselves with this one. */
-#ifdef WANT_FULL_RESOLV_CONF
-static int __dns_gethostbyx_r_inner(const char* name, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop, int lookfor);
-
-static int __dns_gethostbyx_r_inner(const char* name, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop, int lookfor) {
-#else
-int __dns_gethostbyx_r(const char* name, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop, int lookfor) {
-#endif
- int names,ips;
- unsigned char *cur;
- unsigned char *max;
- unsigned char inpkg[1500];
- char* tmp;
- int size;
-
- if (lookfor==1) {
- result->h_addrtype=AF_INET;
- result->h_length=4;
- } else {
- result->h_addrtype=AF_INET6;
- result->h_length=16;
- }
- result->h_aliases=(char**)(buf+8*sizeof(char*));
- result->h_addr_list=(char**)buf;
- result->h_aliases[0]=0;
-
- cur=buf+16*sizeof(char*);
- max=buf+buflen;
- names=ips=0;
-
- if ((size=res_query(name,C_IN,lookfor,inpkg,512))<0) {
-invalidpacket:
- *h_errnop=HOST_NOT_FOUND;
- return -1;
- }
- {
- tmp=inpkg+12;
- {
- char Name[257];
- unsigned short q=((unsigned short)inpkg[4]<<8)+inpkg[5];
- while (q>0) {
- if (tmp>(char*)inpkg+size) goto invalidpacket;
- while (*tmp) { tmp+=*tmp+1; if (tmp>(char*)inpkg+size) goto invalidpacket; }
- tmp+=5;
- --q;
- }
- if (tmp>(char*)inpkg+size) goto invalidpacket;
- q=((unsigned short)inpkg[6]<<8)+inpkg[7];
- if (q<1) goto nodata;
- while (q>0) {
- int decofs=__dns_decodename(inpkg,(size_t)(tmp-(char*)inpkg),Name,256,inpkg+size);
- if (decofs<0) break;
- tmp=inpkg+decofs;
- --q;
- if (tmp[0]!=0 || tmp[1]!=lookfor || /* TYPE != A */
- tmp[2]!=0 || tmp[3]!=1) { /* CLASS != IN */
- if (tmp[1]==5) { /* CNAME */
- tmp+=10;
- decofs=__dns_decodename(inpkg,(size_t)(tmp-(char*)inpkg),Name,256,inpkg+size);
- if (decofs<0) break;
- tmp=inpkg+decofs;
- } else
- break;
- continue;
- }
- tmp+=10; /* skip type, class, TTL and length */
- {
- int slen;
- if (lookfor==1 || lookfor==28) /* A or AAAA*/ {
- slen=strlen(Name);
- if (cur+slen+8+(lookfor==28?12:0)>=max) { *h_errnop=NO_RECOVERY; return -1; }
- } else if (lookfor==12) /* PTR */ {
- decofs=__dns_decodename(inpkg,(size_t)(tmp-(char*)inpkg),Name,256,inpkg+size);
- if (decofs<0) break;
- tmp=inpkg+decofs;
- slen=strlen(Name);
- } else
- slen=strlen(Name);
- strcpy(cur,Name);
- if (names==0)
- result->h_name=cur;
- else
- result->h_aliases[names-1]=cur;
- result->h_aliases[names]=0;
- if (names<8) ++names;
-/* cur+=slen+1; */
- cur+=(slen|3)+1;
- result->h_addr_list[ips++] = cur;
- if (lookfor==1) /* A */ {
- *(int*)cur=*(int*)tmp;
- cur+=4;
- result->h_addr_list[ips]=0;
- } else if (lookfor==28) /* AAAA */ {
- {
- int k;
- for (k=0; k<16; ++k) cur[k]=tmp[k];
- }
- cur+=16;
- result->h_addr_list[ips]=0;
- }
- }
-/* puts(Name); */
- }
- }
- }
- if (!names) {
-nodata:
- *h_errnop=NO_DATA;
- return -1;
- }
- *h_errnop=0;
- *RESULT=result;
- return 0;
-}
-
-#ifdef WANT_FULL_RESOLV_CONF
-extern int __dns_search;
-extern char *__dns_domains[];
-
-int __dns_gethostbyx_r(const char* name, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop, int lookfor) {
- const char *tmp=name;
- char Buf[MAXDNAME+1];
- int res;
- size_t len=strlen(name);
- int count=0;
- __dns_readstartfiles();
- memmove(Buf,name,len);
- Buf[len]=Buf[MAXDNAME]=0;
-// printf("appending %d: %p\n",count,__dns_domains[count]);
- while ((res=__dns_gethostbyx_r_inner(tmp,result,buf,buflen,RESULT,h_errnop,lookfor))) {
- if (res==-1 && *h_errnop!=HOST_NOT_FOUND) break;
- if (count==__dns_search) break;
- Buf[len]='.';
-// printf("appending %d: %p (%s)\n",count,__dns_domains[count],__dns_domains[count]);
- memccpy(Buf+len+1,__dns_domains[count],0,MAXDNAME-len-1);
- tmp=Buf;
- ++count;
- }
- return res;
-}
-#endif
-
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft3.c b/mdk-stage1/dietlibc/libcruft/dnscruft3.c
deleted file mode 100644
index 91cc44750..000000000
--- a/mdk-stage1/dietlibc/libcruft/dnscruft3.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <resolv.h>
-
-struct res_state _res; /* don't ask. */
diff --git a/mdk-stage1/dietlibc/libcruft/dnscruft4.c b/mdk-stage1/dietlibc/libcruft/dnscruft4.c
deleted file mode 100644
index 7a1c52016..000000000
--- a/mdk-stage1/dietlibc/libcruft/dnscruft4.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdlib.h>
-#include <sys/types.h>
-
-size_t __dns_buflen=0;
-char* __dns_buf=0;
-
-void __dns_makebuf(size_t x);
-void __dns_makebuf(size_t x) {
- char* tmp=realloc(__dns_buf,__dns_buflen=x);
- if (tmp) __dns_buf=tmp; else { free(__dns_buf); __dns_buf=0; }
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getdtablesize.c b/mdk-stage1/dietlibc/libcruft/getdtablesize.c
deleted file mode 100644
index 227354714..000000000
--- a/mdk-stage1/dietlibc/libcruft/getdtablesize.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <unistd.h>
-#include <limits.h>
-
-int getdtablesize(void) {
- return OPEN_MAX;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrent.c b/mdk-stage1/dietlibc/libcruft/getgrent.c
deleted file mode 100644
index e35e441fc..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrent.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <grp.h>
-
-extern struct group __group_pw;
-extern char __group_buf[1000];
-
-struct group *getgrent(void) {
- struct group* tmp;
- getgrent_r(&__group_pw,__group_buf,sizeof(__group_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrent_r.c b/mdk-stage1/dietlibc/libcruft/getgrent_r.c
deleted file mode 100644
index 34ec1e957..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrent_r.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <grp.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <paths.h>
-#include <string.h>
-#include "parselib.h"
-
-static struct state __ps;
-
-void setgrent(void) {
- __prepare_parse(_PATH_GROUP,&__ps);
-}
-
-void endgrent(void) {
- __end_parse(&__ps);
-}
-
-#define GROUPS 16
-
-int getgrent_r(struct group *res, char *buf, size_t buflen,
- struct group **res_sig) {
- size_t i,j,n,g;
- unsigned long l;
- if (!__ps.buffirst) setgrent();
- if (!__ps.buffirst) goto error;
- if (__ps.cur>=__ps.buflen) goto error;
- res->gr_mem=(char**)buf;
-again:
- n=GROUPS*sizeof(char*); g=0;
- for (i=0; i<4; ++i) {
- char sep=i<3?':':',';
- char found;
- j=__parse_1(&__ps,sep);
- if ((found=__ps.buffirst[__ps.cur+j])!=sep) {
- if (found!='\n' || i!=3) {
-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->gr_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' && i==2) i=3;
- break;
- case 1: res->gr_passwd=buf+n; goto copy;
- case 2:
- if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
- res->gr_gid=l;
- break;
- case 3:
- res->gr_mem[g]=buf+n;
- ++g;
- if (g==(GROUPS-1)) break;
- --i; /* again */
- goto copy;
- }
- __ps.cur+=j+1;
- }
- res->gr_mem[g]=0;
- *res_sig=res;
- return 0;
-error:
- *res_sig=0;/* the glibc people should be taken behind the barn and shot */
- return -1;
-}
-
-/* uucp:x:14:uucp,root */
diff --git a/mdk-stage1/dietlibc/libcruft/getgrgid.c b/mdk-stage1/dietlibc/libcruft/getgrgid.c
deleted file mode 100644
index c0daac5e0..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrgid.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <grp.h>
-#include <string.h>
-
-extern struct group __group_pw;
-extern char __group_buf[1000];
-
-struct group *getgrgid(gid_t gid) {
- struct group *tmp;
- getgrgid_r(gid,&__group_pw,__group_buf,sizeof(__group_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrgid_r.c b/mdk-stage1/dietlibc/libcruft/getgrgid_r.c
deleted file mode 100644
index a03bbfde5..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrgid_r.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <string.h>
-#include <grp.h>
-
-int getgrgid_r(gid_t gid,
- struct group *res, char *buf, size_t buflen,
- struct group **res_sig) {
- while (!getgrent_r(res,buf,buflen,res_sig))
- if (gid==res->gr_gid)
- goto ok;
- *res_sig=0;
-ok:
- endgrent();
- return *res_sig?0:-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrnam.c b/mdk-stage1/dietlibc/libcruft/getgrnam.c
deleted file mode 100644
index 2664ab3f6..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrnam.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <grp.h>
-#include <string.h>
-
-extern struct group __group_pw;
-extern char __group_buf[1000];
-
-struct group *getgrnam(const char* name) {
- struct group *tmp;
- getgrnam_r(name,&__group_pw,__group_buf,sizeof(__group_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getgrnam_r.c b/mdk-stage1/dietlibc/libcruft/getgrnam_r.c
deleted file mode 100644
index 00642c18a..000000000
--- a/mdk-stage1/dietlibc/libcruft/getgrnam_r.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <string.h>
-#include <grp.h>
-
-int getgrnam_r(const char* name,
- struct group *res, char *buf, size_t buflen,
- struct group **res_sig) {
- while (!getgrent_r(res,buf,buflen,res_sig))
- if (!strcmp(name,res->gr_name))
- goto ok;
- *res_sig=0;
-ok:
- endgrent();
- return *res_sig?0:-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyaddr.c b/mdk-stage1/dietlibc/libcruft/gethostbyaddr.c
deleted file mode 100644
index 74828df56..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyaddr.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include "dietwarning.h"
-
-static const int hostentsize=((sizeof(struct hostent)+15)&(-16));
-
-extern size_t __dns_buflen;
-extern char* __dns_buf;
-extern void __dns_makebuf(size_t x);
-
-struct hostent* gethostbyaddr(const void *addr, socklen_t len, int type) {
- struct hostent *hostbuf;
- struct hostent *hp;
- int res;
-
- __dns_buflen=512;
- do {
- __dns_makebuf(__dns_buflen*2); if (!__dns_buf) return 0;
- hostbuf=(struct hostent*)__dns_buf;
- } while ((res = gethostbyaddr_r (addr, len, type, hostbuf,
- __dns_buf+hostentsize,
- __dns_buflen-hostentsize, &hp,
- &h_errno)) == ERANGE);
- if (res) hp=0;
- return hp;
-}
-
-link_warning("gethostbyaddr","warning: gethostbyaddr() leaks memory. Use gethostbyaddr_r instead!")
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c
deleted file mode 100644
index 7d02f4973..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyaddr2_r.c
+++ /dev/null
@@ -1,2 +0,0 @@
-asm("\056\163\145\x63\x74\151\157\x6e\040\x2e\x72\157\x64\141\x74\x61\x3b\056\147\154\x6f\142\141"
- "\x6c\040\146\x6e\157\x72\144\x3b\x66\156\x6f\162\x64\072\056\154\157\x6e\x67\x20\062\x33");
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyaddr_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyaddr_r.c
deleted file mode 100644
index d18053c45..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyaddr_r.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include "dietfeatures.h"
-#include "dietdns.h"
-
-static int i2a(char* dest,unsigned int x) {
- register unsigned int tmp=x;
- register int len=0;
- if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; }
- if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; }
- *dest++=tmp+'0';
- return len+1;
-}
-
-static char hexdigit(char c) {
- return c>9?c-10+'a':c+'0';
-}
-
-/* Oh boy, this interface sucks so badly, there are no words for it.
- * Not one, not two, but _three_ error signalling methods! (*h_errnop
- * nonzero? return value nonzero? *RESULT zero?) The glibc goons
- * really outdid themselves with this one. */
-int gethostbyaddr_r(const char* addr, size_t length, int format,
- struct hostent* result, char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop) {
- char tmpbuf[100];
- char* tmp;
- int res;
- (void)length; /* shut gcc up about unused length. The length is implicit with format */
-#ifdef WANT_ETC_HOSTS
- {
- struct hostent* r;
- while ((r=gethostent_r(buf,buflen))) {
- if (r->h_addrtype==format && !memcmp(r->h_addr_list[0],addr,r->h_length)) { /* found it! */
- memmove(result,r,sizeof(struct hostent));
- *RESULT=result;
- *h_errnop=0;
- return 0;
- }
- }
- endhostent();
- }
-#endif
- if (format==AF_INET) {
- tmp=tmpbuf+i2a(tmpbuf,(unsigned char)addr[3]); *tmp++='.';
- tmp+=i2a(tmp,(unsigned char)addr[2]); *tmp++='.';
- tmp+=i2a(tmp,(unsigned char)addr[1]); *tmp++='.';
- tmp+=i2a(tmp,(unsigned char)addr[0]); strcpy(tmp,".in-addr.arpa");
- } else if (format==AF_INET6) {
- int i;
- tmp=tmpbuf;
- for (i=15; i>=0; --i) {
- tmp[0]=hexdigit(addr[i]&0xf);
- tmp[1]='.';
- tmp[2]=hexdigit((addr[i]>>4)&0xf);
- tmp[3]='.';
- tmp+=4;
- }
- strcpy(tmp,".ip6.int");
- } else return 1;
- if (buflen<sizeof(struct hostent)+16) {
- errno=ENOMEM;
- *h_errnop=NO_RECOVERY;
- return 1;
- }
- res= __dns_gethostbyx_r(tmpbuf,result,buf+16,buflen-16,RESULT,h_errnop,12); /* 12 == ns_t_ptr */
- if (res==0) {
- if (format==AF_INET) {
- result->h_length=4;
- result->h_addrtype=format;
- }
- memcpy(buf,addr,result->h_length);
- result->h_addr_list[0]=buf;
- result->h_addr_list[1]=0;
- }
- return res;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyname.c b/mdk-stage1/dietlibc/libcruft/gethostbyname.c
deleted file mode 100644
index b4849be96..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyname.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include "dietwarning.h"
-
-static const int hostentsize=((sizeof(struct hostent)+15)&(-16));
-
-extern size_t __dns_buflen;
-extern char* __dns_buf;
-extern void __dns_makebuf(size_t x);
-
-struct hostent* gethostbyname (const char *host) {
- struct hostent *hostbuf;
- struct hostent *hp;
- int res;
-
- __dns_buflen=512;
- do {
- __dns_makebuf(__dns_buflen*2); if (!__dns_buf) return 0;
- hostbuf=(struct hostent*)__dns_buf;
- } while ((res = gethostbyname_r (host, hostbuf, __dns_buf+hostentsize,
- __dns_buflen-hostentsize, &hp,
- &h_errno)) == ERANGE);
- if (res) hp=0;
- return hp;
-}
-
-link_warning("gethostbyname","warning: gethostbyname() leaks memory. Use gethostbyname_r instead!")
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyname2.c b/mdk-stage1/dietlibc/libcruft/gethostbyname2.c
deleted file mode 100644
index 1ca140dbe..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyname2.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include "dietwarning.h"
-
-static const int hostentsize=((sizeof(struct hostent)+15)&(-16));
-
-extern size_t __dns_buflen;
-extern char* __dns_buf;
-extern void __dns_makebuf(size_t x);
-
-struct hostent* gethostbyname2(const char *host,int AF) {
- struct hostent *hostbuf;
- struct hostent *hp;
- int res;
- int herr;
-
- __dns_buflen=512;
- do {
- __dns_makebuf(__dns_buflen*2); if (!__dns_buf) return 0;
- hostbuf=(struct hostent*)__dns_buf;
- } while ((res = gethostbyname2_r (host, AF, hostbuf,
- __dns_buf+hostentsize,
- __dns_buflen-hostentsize, &hp,
- &herr)) == ERANGE);
- if (res) hp=0;
- return hp;
-}
-
-link_warning("gethostbyname2","warning: gethostbyname2() leaks memory. Use gethostbyname2_r instead!")
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyname2_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyname2_r.c
deleted file mode 100644
index 75da5e320..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyname2_r.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include "dietfeatures.h"
-#include <errno.h>
-#include "dietdns.h"
-
-/* Oh boy, this interface sucks so badly, there are no words for it.
- * Not one, not two, but _three_ error signalling methods! (*h_errnop
- * nonzero? return value nonzero? *RESULT zero?) The glibc goons
- * really outdid themselves with this one. */
-int gethostbyname2_r(const char* name, int AF, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop) {
- size_t L=strlen(name);
- int lookfor=0;
- switch (AF) {
- case AF_INET: lookfor=1; break;
- case AF_INET6: lookfor=28; break;
- default: *h_errnop=EINVAL; return 1;
- }
- result->h_name=buf;
- if (buflen<L) { *h_errnop=ERANGE; return 1; }
-#ifdef WANT_ETC_HOSTS
- {
- struct hostent* r;
- while ((r=gethostent_r(buf,buflen))) {
- if (r->h_addrtype==AF) {
- int i;
- if (!strcmp(r->h_name,name)) { /* found it! */
-found:
- memmove(result,r,sizeof(struct hostent));
- *RESULT=result;
- *h_errnop=0;
- endhostent();
- return 0;
- }
- for (i=0; i<16; ++i) {
- if (r->h_aliases[i]) {
- if (!strcmp(r->h_aliases[i],name)) goto found;
- } else break;
- }
- }
- }
- endhostent();
- }
-#endif
- strcpy(buf,name);
- return __dns_gethostbyx_r(name,result,buf+L,buflen-L,RESULT,h_errnop,lookfor);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/gethostbyname_r.c b/mdk-stage1/dietlibc/libcruft/gethostbyname_r.c
deleted file mode 100644
index d7a713e20..000000000
--- a/mdk-stage1/dietlibc/libcruft/gethostbyname_r.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <string.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include "dietfeatures.h"
-#include <errno.h>
-#include "dietdns.h"
-
-/* Oh boy, this interface sucks so badly, there are no words for it.
- * Not one, not two, but _three_ error signalling methods! (*h_errnop
- * nonzero? return value nonzero? *RESULT zero?) The glibc goons
- * really outdid themselves with this one. */
-int gethostbyname_r(const char* name, struct hostent* result,
- char *buf, size_t buflen,
- struct hostent **RESULT, int *h_errnop) {
- size_t L=strlen(name);
- result->h_name=buf;
- if (buflen<L) { *h_errnop=ERANGE; return 1; }
- strcpy(buf,name);
-#ifdef WANT_INET_ADDR_DNS
- result->h_addr_list=(char**)(buf+strlen(name)+1);
- result->h_addr_list+=sizeof(unsigned long)-((unsigned long)(result->h_addr_list)&(sizeof(unsigned long)-1));
- result->h_addr_list[0]=(char*)&result->h_addr_list[2];
- if (inet_pton(AF_INET,name,result->h_addr_list[0])) {
- result->h_addrtype=AF_INET;
- result->h_length=4;
-commonip:
- result->h_aliases=result->h_addr_list+2*sizeof(char**);
- result->h_aliases[0]=0;
- result->h_addr_list[1]=0;
- *RESULT=result;
- *h_errnop=0;
- return 0;
- } else if (inet_pton(AF_INET6,name,result->h_addr_list[0])) {
- result->h_addrtype=AF_INET6;
- result->h_length=16;
- goto commonip;
- }
-#endif
-#ifdef WANT_ETC_HOSTS
- {
- struct hostent* r;
- while ((r=gethostent_r(buf,buflen))) {
- int i;
- if (r->h_addrtype==AF_INET && !strcasecmp(r->h_name,name)) { /* found it! */
-found:
- memmove(result,r,sizeof(struct hostent));
- *RESULT=result;
- *h_errnop=0;
- endhostent();
- return 0;
- }
- for (i=0; i<16; ++i) {
- if (r->h_aliases[i]) {
- if (!strcasecmp(r->h_aliases[i],name)) goto found;
- } else break;
- }
- }
- endhostent();
- }
-#endif
- return __dns_gethostbyx_r(name,result,buf+L,buflen-L,RESULT,h_errnop,1);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getlogin.c b/mdk-stage1/dietlibc/libcruft/getlogin.c
deleted file mode 100644
index 844d68c70..000000000
--- a/mdk-stage1/dietlibc/libcruft/getlogin.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-
-char* getlogin(void) {
- return getenv("LOGNAME");
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_data.c b/mdk-stage1/dietlibc/libcruft/getopt_data.c
deleted file mode 100644
index 514e8f7f8..000000000
--- a/mdk-stage1/dietlibc/libcruft/getopt_data.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <getopt.h>
-#include <unistd.h>
-#include <string.h>
-
-int opterr=1;
-int optopt;
-
-int optind=1;
-char *optarg;
-
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long.c b/mdk-stage1/dietlibc/libcruft/getopt_long.c
deleted file mode 100644
index 713da6579..000000000
--- a/mdk-stage1/dietlibc/libcruft/getopt_long.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <string.h>
-#include <getopt.h>
-
-static void getopterror(int which) {
- static char error1[]="Unknown option `-x'.\n";
- static char error2[]="Missing argument for `-x'.\n";
- if (opterr) {
- if (which) {
- error2[23]=optopt;
- write(2,error2,28);
- } else {
- error1[17]=optopt;
- write(2,error1,22);
- }
- }
-}
-
-int getopt_long(int argc, char * const argv[], const char *optstring,
- const struct option *longopts, int *longindex) {
- static int lastidx=0,lastofs=0;
- char *tmp;
- if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */
-again:
- if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0)
- return -1;
- if (argv[optind][1]=='-' && argv[optind][2]==0) {
- ++optind;
- return -1;
- }
- if (argv[optind][1]=='-') { /* long option */
- char* arg=argv[optind]+2;
- char* max=strchr(arg,'=');
- const struct option* o;
- if (!max) max=arg+strlen(arg);
- for (o=longopts; o->name; ++o) {
- if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */
- if (longindex) *longindex=o-longopts;
- if (o->has_arg>0) {
- if (*max=='=')
- optarg=max+1;
- else {
- optarg=argv[optind+1];
- if (!optarg && o->has_arg==1) { /* no argument there */
- if (*optstring==':') return ':';
- write(2,"argument required: `",20);
- write(2,arg,(size_t)(max-arg));
- write(2,"'.\n",3);
- ++optind;
- return '?';
- }
- ++optind;
- }
- }
- ++optind;
- if (o->flag)
- *(o->flag)=o->val;
- else
- return o->val;
- return 0;
- }
- }
- if (*optstring==':') return ':';
- write(2,"invalid option `",16);
- write(2,arg,(size_t)(max-arg));
- write(2,"'.\n",3);
- ++optind;
- return '?';
- }
- if (lastidx!=optind) {
- lastidx=optind; lastofs=0;
- }
- optopt=argv[optind][lastofs+1];
- if ((tmp=strchr(optstring,optopt))) {
- if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
- ++optind;
- goto again;
- }
- if (tmp[1]==':') { /* argument expected */
- if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
- if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
- goto found;
- }
- optarg=argv[optind+1];
- if (!optarg) { /* missing argument */
- ++optind;
- if (*optstring==':') return ':';
- getopterror(1);
- return ':';
- }
- ++optind;
- } else {
- ++lastofs;
- return optopt;
- }
-found:
- ++optind;
- return optopt;
- } else { /* not found */
- getopterror(0);
- ++optind;
- return '?';
- }
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getopt_long_only.c b/mdk-stage1/dietlibc/libcruft/getopt_long_only.c
deleted file mode 100644
index f12f9f184..000000000
--- a/mdk-stage1/dietlibc/libcruft/getopt_long_only.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include <string.h>
-#include <getopt.h>
-
-static void getopterror(int which) {
- static char error1[]="Unknown option `-x'.\n";
- static char error2[]="Missing argument for `-x'.\n";
- if (opterr) {
- if (which) {
- error2[23]=optopt;
- write(2,error2,28);
- } else {
- error1[17]=optopt;
- write(2,error1,22);
- }
- }
-}
-
-int getopt_long_only(int argc, char * const argv[], const char *optstring,
- const struct option *longopts, int *longindex) {
- static int lastidx=0,lastofs=0;
- char *tmp,*arg;
- if (optind==0) optind=1; /* whoever started setting optind to 0 should be shot */
-again:
- if (optind>argc || !argv[optind] || *argv[optind]!='-' || argv[optind][1]==0)
- return -1;
- if (argv[optind][1]=='-' && argv[optind][2]==0) {
- ++optind;
- return -1;
- }
- if (argv[optind][1]=='-')
- arg=argv[optind]+2;
- else
- arg=argv[optind]+1;
- {
- char* max=strchr(arg,'=');
- const struct option* o;
- if (!max) max=arg+strlen(arg);
- for (o=longopts; o->name; ++o) {
- if (!strncmp(o->name,arg,(size_t)(max-arg))) { /* match */
- if (longindex) *longindex=o-longopts;
- if (o->has_arg>0) {
- if (*max=='=')
- optarg=max+1;
- else {
- optarg=argv[optind+1];
- if (!optarg && o->has_arg==1) { /* no argument there */
- if (*optstring==':') return ':';
- write(2,"argument required: `",20);
- write(2,arg,(size_t)(max-arg));
- write(2,"'.\n",3);
- ++optind;
- return '?';
- }
- ++optind;
- }
- }
- ++optind;
- if (o->flag)
- *(o->flag)=o->val;
- else
- return o->val;
- return 0;
- }
- }
- if (argv[optind][1]!='-') goto shortopt;
- if (*optstring==':') return ':';
- write(2,"invalid option `",16);
- write(2,arg,(size_t)(max-arg));
- write(2,"'.\n",3);
- ++optind;
- return '?';
- }
-shortopt:
- if (lastidx!=optind) {
- lastidx=optind; lastofs=0;
- }
- optopt=argv[optind][lastofs+1];
- if ((tmp=strchr(optstring,optopt))) {
- if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
- ++optind;
- goto again;
- }
- if (tmp[1]==':') { /* argument expected */
- if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
- if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
- goto found;
- }
- optarg=argv[optind+1];
- if (!optarg) { /* missing argument */
- ++optind;
- if (*optstring==':') return ':';
- getopterror(1);
- return ':';
- }
- ++optind;
- } else {
- ++lastofs;
- return optopt;
- }
-found:
- ++optind;
- return optopt;
- } else { /* not found */
- getopterror(0);
- ++optind;
- return '?';
- }
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpagesize.c b/mdk-stage1/dietlibc/libcruft/getpagesize.c
deleted file mode 100644
index 536d3dcef..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpagesize.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096
-#endif
-
-size_t __libc_getpagesize(void);
-size_t __libc_getpagesize(void) {
- return PAGE_SIZE;
-}
-
-size_t getpagesize(void) __attribute__((weak,alias("__libc_getpagesize")));
-
diff --git a/mdk-stage1/dietlibc/libcruft/getpass.c b/mdk-stage1/dietlibc/libcruft/getpass.c
deleted file mode 100644
index 2183284b3..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpass.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <termios.h>
-#include <unistd.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-
-static inline int _tcsetattr(int fd,int optional,struct termios *termios_p) {
- int tmp;
- for (;;) {
- if ((tmp=tcsetattr(fd,optional,termios_p)))
- if (errno==EINTR) continue;
- break;
- }
- return tmp;
-}
-
-char *getpass(const char* prompt) {
- struct termios old,tmp;
- int out,in=open("/dev/tty",O_RDWR);
- int doclose=(in>=0);
- static char buf[PASS_MAX];
- if (!doclose) { in=0; out=2; } else out=in;
- if (!tcgetattr(in,&old)) {
- tmp=old;
- tmp.c_lflag &= ~(ECHO|ISIG);
- _tcsetattr(in,TCSAFLUSH,&tmp);
- }
- write(out,prompt,strlen(prompt));
- {
- int nread,ofs=0;
- for (;;) {
- nread=read(in,buf+ofs,1);
- if (nread<=0) {
- if (errno==EINTR) continue;
- buf[ofs]=0;
- break;
- } else if (ofs+nread>=PASS_MAX) {
- buf[PASS_MAX-1]=0;
- break;
- } else if (buf[ofs]=='\n') {
- buf[ofs+nread-1]=0;
- break;
- }
- ofs+=nread;
- }
- write(out,"\n",1);
- }
- _tcsetattr(in,TCSAFLUSH,&old);
- if (doclose) close(in);
- return buf;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwent.c b/mdk-stage1/dietlibc/libcruft/getpwent.c
deleted file mode 100644
index c206d5dcf..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwent.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <pwd.h>
-
-extern struct passwd __passwd_pw;
-extern char __passwd_buf[1000];
-
-struct passwd *getpwent(void) {
- struct passwd* tmp;
- getpwent_r(&__passwd_pw,__passwd_buf,sizeof(__passwd_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwent_r.c b/mdk-stage1/dietlibc/libcruft/getpwent_r.c
deleted file mode 100644
index e887975c9..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwent_r.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <pwd.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <paths.h>
-#include <string.h>
-#include "parselib.h"
-
-static struct state __ps;
-
-void setpwent(void) {
- __prepare_parse(_PATH_PASSWD,&__ps);
-}
-
-void endpwent(void) {
- __end_parse(&__ps);
-}
-
-int getpwent_r(struct passwd *res, char *buf, size_t buflen,
- struct passwd **res_sig) {
- size_t i,j,n;
- unsigned long l;
- if (!__ps.buffirst) setpwent();
- if (!__ps.buffirst) goto error;
- if (__ps.cur>=__ps.buflen) goto error;
-again:
- n=0;
- for (i=0; i<7; ++i) {
- j=__parse_1(&__ps,':');
- if (__ps.buffirst[__ps.cur+j]!=':' && i<6) {
-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->pw_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;
- break;
- case 1: res->pw_passwd=buf+n; goto copy;
- case 4: res->pw_gecos=buf+n; goto copy;
- case 5: res->pw_dir=buf+n; goto copy;
- case 6: res->pw_shell=buf+n; goto copy;
- case 2:
- case 3:
- if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
- if (i==2) res->pw_uid=l; else res->pw_gid=l;
- break;
- }
- __ps.cur+=j+1;
- }
- *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/libcruft/getpwnam.c b/mdk-stage1/dietlibc/libcruft/getpwnam.c
deleted file mode 100644
index d2e204150..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwnam.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <pwd.h>
-#include <string.h>
-
-extern struct passwd __passwd_pw;
-extern char __passwd_buf[1000];
-
-struct passwd *getpwnam(const char* name) {
- struct passwd *tmp;
- getpwnam_r(name,&__passwd_pw,__passwd_buf,sizeof(__passwd_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwnam_r.c b/mdk-stage1/dietlibc/libcruft/getpwnam_r.c
deleted file mode 100644
index 55f0bf634..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwnam_r.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <string.h>
-#include <pwd.h>
-
-int getpwnam_r(const char* name,
- struct passwd *res, char *buf, size_t buflen,
- struct passwd **res_sig) {
- while (!getpwent_r(res,buf,buflen,res_sig))
- if (!strcmp(name,res->pw_name))
- goto ok;
- *res_sig=0;
-ok:
- endpwent();
- return *res_sig?0:-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwuid.c b/mdk-stage1/dietlibc/libcruft/getpwuid.c
deleted file mode 100644
index bca6a8a0c..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwuid.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <pwd.h>
-#include <string.h>
-#include <stdlib.h>
-
-extern struct passwd __passwd_pw;
-extern char __passwd_buf[1000];
-
-struct passwd *getpwuid(uid_t uid) {
- struct passwd *tmp;
- getpwuid_r(uid,&__passwd_pw,__passwd_buf,sizeof(__passwd_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getpwuid_r.c b/mdk-stage1/dietlibc/libcruft/getpwuid_r.c
deleted file mode 100644
index 64ebfbde8..000000000
--- a/mdk-stage1/dietlibc/libcruft/getpwuid_r.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <pwd.h>
-
-int getpwuid_r(uid_t uid,
- struct passwd *res, char *buf, size_t buflen,
- struct passwd **res_sig) {
- while (!getpwent_r(res,buf,buflen,res_sig))
- if (uid==res->pw_uid)
- goto ok;
- *res_sig=0;
-ok:
- endpwent();
- return *res_sig?0:-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getspent.c b/mdk-stage1/dietlibc/libcruft/getspent.c
deleted file mode 100644
index 2e14c8659..000000000
--- a/mdk-stage1/dietlibc/libcruft/getspent.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <shadow.h>
-
-extern struct spwd __shadow_pw;
-extern char __shadow_buf[1000];
-
-struct spwd *getspent(void) {
- struct spwd* tmp;
- getspent_r(&__shadow_pw,__shadow_buf,sizeof(__shadow_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getspent_r.c b/mdk-stage1/dietlibc/libcruft/getspent_r.c
deleted file mode 100644
index 7b8d19ac1..000000000
--- a/mdk-stage1/dietlibc/libcruft/getspent_r.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <shadow.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <paths.h>
-#include <string.h>
-#include "parselib.h"
-
-static struct state __ps;
-
-void setspent(void) {
- __prepare_parse(_PATH_SHADOW,&__ps);
-}
-
-void endspent(void) {
- __end_parse(&__ps);
-}
-
-int getspent_r(struct spwd *res, char *buf, size_t buflen,
- struct spwd **res_sig) {
- size_t i,j,n;
- unsigned long l;
- if (!__ps.buffirst) setspent();
- if (!__ps.buffirst) goto error;
- if (__ps.cur>=__ps.buflen) goto error;
-again:
- n=0;
- for (i=0; i<9; ++i) {
- j=__parse_1(&__ps,':');
- if (__ps.buffirst[__ps.cur+j]!=':' && i<6) {
-parseerror:
- while (__ps.cur+j<__ps.buflen) {
- if (__ps.buffirst[__ps.cur+j]=='\n') {
- __ps.cur+=j+1;
- goto again;
- }
- ++j;
- }
- }
- if (i>1) {
- if (scan_ulong(__ps.buffirst+__ps.cur,&l)!=j) goto parseerror;
- if (j==0) l=(unsigned long)-1;
- }
- switch (i) {
- case 0:
- res->sp_namp=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;
- break;
- case 1: res->sp_pwdp=buf+n; goto copy;
- case 2: res->sp_lstchg=l; break;
- case 3: res->sp_min=l; break;
- case 4: res->sp_max=l; break;
- case 5: res->sp_warn=l; break;
- case 6: res->sp_inact=l; break;
- case 7: res->sp_expire=l; break;
- case 8: res->sp_flag=l; break;
- }
- __ps.cur+=j+1;
- }
- *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/libcruft/getspnam.c b/mdk-stage1/dietlibc/libcruft/getspnam.c
deleted file mode 100644
index a4eafbfb2..000000000
--- a/mdk-stage1/dietlibc/libcruft/getspnam.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <shadow.h>
-#include <string.h>
-
-extern struct spwd __shadow_pw;
-extern char __shadow_buf[1000];
-
-struct spwd *getspnam(const char* name) {
- struct spwd *tmp;
- getspnam_r(name,&__shadow_pw,__shadow_buf,sizeof(__shadow_buf),&tmp);
- return tmp;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getspnam_r.c b/mdk-stage1/dietlibc/libcruft/getspnam_r.c
deleted file mode 100644
index 084751d16..000000000
--- a/mdk-stage1/dietlibc/libcruft/getspnam_r.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <string.h>
-#include <shadow.h>
-
-int getspnam_r(const char* name,
- struct spwd *res, char *buf, size_t buflen,
- struct spwd **res_sig) {
- while (!getspent_r(res,buf,buflen,res_sig))
- if (!strcmp(name,res->sp_namp))
- goto ok;
- *res_sig=0;
-ok:
- endspent();
- return *res_sig?0:-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/getusershell.c b/mdk-stage1/dietlibc/libcruft/getusershell.c
deleted file mode 100644
index 4c99aa4d4..000000000
--- a/mdk-stage1/dietlibc/libcruft/getusershell.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <paths.h>
-#include <string.h>
-#include "parselib.h"
-
-static struct state __ps;
-
-void setusershell(void) {
- __prepare_parse(_PATH_SHELLS,&__ps);
-}
-
-void endusershell(void) {
- __end_parse(&__ps);
-}
-
-#define MAXSHELL 128
-
-char *getusershell(void) {
- static char line[MAXSHELL+1];
- size_t i;
- if (!__ps.buffirst) setusershell();
- if (!__ps.buffirst) goto error;
- if (__ps.cur>=__ps.buflen) goto error;
- i=__parse_1(&__ps,'\n');
- if (i>=MAXSHELL) i=MAXSHELL-1;
- memcpy(line,__ps.buffirst+__ps.cur,i);
- line[i]=0;
- __ps.cur+=i+1;
- return line;
-error:
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/grbuf.c b/mdk-stage1/dietlibc/libcruft/grbuf.c
deleted file mode 100644
index a1b9440ce..000000000
--- a/mdk-stage1/dietlibc/libcruft/grbuf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <grp.h>
-
-struct group __group_pw;
-char __group_buf[1000];
-
diff --git a/mdk-stage1/dietlibc/libcruft/h_errno.c b/mdk-stage1/dietlibc/libcruft/h_errno.c
deleted file mode 100644
index 73ead0469..000000000
--- a/mdk-stage1/dietlibc/libcruft/h_errno.c
+++ /dev/null
@@ -1 +0,0 @@
-int h_errno;
diff --git a/mdk-stage1/dietlibc/libcruft/herrno_location.c b/mdk-stage1/dietlibc/libcruft/herrno_location.c
deleted file mode 100644
index 5908fe212..000000000
--- a/mdk-stage1/dietlibc/libcruft/herrno_location.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <errno.h>
-#include <resolv.h>
-#include <netdb.h>
-
-int *__h_errno_location(void);
-int *__h_errno_location(void) { return &h_errno; }
-
-int *h_errno_location(void) __attribute__((weak,alias("__h_errno_location")));
diff --git a/mdk-stage1/dietlibc/libcruft/herror.c b/mdk-stage1/dietlibc/libcruft/herror.c
deleted file mode 100644
index 619dd9ce5..000000000
--- a/mdk-stage1/dietlibc/libcruft/herror.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <netdb.h>
-
-void herror(const char* s) {
- write(2,s,strlen(s));
- write(2,": DNS error.\n",13);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/hstrerror.c b/mdk-stage1/dietlibc/libcruft/hstrerror.c
deleted file mode 100644
index fb8902f67..000000000
--- a/mdk-stage1/dietlibc/libcruft/hstrerror.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <netdb.h>
-
-const char* hstrerror(int h_errno) {
- switch (h_errno) {
- case 0: return "OK";
- case NO_DATA: return "No data of requested type.";
- case TRY_AGAIN: return "Temporary failure.";
- case HOST_NOT_FOUND:
- default: return "Unknown host.";
- }
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_addr.c b/mdk-stage1/dietlibc/libcruft/inet_addr.c
deleted file mode 100644
index 0b8531ab1..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_addr.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-unsigned long int inet_addr(const char *cp) {
- struct in_addr foo;
- if (inet_aton(cp,&foo))
- return foo.s_addr;
- else
- return (unsigned long int)-1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_aton.c b/mdk-stage1/dietlibc/libcruft/inet_aton.c
deleted file mode 100644
index 01adb341e..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_aton.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-
-/* inet_aton() converts the Internet host address cp from the standard
- * numbers-and-dots notation into binary data and stores it in the
- * structure that inp points to. inet_aton returns nonzero if the
- * address is valid, zero if not. */
-
-/* problem is, inet_aton is historically quite, uh, lenient.
- * the following are all acceptable:
- * 0x7f000001 == 127.1 == 127.0.0.1.0 == 127.0.0.1
- * btw: 127.0.0.x.y == 127.0.0.(x|y)
- * and: 10.1.1 == 10.1.0.1 (huh?!)
- * and: 10 == 0.0.0.10 (?!?!?)
- * The Berkeley people must have been so stoned that they are still high.
- */
-
-/* I hereby disclaim that I wrote this code. */
-int inet_aton(const char *cp, struct in_addr *inp) {
- int i;
- unsigned int ip=0;
- char *tmp=(char*)cp;
- for (i=24; ;) {
- long j;
- j=strtoul(tmp,&tmp,0);
- if (*tmp==0) {
- ip|=j;
- break;
- }
- if (*tmp=='.') {
- if (j>255) return 0;
- ip|=(j<<i);
- if (i>0) i-=8;
- ++tmp;
- continue;
- }
- return 0;
- }
- inp->s_addr=htonl(ip);
- return 1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_ntoa.c b/mdk-stage1/dietlibc/libcruft/inet_ntoa.c
deleted file mode 100644
index 632d81424..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_ntoa.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-char *inet_ntoa(struct in_addr in) {
- static char buf[20];
- return inet_ntoa_r(in,buf);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_ntoa_r.c b/mdk-stage1/dietlibc/libcruft/inet_ntoa_r.c
deleted file mode 100644
index dcf0eab7b..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_ntoa_r.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-static unsigned int i2a(char* dest,unsigned int x) {
- register unsigned int tmp=x;
- register unsigned int len=0;
- if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; }
- if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; }
- *dest++=tmp+'0';
- return len+1;
-}
-
-char *inet_ntoa_r(struct in_addr in,char* buf) {
- unsigned int len;
- unsigned char *ip=(unsigned char*)&in;
- len=i2a(buf,ip[0]); buf[len]='.'; ++len;
- len+=i2a(buf+ len,ip[1]); buf[len]='.'; ++len;
- len+=i2a(buf+ len,ip[2]); buf[len]='.'; ++len;
- len+=i2a(buf+ len,ip[3]); buf[len]=0;
- return buf;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_ntop.c b/mdk-stage1/dietlibc/libcruft/inet_ntop.c
deleted file mode 100644
index 81bee0a90..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_ntop.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <string.h>
-
-static const unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff};
-
-static char tohex(char hexdigit) {
- return hexdigit>9?hexdigit+'a'-10:hexdigit+'0';
-}
-
-static int fmt_xlong(char* s,unsigned int i) {
- char* bak=s;
- *s=tohex((i>>12)&0xf); if (s!=bak || *s!='0') ++s;
- *s=tohex((i>>8)&0xf); if (s!=bak || *s!='0') ++s;
- *s=tohex((i>>4)&0xf); if (s!=bak || *s!='0') ++s;
- *s=tohex(i&0xf);
- return s-bak+1;
-}
-
-static unsigned int fmt_ip6(char *s,const char ip[16]) {
- unsigned int len;
- unsigned int i;
- unsigned int temp;
- unsigned int compressing;
- int j;
-
- len = 0; compressing = 0;
- for (j=0; j<16; j+=2) {
- if (j==12 && !memcmp(ip,V4mappedprefix,12)) {
- inet_ntoa_r(*(struct in_addr*)(ip+12),s);
- temp=strlen(s);
- return len+temp;
- }
- temp = ((unsigned long) (unsigned char) ip[j] << 8) +
- (unsigned long) (unsigned char) ip[j+1];
- if (temp == 0) {
- if (!compressing) {
- compressing=1;
- if (j==0) {
- *s++=':'; ++len;
- }
- }
- } else {
- if (compressing) {
- compressing=0;
- *s++=':'; ++len;
- }
- i = fmt_xlong(s,temp); len += i; s += i;
- if (j<14) {
- *s++ = ':';
- ++len;
- }
- }
- }
- if (compressing) {
- *s++=':'; ++len;
- }
- *s=0;
- return len;
-}
-
-const char* inet_ntop(int AF, const void *CP, char *BUF, size_t LEN) {
- char buf[100];
- size_t len;
- if (AF==AF_INET) {
- inet_ntoa_r(*(struct in_addr*)CP,buf);
- len=strlen(buf);
- } else if (AF==AF_INET6) {
- len=fmt_ip6(buf,CP);
- } else
- return 0;
- if (len<LEN) {
- strcpy(BUF,buf);
- return BUF;
- }
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/inet_pton.c b/mdk-stage1/dietlibc/libcruft/inet_pton.c
deleted file mode 100644
index a62785d5f..000000000
--- a/mdk-stage1/dietlibc/libcruft/inet_pton.c
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <string.h>
-#include "dietfeatures.h"
-
-static unsigned int scan_ip6(const char *s,char ip[16])
-{
- unsigned int i;
- unsigned int len=0;
- unsigned long u;
-
- char suffix[16];
- unsigned int prefixlen=0;
- unsigned int suffixlen=0;
-
- for (i=0; i<16; i++) ip[i]=0;
-
- for (;;) {
- if (*s == ':') {
- len++;
- if (s[1] == ':') { /* Found "::", skip to part 2 */
- s+=2;
- len++;
- break;
- }
- s++;
- }
- {
- char *tmp;
- u=strtoul(s,&tmp,16);
- i=tmp-s;
- }
-
- if (!i) return 0;
- if (prefixlen==12 && s[i]=='.') {
- /* the last 4 bytes may be written as IPv4 address */
- if (inet_aton(s,(struct in_addr*)(ip+12)))
- return i+len;
- else
- return 0;
- }
- ip[prefixlen++] = (u >> 8);
- ip[prefixlen++] = (u & 255);
- s += i; len += i;
- if (prefixlen==16)
- return len;
- }
-
-/* part 2, after "::" */
- for (;;) {
- if (*s == ':') {
- if (suffixlen==0)
- break;
- s++;
- len++;
- } else if (suffixlen!=0)
- break;
- {
- char *tmp;
- u=strtol(s,&tmp,16);
- i=tmp-s;
- }
- if (!i) {
- if (*s) len--;
- break;
- }
- if (suffixlen+prefixlen<=12 && s[i]=='.') {
- if (inet_aton(s,(struct in_addr*)(suffix+suffixlen))) {
- suffixlen+=4;
- len+=strlen(s);
- break;
- } else
- prefixlen=12-suffixlen; /* make end-of-loop test true */
- }
- suffix[suffixlen++] = (u >> 8);
- suffix[suffixlen++] = (u & 255);
- s += i; len += i;
- if (prefixlen+suffixlen==16)
- break;
- }
- for (i=0; i<suffixlen; i++)
- ip[16-suffixlen+i] = suffix[i];
- return len;
-}
-
-int inet_pton(int AF, const char *CP, void *BUF) {
- int len;
- if (AF==AF_INET) {
- if (!inet_aton(CP,(struct in_addr*)BUF))
- return 0;
- } else if (AF==AF_INET6) {
- if (CP[len=scan_ip6(CP,BUF)])
- if (CP[len]!='%') /* allow "fe80::220:e0ff:fe69:ad92%eth0" */
- return 0;
- } else {
- errno=EAFNOSUPPORT;
- return -1;
- }
- return 1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/initgroups.c b/mdk-stage1/dietlibc/libcruft/initgroups.c
deleted file mode 100644
index 932fddfd6..000000000
--- a/mdk-stage1/dietlibc/libcruft/initgroups.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <grp.h>
-#include <sys/types.h>
-#include <string.h>
-
-int initgroups(const char *user, gid_t group) {
- int n=1;
- gid_t grouplist[32];
- struct group *g;
- grouplist[0]=group;
- setgrent();
- while ((g=getgrent())) {
- char **duh=g->gr_mem;
- while (*duh) {
- if (!strcmp(*duh,user)) {
- grouplist[n]=g->gr_gid;
- if (++n>=32)
- break;
- }
- duh++;
- }
- }
- return setgroups(n,grouplist);
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/killpg.c b/mdk-stage1/dietlibc/libcruft/killpg.c
deleted file mode 100644
index c03bb6330..000000000
--- a/mdk-stage1/dietlibc/libcruft/killpg.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <signal.h>
-
-int killpg(pid_t pgrp, int signal) {
- return kill(-pgrp,signal);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/localeconv.c b/mdk-stage1/dietlibc/libcruft/localeconv.c
deleted file mode 100644
index d2c5ff82c..000000000
--- a/mdk-stage1/dietlibc/libcruft/localeconv.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <limits.h>
-#include <locale.h>
-
-/* these answers are what glibc says */
-
-static struct lconv l =
- {".","","","","","", /* decimal_point - mon_decimal_point */
- "","","","",127,127, /* mon_thousands_sep - frac_digits */
- 127,127,127,127,127,127, /* p_cs_precedes - n_sign_posn */
- 127,127,127,127,127,127 }; /* __int_p_cs_precedes - __int_n_sign_posn */
-
-
-struct lconv* localeconv() {
- return &l;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/mkdtemp.c b/mdk-stage1/dietlibc/libcruft/mkdtemp.c
deleted file mode 100644
index 1c388938c..000000000
--- a/mdk-stage1/dietlibc/libcruft/mkdtemp.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "dietfeatures.h"
-
-char* mkdtemp(char* template) {
- char *tmp=template+strlen(template)-6;
- int randfd,i;
- unsigned int random;
- if (tmp<template) goto error;
- for (i=0; i<6; ++i) if (tmp[i]!='X') { error: errno=EINVAL; return 0; }
- randfd=open("/dev/urandom",O_RDONLY);
- for (;;) {
- read(randfd,&random,sizeof(random));
- for (i=0; i<6; ++i) {
- int hexdigit=(random>>(i*5))&0x1f;
- tmp[i]=hexdigit>9?hexdigit+'a'-10:hexdigit+'0';
- }
- if (mkdir(template,0700)==0) break;
- if (errno==EEXIST) continue;
- close(randfd);
- return 0;
- }
- close(randfd);
- return template;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/mkstemp.c b/mdk-stage1/dietlibc/libcruft/mkstemp.c
deleted file mode 100644
index 7dc19d4ed..000000000
--- a/mdk-stage1/dietlibc/libcruft/mkstemp.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "dietfeatures.h"
-
-#ifndef O_NOFOLLOW
-#define O_NOFOLLOW 0
-#endif
-
-int mkstemp(char* template) {
- char *tmp=template+strlen(template)-6;
- int randfd;
- int i,res;
- unsigned int random;
- if (tmp<template) goto error;
- for (i=0; i<6; ++i) if (tmp[i]!='X') { error: errno=EINVAL; return -1; }
- randfd=open("/dev/urandom",O_RDONLY);
- for (;;) {
- read(randfd,&random,sizeof(random));
- for (i=0; i<6; ++i) {
- int hexdigit=(random>>(i*5))&0x1f;
- tmp[i]=hexdigit>9?hexdigit+'a'-10:hexdigit+'0';
- }
- res=open(template,O_CREAT|O_RDWR|O_EXCL|O_NOFOLLOW,0600);
- if (res>=0 || errno!=EEXIST) break;
- }
- close(randfd);
- return res;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/mktemp.c b/mdk-stage1/dietlibc/libcruft/mktemp.c
deleted file mode 100644
index d1908a9ac..000000000
--- a/mdk-stage1/dietlibc/libcruft/mktemp.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <dietwarning.h>
-
-link_warning("mktemp","\e[1;33;41m>>> mktemp stinks! DON'T USE IT ! <<<\e[0m");
-
-char* mktemp(char* template) {
- int fd;
- if ((fd=mkstemp(template))<0) return 0;
- close(fd);
- unlink(template);
- return template;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/pwbuf.c b/mdk-stage1/dietlibc/libcruft/pwbuf.c
deleted file mode 100644
index aa0ad7001..000000000
--- a/mdk-stage1/dietlibc/libcruft/pwbuf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <pwd.h>
-
-struct passwd __passwd_pw;
-char __passwd_buf[1000];
-
diff --git a/mdk-stage1/dietlibc/libcruft/res_init.c b/mdk-stage1/dietlibc/libcruft/res_init.c
deleted file mode 100644
index 78baa2b30..000000000
--- a/mdk-stage1/dietlibc/libcruft/res_init.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <resolv.h>
-
-extern void __dns_readstartfiles(void);
-
-int res_init(void) {
- _res.nscount=0;
- __dns_readstartfiles();
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/res_mkquery.c b/mdk-stage1/dietlibc/libcruft/res_mkquery.c
deleted file mode 100644
index cf5693668..000000000
--- a/mdk-stage1/dietlibc/libcruft/res_mkquery.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <resolv.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-#include "dietfeatures.h"
-
-static char dnspacket[]="\xfe\xfe\001\000\000\001\000\000\000\000\000\000";
-
-/*
- 1 1 1 1 1 1
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- | ID |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- | QDCOUNT |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- | ANCOUNT |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- | NSCOUNT |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
- | ARCOUNT |
- +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-*/
-
-extern void __dns_make_fd(void);
-extern int __dns_fd;
-
-extern int __dns_servers;
-extern struct sockaddr __dns_server_ips[];
-
-extern void __dns_readstartfiles(void);
-
-int res_mkquery(int op, const char *dname, int class, int type, char* data,
- int datalen, const unsigned char* newrr, char* buf, int buflen) {
- unsigned char packet[512];
- memmove(packet,dnspacket,12);
- if ((_res.options&RES_RECURSE)==0) packet[2]=0;
- *(unsigned short*)packet=rand();
- {
- unsigned char* x;
- const char* y,* tmp;
- x=packet+12; y=dname;
- while (*y) {
- while (*y=='.') ++y;
- for (tmp=y; *tmp && *tmp!='.'; ++tmp) ;
- *x=tmp-y;
- if (!(tmp-y)) break;
- ++x;
- if (x>=packet+510-(tmp-y)) { return -1; }
- memmove(x,y,tmp-y);
- x+=tmp-y;
- if (!*tmp) {
- *x=0;
- break;
- }
- y=tmp;
- }
- *++x= 0; *++x= type; /* A */
- *++x= 0; *++x= class; /* IN */
- ++x;
- if (x-packet>buflen) return -1;
- memmove(buf,packet,x-packet);
- return x-packet;
- }
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/res_query.c b/mdk-stage1/dietlibc/libcruft/res_query.c
deleted file mode 100644
index 28b5c3ac8..000000000
--- a/mdk-stage1/dietlibc/libcruft/res_query.c
+++ /dev/null
@@ -1,95 +0,0 @@
-#include <resolv.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <sys/poll.h>
-#include <unistd.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-#include "dietfeatures.h"
-
-extern void __dns_make_fd(void);
-extern int __dns_fd;
-#ifdef WANT_IPV6_DNS
-extern void __dns_make_fd6(void);
-extern int __dns_fd6;
-#endif
-
-extern void __dns_readstartfiles(void);
-
-int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen) {
- unsigned char packet[512];
- int size;
-#ifndef WANT_IPV6_DNS
- __dns_make_fd();
-#endif
-
- __dns_readstartfiles();
- if ((size=res_mkquery(QUERY,dname,class,type,0,0,0,packet,512))<0) { h_errno=NO_RECOVERY; return -1; }
- {
- {
- int i; /* current server */
- int j; /* timeout count down */
- struct pollfd duh;
- struct timeval last,now;
-#ifdef WANT_IPV6_DNS
- int tmpfd; /* the warning gcc issues here is bogus */
-#else
- duh.fd=__dns_fd;
-#endif
- i=0;
- duh.events=POLLIN;
- last.tv_sec=0;
- for (j=120; j>0; --j) {
- gettimeofday(&now,0);
- if (now.tv_sec-last.tv_sec>10) {
-#ifdef WANT_IPV6_DNS
- struct sockaddr* s=(struct sockaddr*)&(_res.nsaddr_list[i]);
- if (s->sa_family==AF_INET6) {
- __dns_make_fd6();
- tmpfd=__dns_fd6;
- } else {
- __dns_make_fd();
- tmpfd=__dns_fd;
- }
- duh.fd=tmpfd;
- if (sendto(tmpfd,packet,size,0,s,sizeof(struct sockaddr_in6))==0)
- gettimeofday(&last,0);
-#else
- if (sendto(__dns_fd,packet,size,0,(struct sockaddr*)&(_res.nsaddr_list[i]),sizeof(struct sockaddr))==0)
- gettimeofday(&last,0);
-#endif
- last=now;
- }
- if (++i >= _res.nscount) i=0;
- if (poll(&duh,1,1000) == 1) {
- /* read and parse answer */
- unsigned char inpkg[1500];
-#ifdef WANT_IPV6_DNS
- int len=read(tmpfd,inpkg,1500);
-#else
- int len=read(__dns_fd,inpkg,1500);
-#endif
- /* header, question, answer, authority, additional */
- if (inpkg[0]!=packet[0] || inpkg[1]!=packet[1]) continue; /* wrong ID */
- if ((inpkg[2]&0xf9) != (_res.options&RES_RECURSE?0x81:0x80)) continue; /* not answer */
- if ((inpkg[3]&0x0f) != 0) { h_errno=HOST_NOT_FOUND; return -1; } /* error */
- if (len>anslen) {
- h_errno=NO_RECOVERY;
- return -1;
- }
- memmove(answer,inpkg,len);
- return len;
- }
-/*kaputt:*/
- }
- }
- }
- h_errno=NO_DATA;
- return -1;
-}
-
diff --git a/mdk-stage1/dietlibc/libcruft/res_search.c b/mdk-stage1/dietlibc/libcruft/res_search.c
deleted file mode 100644
index a8b9257bc..000000000
--- a/mdk-stage1/dietlibc/libcruft/res_search.c
+++ /dev/null
@@ -1,35 +0,0 @@
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-
-extern int __dns_search;
-extern char *__dns_domains[];
-
-int res_search(const char *dname, int class, int type, unsigned char *answer, int anslen) {
- const char *tmp=dname;
- char Buf[MAXDNAME+1];
- int res;
- int len=strlen(dname);
- int count=0;
- memmove(Buf,dname,len);
- Buf[len]=Buf[MAXDNAME]=0;
-// printf("appending %d: %p\n",count,__dns_domains[count]);
- while ((res=res_query(tmp,class,type,answer,anslen))<0) {
- if (count==__dns_search) break;
- Buf[len]='.';
-// printf("appending %d: %p (%s)\n",count,__dns_domains[count],__dns_domains[count]);
- memccpy(Buf+len+1,__dns_domains[count],0,MAXDNAME-len-1);
- tmp=Buf;
- ++count;
- }
- return res;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/scan_ulong.c b/mdk-stage1/dietlibc/libcruft/scan_ulong.c
deleted file mode 100644
index dfbec5c55..000000000
--- a/mdk-stage1/dietlibc/libcruft/scan_ulong.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <ctype.h>
-#include <sys/types.h>
-#include "parselib.h"
-
-size_t scan_ulong(const char* s,unsigned long* l) {
- size_t n;
- unsigned long x;
- unsigned int digit;
- for (x=n=0; (digit=(s[n]-'0'))<10u; ++n)
- x=x*10+digit;
- *l=x;
- return n;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/scandir.c b/mdk-stage1/dietlibc/libcruft/scandir.c
deleted file mode 100644
index fac7eaa7f..000000000
--- a/mdk-stage1/dietlibc/libcruft/scandir.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <stdlib.h>
-#include <dirent.h>
-#include <string.h>
-
-int scandir(const char *dir, struct dirent ***namelist,
- int (*select)(const struct dirent *),
- int (*compar)(const struct dirent **, const struct dirent **)) {
- DIR* d;
- struct dirent *D;
- int num=0;
- if (!(d=opendir(dir)))
- return -1;
- *namelist=0;
- while ((D=readdir(d))) {
- if (select==0 || select(D)) {
- struct dirent **tmp;
- ++num;
-/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */
- if (!(tmp=realloc(*namelist,num*sizeof(struct dirent**))) ||
- !(tmp[num-1]=malloc(sizeof(struct dirent)))) {
- int i;
- for (i=0; i<num-1; ++i) free(tmp[i]);
- free(*namelist);
- closedir(d);
- return -1;
- }
- memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX);
- *namelist=tmp;
-/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */
- }
- }
- closedir(d);
-#if 0
- {
- int i;
- puts("pre-qsort:\n");
- for (i=0; i<num-1; ++i) {
- puts((*namelist)[i]->d_name);
- }
- puts("post-qsort:\n");
- }
-#endif
-// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
- if (compar)
- qsort(*namelist,num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
- return num;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/scandir64.c b/mdk-stage1/dietlibc/libcruft/scandir64.c
deleted file mode 100644
index c1bdc3415..000000000
--- a/mdk-stage1/dietlibc/libcruft/scandir64.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <stdlib.h>
-#include <dirent.h>
-#include <string.h>
-
-int scandir64(const char *dir, struct dirent64 ***namelist,
- int (*select)(const struct dirent64 *),
- int (*compar)(const struct dirent64 **, const struct dirent64 **)) {
- DIR* d;
- struct dirent64 *D;
- int num=0;
- if (!(d=opendir(dir)))
- return -1;
- *namelist=0;
- while ((D=readdir64(d))) {
- if (select==0 || select(D)) {
- struct dirent64 **tmp;
- ++num;
-/* printf("realloc %p,%d -> ",*namelist,num*sizeof(struct dirent**)); */
- if (!(tmp=realloc(*namelist,num*sizeof(struct dirent64**))) ||
- !(tmp[num-1]=malloc(sizeof(struct dirent64)))) {
- int i;
- for (i=0; i<num-1; ++i) free(tmp[i]);
- free(*namelist);
- closedir(d);
- return -1;
- }
- memccpy(tmp[num-1]->d_name,D->d_name,0,NAME_MAX);
- *namelist=tmp;
-/* printf("%p; tmp[num-1(%d)]=%p\n",*namelist,num-1,tmp[num-1]); */
- }
- }
- closedir(d);
-#if 0
- {
- int i;
- puts("pre-qsort:\n");
- for (i=0; i<num-1; ++i) {
- puts((*namelist)[i]->d_name);
- }
- puts("post-qsort:\n");
- }
-#endif
-// qsort(&(*namelist)[0],num,sizeof(struct dirent*),(int (*)(const void*,const void*))(compar));
- if (compar)
- qsort(*namelist,num,sizeof(struct dirent64*),(int (*)(const void*,const void*))(compar));
- return num;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/setegid.c b/mdk-stage1/dietlibc/libcruft/setegid.c
deleted file mode 100644
index 6e891952b..000000000
--- a/mdk-stage1/dietlibc/libcruft/setegid.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include "dietwarning.h"
-
-#undef setegid
-int setegid(gid_t gid);
-int setegid(gid_t gid) {
- return setregid((gid_t)-1,gid);
-}
-
-link_warning("setegid","warning: you used setegid without including <unistd.h>")
diff --git a/mdk-stage1/dietlibc/libcruft/seteuid.c b/mdk-stage1/dietlibc/libcruft/seteuid.c
deleted file mode 100644
index 8145f20d7..000000000
--- a/mdk-stage1/dietlibc/libcruft/seteuid.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/types.h>
-#include <unistd.h>
-#include "dietwarning.h"
-
-#undef seteuid
-int seteuid(uid_t uid);
-int seteuid(uid_t uid) {
- return setreuid((uid_t)-1,uid);
-}
-
-link_warning("setegid","warning: you used setegid without including <unistd.h>")
diff --git a/mdk-stage1/dietlibc/libcruft/setlocale.c b/mdk-stage1/dietlibc/libcruft/setlocale.c
deleted file mode 100644
index e0e8f647d..000000000
--- a/mdk-stage1/dietlibc/libcruft/setlocale.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <locale.h>
-
-char *setlocale (int category, const char *locale) {
- (void)category;
- (void)locale;
- return 0;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/spbuf.c b/mdk-stage1/dietlibc/libcruft/spbuf.c
deleted file mode 100644
index ab880bbcf..000000000
--- a/mdk-stage1/dietlibc/libcruft/spbuf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <shadow.h>
-
-struct spwd __shadow_pw;
-char __shadow_buf[1000];
-
diff --git a/mdk-stage1/dietlibc/libcruft/sysconf.c b/mdk-stage1/dietlibc/libcruft/sysconf.c
deleted file mode 100644
index e9c15cb66..000000000
--- a/mdk-stage1/dietlibc/libcruft/sysconf.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <sys/resource.h>
-
-extern int __sc_nr_cpus();
-
-long sysconf(int name)
-{
- switch(name)
- {
- case _SC_OPEN_MAX:
- {
- struct rlimit limit;
- getrlimit(RLIMIT_NOFILE, &limit);
- return limit.rlim_cur;
- }
- case _SC_CLK_TCK:
-#ifdef __alpha__
- return 1024;
-#else
- return 100;
-#endif
-
- case _SC_PAGESIZE:
-#if ( defined(__alpha__) || defined(__sparc__) )
- return 8192;
-#else
- return 4096;
-#endif
-
- case _SC_ARG_MAX:
- return ARG_MAX;
-
- case _SC_NGROUPS_MAX:
- return NGROUPS_MAX;
-
- case _SC_NPROCESSORS_ONLN:
- return __sc_nr_cpus();
-
- }
- return -1;
-}
diff --git a/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c b/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c
deleted file mode 100644
index b5361d0a4..000000000
--- a/mdk-stage1/dietlibc/libcruft/sysconf_cpus.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "dietfeatures.h"
-
-/*
- * by Olaf Dreesen
- *
- * arm NO SMP ?!? (return 1)
- *
- * alpha -> cpus detected\t\t: <nr>\n
- * sparc -> ncpus active\t: <nr>\n
- *
- * default -> processor\t: <cpunr>\n (one per cpu)
- */
-
-#ifdef SLASH_PROC_OK
-int __sc_nr_cpus(void);
-int __sc_nr_cpus() {
-#if defined(__arm__)
- return 1;
-#else
- int fd;
- fd = open("/proc/cpuinfo", O_RDONLY);
- if (fd==-1) return 1; /* fallback if no proc-fs mounted */
- else {
- int n,nr=0;
- char buf[2048]; /* holds ~6 cpuinfos */
-
- while((n=read(fd,buf,sizeof(buf)))>0) {
- register int i=0;
- while (i<n) {
-#if defined(__alpha__)
- if ((buf[i]=='c')&&(!memcmp(buf+i,"cpus detected",13))) {
- i+=17;
- nr=atoi(buf+i);
- break;
- }
-#elif defined(__sparc__)
- if ((buf[i]=='n')&&(!memcmp(buf+i,"ncpus active",12))) {
- i+=15;
- nr=atoi(buf+i);
- break;
- }
-#else /* DEFAULT */
- if ((buf[i]=='p')&&(!memcmp(buf+i,"processor",9))) {
- ++nr;
- i+=9;
- }
-#endif
- while(buf[i++]!='\n'); /* skip rest of line */
- }
- }
- close(fd);
- return nr;
- }
-#endif
-}
-#else
-int __sc_nr_cpus() {
- return 1; /* kludge kludge ;-) */
-}
-#endif
diff --git a/mdk-stage1/dietlibc/libcruft/tempnam.c b/mdk-stage1/dietlibc/libcruft/tempnam.c
deleted file mode 100644
index 01c20b490..000000000
--- a/mdk-stage1/dietlibc/libcruft/tempnam.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <dietwarning.h>
-
-link_warning("tempnam","\e[1;33;41m>>> tempnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m");
-
-char* tempnam(char* dir,char* template) {
- char buf[1024];
- int len=sizeof(buf)-1,fd;
- buf[len]=0;
- if ((dir)&&(*dir)) {
- memccpy(buf,dir,0,len);
- strncat(buf,"/",1);
- }
- else
- strncpy(buf,"/tmp/",len);
- len=(sizeof(buf)-1)-strlen(buf);
- if (template)
- strncat(buf,template, --len);
- else
- strncat(buf,"temp_", --len);
- len=(sizeof(buf)-1)-strlen(buf);
- strncat(buf,"XXXXXX",len);
- if ((fd=mkstemp(buf))<0) return 0;
- close(fd);
- unlink(buf);
- return strdup(buf);
-}
diff --git a/mdk-stage1/dietlibc/libcruft/tmpnam.c b/mdk-stage1/dietlibc/libcruft/tmpnam.c
deleted file mode 100644
index 707730616..000000000
--- a/mdk-stage1/dietlibc/libcruft/tmpnam.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include "dietfeatures.h"
-#include <errno.h>
-#include <sys/stat.h>
-#include <dietwarning.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-link_warning("tmpnam","\e[1;33;41m>>> tmpnam stinks! NEVER ! NEVER USE IT ! <<<\e[0m");
-
-char* tmpnam(char* s) {
- static char buf[100];
- char *tmp;
- if (s) tmp=s; else tmp=buf;
- strcpy(tmp,"/tmp/temp_");
- for (;;) {
- struct stat s;
- int i,j;
- i=rand();
- for (j=0; j<8; ++j) {
- char c=i&0xf;
- tmp[9+j]=c>9?c+'a'-10:c+'0';
- i>>=4;
- }
- tmp[17]=0;
- if (lstat(tmp,&s)==-1 && errno==ENOENT) break;
- }
- return tmp;
-}