summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-05-14 04:16:35 +0000
committerErik Andersen <andersen@codepoet.org>2000-05-14 04:16:35 +0000
commit64bc6412188b141c010ac3b8e813b837dd991e80 (patch)
treeffa12b79ea4b13191754f54b872eb1a4f9e3a04b /libc
Initial revision
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/Makefile43
-rw-r--r--libc/inet/addr.c85
-rw-r--r--libc/inet/resolv.c892
-rw-r--r--libc/inet/rpc/Makefile27
-rw-r--r--libc/inet/rpc/auth_none.c133
-rw-r--r--libc/inet/rpc/auth_unix.c319
-rw-r--r--libc/inet/rpc/authunix_prot.c66
-rw-r--r--libc/inet/rpc/bindresvport.c78
-rw-r--r--libc/inet/rpc/clnt_generic.c115
-rw-r--r--libc/inet/rpc/clnt_perror.c310
-rw-r--r--libc/inet/rpc/clnt_raw.c238
-rw-r--r--libc/inet/rpc/clnt_simple.c112
-rw-r--r--libc/inet/rpc/clnt_tcp.c466
-rw-r--r--libc/inet/rpc/clnt_udp.c442
-rw-r--r--libc/inet/rpc/get_myaddress.c108
-rw-r--r--libc/inet/rpc/getrpcent.c286
-rw-r--r--libc/inet/rpc/getrpcport.c55
-rw-r--r--libc/inet/rpc/pmap_clnt.c115
-rw-r--r--libc/inet/rpc/pmap_getmaps.c84
-rw-r--r--libc/inet/rpc/pmap_getport.c87
-rw-r--r--libc/inet/rpc/pmap_prot.c57
-rw-r--r--libc/inet/rpc/pmap_prot2.c116
-rw-r--r--libc/inet/rpc/pmap_rmt.c408
-rw-r--r--libc/inet/rpc/rpc_callmsg.c190
-rw-r--r--libc/inet/rpc/rpc_commondata.c41
-rw-r--r--libc/inet/rpc/rpc_dtablesize.c46
-rw-r--r--libc/inet/rpc/rpc_prot.c289
-rw-r--r--libc/inet/rpc/svc.c492
-rw-r--r--libc/inet/rpc/svc_auth.c114
-rw-r--r--libc/inet/rpc/svc_auth_unix.c134
-rw-r--r--libc/inet/rpc/svc_raw.c166
-rw-r--r--libc/inet/rpc/svc_run.c72
-rw-r--r--libc/inet/rpc/svc_simple.c143
-rw-r--r--libc/inet/rpc/svc_tcp.c421
-rw-r--r--libc/inet/rpc/svc_udp.c475
-rw-r--r--libc/inet/rpc/xdr.c576
-rw-r--r--libc/inet/rpc/xdr_array.c153
-rw-r--r--libc/inet/rpc/xdr_float.c272
-rw-r--r--libc/inet/rpc/xdr_mem.c184
-rw-r--r--libc/inet/rpc/xdr_rec.c580
-rw-r--r--libc/inet/rpc/xdr_reference.c132
-rw-r--r--libc/inet/rpc/xdr_stdio.c189
-rw-r--r--libc/misc/time/Makefile24
-rw-r--r--libc/misc/time/README8
-rw-r--r--libc/misc/time/asc_conv.c49
-rw-r--r--libc/misc/time/asctime.c15
-rw-r--r--libc/misc/time/asctime_r.c15
-rw-r--r--libc/misc/time/ctime.c26
-rw-r--r--libc/misc/time/ctime_r.c26
-rw-r--r--libc/misc/time/gmtime.c16
-rw-r--r--libc/misc/time/gmtime_r.c14
-rw-r--r--libc/misc/time/localtime.c22
-rw-r--r--libc/misc/time/localtime_r.c22
-rw-r--r--libc/misc/time/mktime.c259
-rw-r--r--libc/misc/time/tm_conv.c138
-rw-r--r--libc/pwd_grp/Makefile33
-rw-r--r--libc/pwd_grp/__getgrent.c168
-rw-r--r--libc/pwd_grp/config.h65
-rw-r--r--libc/pwd_grp/fgetgrent.c35
-rw-r--r--libc/pwd_grp/fgetpwent.c35
-rw-r--r--libc/pwd_grp/getgrgid.c48
-rw-r--r--libc/pwd_grp/getgrnam.c51
-rw-r--r--libc/pwd_grp/getpw.c51
-rw-r--r--libc/pwd_grp/getpwnam.c52
-rw-r--r--libc/pwd_grp/getpwuid.c44
-rw-r--r--libc/pwd_grp/grent.c57
-rw-r--r--libc/pwd_grp/initgroups.c80
-rw-r--r--libc/pwd_grp/putpwent.c39
-rw-r--r--libc/pwd_grp/pwent.c62
-rw-r--r--libc/stdio/Makefile53
-rw-r--r--libc/stdio/printf.c387
-rw-r--r--libc/stdio/scanf.c536
-rw-r--r--libc/stdio/stdio.c925
-rw-r--r--libc/stdlib/Makefile64
-rw-r--r--libc/stdlib/atexit.c117
-rw-r--r--libc/stdlib/bsearch.c46
-rw-r--r--libc/stdlib/getenv.c31
-rw-r--r--libc/stdlib/malloc/Makefile33
-rw-r--r--libc/stdlib/malloc/alloc.c82
-rw-r--r--libc/stdlib/mkstemp.c43
-rw-r--r--libc/stdlib/mktemp.c40
-rw-r--r--libc/stdlib/putenv.c62
-rw-r--r--libc/stdlib/qsort.c166
-rw-r--r--libc/stdlib/rand.c61
-rw-r--r--libc/stdlib/setenv.c73
-rw-r--r--libc/stdlib/strtod.c96
-rw-r--r--libc/stdlib/system.c48
-rw-r--r--libc/string/Makefile37
-rw-r--r--libc/string/config.c93
-rw-r--r--libc/string/strcasecmp.c26
-rw-r--r--libc/string/strcspn.c32
-rw-r--r--libc/string/string.c672
-rw-r--r--libc/string/strncasecmp.c28
-rw-r--r--libc/string/strpbrk.c21
-rw-r--r--libc/string/strsep.c38
-rw-r--r--libc/string/strspn.c44
-rw-r--r--libc/string/strstr.c54
-rw-r--r--libc/string/strtok.c71
-rw-r--r--libc/sysdeps/linux/i386/bits/setjmp.h176
-rw-r--r--libc/termios/Makefile36
-rw-r--r--libc/termios/termios.c348
-rw-r--r--libc/termios/ttyname.c45
102 files changed, 15349 insertions, 0 deletions
diff --git a/libc/inet/Makefile b/libc/inet/Makefile
new file mode 100644
index 000000000..28565cecd
--- /dev/null
+++ b/libc/inet/Makefile
@@ -0,0 +1,43 @@
+# Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
+# Copyright (C) 1998-1999 D. Jeff Dionne <jeff@rt-control.com>
+# Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
+# Copyright (C) 1999 D. Jeff Dionne <jeff@rt-control.com>
+# under the GNU Library General Public License.
+
+LIBC=../libc.a
+
+CC=m68k-pic-coff-gcc
+AR=m68k-pic-coff-ar
+RANLIB=m68k-pic-coff-ranlib
+
+CCFLAGS= -O2 -m68000 -msoft-float -fno-builtin -I../include
+
+ASRC=addr.c
+AOBJ=inet_aton.o inet_addr.o inet_ntoa.o
+
+RSRC=resolv.c
+ROBJ= encodeh.o decodeh.o encoded.o decoded.o lengthd.o encodeq.o \
+decodeq.o lengthq.o encodea.o decodea.o encodep.o decodep.o \
+formquery.o dnslookup.o resolveaddress.o resolvemailbox.o \
+opennameservers.o closenameservers.o resolvename.o gethostbyname.o\
+gethostbyaddr.o
+
+OBJ=$(AOBJ) $(ROBJ)
+
+CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
+
+all: $(LIBC)
+ @$(RM) $(OBJ)
+
+$(LIBC): $(LIBC)($(OBJ))
+
+$(LIBC)($(AOBJ)): $(ASRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(AR) $(ARFLAGS) $@ $*.o
+
+$(LIBC)($(ROBJ)): $(RSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(AR) $(ARFLAGS) $@ $*.o
+
+clean:
+ rm -f *.o libc.a
diff --git a/libc/inet/addr.c b/libc/inet/addr.c
new file mode 100644
index 000000000..bb27753bf
--- /dev/null
+++ b/libc/inet/addr.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+
+#include <string.h>
+#include <ctype.h>
+#include <netinet/in.h>
+
+
+#ifdef L_inet_aton
+int
+inet_aton(cp, inp)
+const char *cp;
+struct in_addr *inp;
+{
+ unsigned long addr;
+ int value;
+ int part;
+
+ if (!inp)
+ return 0;
+
+ addr = 0;
+ for (part=1;part<=4;part++) {
+
+ if (!isdigit(*cp))
+ return 0;
+
+ value = 0;
+ while (isdigit(*cp)) {
+ value *= 10;
+ value += *cp++ - '0';
+ if (value > 255)
+ return 0;
+ }
+
+ if (*cp++ != ((part == 4) ? '\0' : '.'))
+ return 0;
+
+ addr <<= 8;
+ addr |= value;
+ }
+
+ inp->s_addr = htonl(addr);
+
+ return 1;
+}
+#endif
+
+#ifdef L_inet_addr
+unsigned long
+inet_addr(cp)
+const char *cp;
+{
+ struct in_addr a;
+ if (!inet_aton(cp, &a))
+ return -1;
+ else
+ return a.s_addr;
+}
+#endif
+
+#ifdef L_inet_ntoa
+
+extern char * itoa(int);
+
+char *
+inet_ntoa(in)
+struct in_addr in;
+{
+ static char buf[18];
+ unsigned long addr = ntohl(in.s_addr);
+
+ strcpy(buf, itoa((addr >> 24) & 0xff));
+ strcat(buf, ".");
+ strcat(buf, itoa((addr >> 16) & 0xff));
+ strcat(buf, ".");
+ strcat(buf, itoa((addr >> 8) & 0xff));
+ strcat(buf, ".");
+ strcat(buf, itoa(addr & 0xff));
+
+ return buf;
+}
+#endif
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
new file mode 100644
index 000000000..b4cfab104
--- /dev/null
+++ b/libc/inet/resolv.c
@@ -0,0 +1,892 @@
+/* resolv.c: DNS Resolver
+ *
+ * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
+ * The Silver Hammer Group, Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <cfgfile.h>
+#include <resolv.h>
+
+#define DNS_SERVICE 53
+#define MAX_RECURSE 5
+#define REPLY_TIMEOUT 10
+#define MAX_RETRIES 15
+
+#undef DEBUG
+#ifdef DEBUG
+#define DPRINTF(X,args...) printf(X,args...)
+#else
+#define DPRINTF(X,args...)
+#endif /* DEBUG */
+
+#ifdef L_encodeh
+int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen)
+{
+ if (maxlen < 12)
+ return -1;
+
+ dest[0] = (h->id & 0xff00) >> 8;
+ dest[1] = (h->id & 0x00ff) >> 0;
+ dest[2] = (h->qr ? 0x80 : 0) |
+ ((h->opcode & 0x0f) << 3) |
+ (h->aa ? 0x04 : 0) |
+ (h->tc ? 0x02 : 0) |
+ (h->rd ? 0x01 : 0);
+ dest[3] = (h->ra ? 0x80 : 0) |
+ (h->rcode & 0x0f);
+ dest[4] = (h->qdcount & 0xff00) >> 8;
+ dest[5] = (h->qdcount & 0x00ff) >> 0;
+ dest[6] = (h->ancount & 0xff00) >> 8;
+ dest[7] = (h->ancount & 0x00ff) >> 0;
+ dest[8] = (h->nscount & 0xff00) >> 8;
+ dest[9] = (h->nscount & 0x00ff) >> 0;
+ dest[10] = (h->arcount & 0xff00) >> 8;
+ dest[11] = (h->arcount & 0x00ff) >> 0;
+
+ return 12;
+}
+#endif
+
+#ifdef L_decodeh
+int decode_header(unsigned char * data, struct resolv_header * h)
+{
+ h->id = (data[0] << 8) | data[1];
+ h->qr = (data[2] & 0x80) ? 1 : 0;
+ h->opcode = (data[2] >> 3) & 0x0f;
+ h->aa = (data[2] & 0x04) ? 1 : 0;
+ h->tc = (data[2] & 0x02) ? 1 : 0;
+ h->rd = (data[2] & 0x01) ? 1 : 0;
+ h->ra = (data[3] & 0x80) ? 1 : 0;
+ h->rcode = data[3] & 0x0f;
+ h->qdcount = (data[4] << 8) | data[5];
+ h->ancount = (data[6] << 8) | data[7];
+ h->nscount = (data[8] << 8) | data[9];
+ h->arcount = (data[10] << 8) | data[11];
+
+ return 12;
+}
+#endif
+
+#ifdef L_encoded
+/* Encode a dotted string into nameserver transport-level encoding.
+ This routine is fairly dumb, and doesn't attempt to compress
+ the data */
+
+int encode_dotted(const char * dotted, unsigned char * dest, int maxlen)
+{
+ int used=0;
+
+ while(dotted && *dotted) {
+ char * c = strchr(dotted, '.');
+ int l = c ? c - dotted : strlen(dotted);
+
+ if (l >= (maxlen-used-1))
+ return -1;
+
+ dest[used++] = l;
+ memcpy(dest+used, dotted, l);
+ used += l;
+
+ if (c)
+ dotted = c+1;
+ else
+ break;
+ }
+
+ if (maxlen < 1)
+ return -1;
+
+ dest[used++] = 0;
+
+ return used;
+}
+#endif
+
+#ifdef L_decoded
+/* Decode a dotted string from nameserver transport-level encoding.
+ This routine understands compressed data. */
+
+int decode_dotted(const unsigned char * data, int offset,
+ char * dest, int maxlen)
+{
+ int l;
+ int measure=1;
+ int total = 0;
+ int used=0;
+
+ if (!data)
+ return -1;
+
+ while ((measure && total++), (l=data[offset++])) {
+
+ if ((l & 0xc0) == (0xc0)) {
+ if (measure)
+ total++;
+ /* compressed item, redirect */
+ offset = ((l & 0x3f) << 8) | data[offset];
+ measure = 0;
+ continue;
+ }
+
+ if ((used+l+1) >= maxlen)
+ return -1;
+
+ memcpy(dest+used, data+offset, l);
+ offset += l;
+ used += l;
+ if (measure)
+ total += l;
+
+ if (data[offset] != 0)
+ dest[used++] = '.';
+ else
+ dest[used++] = '\0';
+ }
+
+ DPRINTF("Total decode len = %d\n", total);
+
+ return total;
+}
+#endif
+
+#ifdef L_lengthd
+
+int length_dotted(const unsigned char * data, int offset)
+{
+ int orig_offset = offset;
+ int l;
+
+ if (!data)
+ return -1;
+
+ while ((l=data[offset++])) {
+
+ if ((l & 0xc0) == (0xc0)) {
+ offset++;
+ break;
+ }
+
+ offset += l;
+ }
+
+ return offset-orig_offset;
+}
+#endif
+
+#ifdef L_encodeq
+int encode_question(struct resolv_question * q,
+ unsigned char * dest, int maxlen)
+{
+ int i;