From c1fe19d4c1db610692365472a90f4661e48449c1 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 9 Oct 2000 20:06:30 +0000 Subject: Bug ugly formatting update --- libc/inet/.indent.pro | 33 +++ libc/inet/Makefile | 10 +- libc/inet/addr.c | 108 ++++---- libc/inet/resolv.c | 552 ++++++++++++++++++++--------------------- libc/inet/rpc/auth_none.c | 57 ++--- libc/inet/rpc/auth_unix.c | 126 +++++----- libc/inet/rpc/authunix_prot.c | 22 +- libc/inet/rpc/bindresvport.c | 12 +- libc/inet/rpc/clnt_generic.c | 19 +- libc/inet/rpc/clnt_perror.c | 218 ++++++++-------- libc/inet/rpc/clnt_raw.c | 106 ++++---- libc/inet/rpc/clnt_simple.c | 39 +-- libc/inet/rpc/clnt_tcp.c | 234 +++++++++-------- libc/inet/rpc/clnt_udp.c | 261 ++++++++++--------- libc/inet/rpc/get_myaddress.c | 22 +- libc/inet/rpc/getrpcent.c | 74 +++--- libc/inet/rpc/getrpcport.c | 6 +- libc/inet/rpc/pmap_clnt.c | 40 +-- libc/inet/rpc/pmap_getmaps.c | 20 +- libc/inet/rpc/pmap_getport.c | 26 +- libc/inet/rpc/pmap_prot.c | 17 +- libc/inet/rpc/pmap_prot2.c | 26 +- libc/inet/rpc/pmap_rmt.c | 212 ++++++++-------- libc/inet/rpc/rpc_callmsg.c | 74 +++--- libc/inet/rpc/rpc_commondata.c | 3 +- libc/inet/rpc/rpc_dtablesize.c | 6 +- libc/inet/rpc/rpc_prot.c | 124 +++++---- libc/inet/rpc/svc.c | 301 +++++++++++----------- libc/inet/rpc/svc_auth.c | 33 +-- libc/inet/rpc/svc_auth_unix.c | 39 +-- libc/inet/rpc/svc_raw.c | 81 +++--- libc/inet/rpc/svc_run.c | 13 +- libc/inet/rpc/svc_simple.c | 51 ++-- libc/inet/rpc/svc_tcp.c | 219 ++++++++-------- libc/inet/rpc/svc_udp.c | 229 +++++++++-------- libc/inet/rpc/xdr.c | 198 +++++++-------- libc/inet/rpc/xdr_array.c | 52 ++-- libc/inet/rpc/xdr_float.c | 154 ++++++------ libc/inet/rpc/xdr_mem.c | 101 ++++---- libc/inet/rpc/xdr_rec.c | 312 ++++++++++++----------- libc/inet/rpc/xdr_reference.c | 37 ++- libc/inet/rpc/xdr_stdio.c | 132 +++++----- 42 files changed, 2166 insertions(+), 2233 deletions(-) create mode 100644 libc/inet/.indent.pro (limited to 'libc/inet') diff --git a/libc/inet/.indent.pro b/libc/inet/.indent.pro new file mode 100644 index 000000000..492ecf1c7 --- /dev/null +++ b/libc/inet/.indent.pro @@ -0,0 +1,33 @@ +--blank-lines-after-declarations +--blank-lines-after-procedures +--break-before-boolean-operator +--no-blank-lines-after-commas +--braces-on-if-line +--braces-on-struct-decl-line +--comment-indentation25 +--declaration-comment-column25 +--no-comment-delimiters-on-blank-lines +--cuddle-else +--continuation-indentation4 +--case-indentation0 +--else-endif-column33 +--space-after-cast +--line-comments-indentation0 +--declaration-indentation1 +--dont-format-first-column-comments +--dont-format-comments +--honour-newlines +--indent-level4 +/* changed from 0 to 4 */ +--parameter-indentation4 +--line-length78 /* changed from 75 */ +--continue-at-parentheses +--no-space-after-function-call-names +--dont-break-procedure-type +--dont-star-comments +--leave-optional-blank-lines +--dont-space-special-semicolon +--tab-size4 +/* additions by Mark */ +--case-brace-indentation0 +--leave-preprocessor-space diff --git a/libc/inet/Makefile b/libc/inet/Makefile index 519501180..07d84d6eb 100644 --- a/libc/inet/Makefile +++ b/libc/inet/Makefile @@ -33,11 +33,13 @@ MOBJ2=encodeh.o decodeh.o encoded.o decoded.o lengthd.o encodeq.o \ formquery.o dnslookup.o resolveaddress.o resolvemailbox.o \ opennameservers.o closenameservers.o resolvename.o gethostbyname.o\ gethostbyaddr.o +OBJS=$(MOBJ) $(MOBJ2) +all: $(OBJS) $(LIBC) -all: $(MOBJ) $(MOBJ2) $(LIBC) +$(LIBC): ar-target -$(LIBC): $(MOBJ) $(MOBJ2) - $(AR) $(ARFLAGS) $(LIBC) $(MOBJ) $(MOBJ2) +ar-target: $(OBJS) + $(AR) $(ARFLAGS) $(LIBC) $(OBJS) $(MOBJ): $(MSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o @@ -45,6 +47,8 @@ $(MOBJ): $(MSRC) $(MOBJ2): $(MSRC2) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o +$(OBJS): Makefile + clean: rm -f *.[oa] *~ core diff --git a/libc/inet/addr.c b/libc/inet/addr.c index dcdd06cd4..142363ccc 100644 --- a/libc/inet/addr.c +++ b/libc/inet/addr.c @@ -10,77 +10,75 @@ int inet_aton(const char *cp, struct in_addr *inp); #ifdef L_inet_aton -int -inet_aton(cp, inp) +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; + 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) +unsigned long inet_addr(cp) const char *cp; { - struct in_addr a; - if (!inet_aton(cp, &a)) - return -1; - else - return a.s_addr; + 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); +extern char *itoa(int); -char * -inet_ntoa(in) +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; + 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 index 27daaf4d6..ae23064bb 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -31,10 +31,10 @@ #define DPRINTF(X,args...) printf(X,args...) #else #define DPRINTF(X,args...) -#endif /* DEBUG */ +#endif /* DEBUG */ #ifdef L_encodeh -int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen) +int encode_header(struct resolv_header *h, unsigned char *dest, int maxlen) { if (maxlen < 12) return -1; @@ -42,12 +42,9 @@ int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen) 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); + ((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; @@ -56,13 +53,13 @@ int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen) 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) +int decode_header(unsigned char *data, struct resolv_header *h) { h->id = (data[0] << 8) | data[1]; h->qr = (data[2] & 0x80) ? 1 : 0; @@ -76,7 +73,7 @@ int decode_header(unsigned char * data, struct resolv_header * h) h->ancount = (data[6] << 8) | data[7]; h->nscount = (data[8] << 8) | data[9]; h->arcount = (data[10] << 8) | data[11]; - + return 12; } #endif @@ -85,33 +82,33 @@ int decode_header(unsigned char * data, struct resolv_header * h) /* 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 encode_dotted(const char *dotted, unsigned char *dest, int maxlen) { - int used=0; + int used = 0; - while(dotted && *dotted) { - char * c = strchr(dotted, '.'); + while (dotted && *dotted) { + char *c = strchr(dotted, '.'); int l = c ? c - dotted : strlen(dotted); - - if (l >= (maxlen-used-1)) + + if (l >= (maxlen - used - 1)) return -1; - + dest[used++] = l; - memcpy(dest+used, dotted, l); + memcpy(dest + used, dotted, l); used += l; - + if (c) - dotted = c+1; + dotted = c + 1; else break; } - + if (maxlen < 1) return -1; - + dest[used++] = 0; - + return used; } #endif @@ -120,19 +117,19 @@ int encode_dotted(const char * dotted, unsigned char * dest, int maxlen) /* 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 decode_dotted(const unsigned char *data, int offset, + char *dest, int maxlen) { int l; - int measure=1; + int measure = 1; int total = 0; - int used=0; - + int used = 0; + if (!data) return -1; - - while ((measure && total++), (l=data[offset++])) { - + + while ((measure && total++), (l = data[offset++])) { + if ((l & 0xc0) == (0xc0)) { if (measure) total++; @@ -141,80 +138,80 @@ int decode_dotted(const unsigned char * data, int offset, measure = 0; continue; } - - if ((used+l+1) >= maxlen) + + if ((used + l + 1) >= maxlen) return -1; - - memcpy(dest+used, data+offset, l); + + 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 length_dotted(const unsigned char *data, int offset) { int orig_offset = offset; int l; - + if (!data) return -1; - - while ((l=data[offset++])) { - + + while ((l = data[offset++])) { + if ((l & 0xc0) == (0xc0)) { offset++; break; } - + offset += l; } - - return offset-orig_offset; + + return offset - orig_offset; } #endif #ifdef L_encodeq -int encode_question(struct resolv_question * q, - unsigned char * dest, int maxlen) +int encode_question(struct resolv_question *q, + unsigned char *dest, int maxlen) { int i; i = encode_dotted(q->dotted, dest, maxlen); if (i < 0) return i; - + dest += i; maxlen -= i; - + if (maxlen < 4) return -1; - + dest[0] = (q->qtype & 0xff00) >> 8; dest[1] = (q->qtype & 0x00ff) >> 0; dest[2] = (q->qclass & 0xff00) >> 8; dest[3] = (q->qclass & 0x00ff) >> 0; - - return i+4; + + return i + 4; } #endif #ifdef L_decodeq -int decode_question(unsigned char * message, int offset, - struct resolv_question * q) +int decode_question(unsigned char *message, int offset, + struct resolv_question *q) { char temp[256]; int i; @@ -222,46 +219,45 @@ int decode_question(unsigned char * message, int offset, i = decode_dotted(message, offset, temp, 256); if (i < 0) return i; - + offset += i; - + q->dotted = strdup(temp); - q->qtype = (message[offset+0] << 8) | message[offset+1]; - q->qclass = (message[offset+2] << 8) | message[offset+3]; - - return i+4; + q->qtype = (message[offset + 0] << 8) | message[offset + 1]; + q->qclass = (message[offset + 2] << 8) | message[offset + 3]; + + return i + 4; } #endif #ifdef L_lengthq -int length_question(unsigned char * message, int offset) +int length_question(unsigned char *message, int offset) { int i; i = length_dotted(message, offset); if (i < 0) return i; - - return i+4; + + return i + 4; } #endif #ifdef L_encodea -int encode_answer(struct resolv_answer * a, - unsigned char * dest, int maxlen) +int encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen) { int i; i = encode_dotted(a->dotted, dest, maxlen); if (i < 0) return i; - + dest += i; maxlen -= i; - - if (maxlen < (10+a->rdlength)) + + if (maxlen < (10 + a->rdlength)) return -1; - + *dest++ = (a->atype & 0xff00) >> 8; *dest++ = (a->atype & 0x00ff) >> 0; *dest++ = (a->aclass & 0xff00) >> 8; @@ -273,14 +269,14 @@ int encode_answer(struct resolv_answer * a, *dest++ = (a->rdlength & 0xff00) >> 8; *dest++ = (a->rdlength & 0x00ff) >> 0; memcpy(dest, a->rdata, a->rdlength); - - return i+10+a->rdlength; + + return i + 10 + a->rdlength; } #endif #ifdef L_decodea -int decode_answer(unsigned char * message, int offset, - struct resolv_answer * a) +int decode_answer(unsigned char *message, int offset, + struct resolv_answer *a) { char temp[256]; int i; @@ -288,47 +284,48 @@ int decode_answer(unsigned char * message, int offset, i = decode_dotted(message, offset, temp, 256); if (i < 0) return i; - - message += offset+i; - + + message += offset + i; + a->dotted = strdup(temp); - a->atype = (message[0] << 8) | message[1]; message += 2; - a->aclass = (message[0] << 8) | message[1]; message += 2; + a->atype = (message[0] << 8) | message[1]; + message += 2; + a->aclass = (message[0] << 8) | message[1]; + message += 2; a->ttl = (message[0] << 24) | - (message[1] << 16) | - (message[2] << 8) | - (message[3] << 0); + (message[1] << 16) | (message[2] << 8) | (message[3] << 0); message += 4; - a->rdlength = (message[0] << 8) | message[1]; message += 2; + a->rdlength = (message[0] << 8) | message[1]; + message += 2; a->rdata = message; - a->rdoffset = offset+i+10; - + a->rdoffset = offset + i + 10; + DPRINTF("i=%d,rdlength=%d\n", i, a->rdlength); - - return i+10+a->rdlength; + + return i + 10 + a->rdlength; } #endif #ifdef L_encodep -int encode_packet(struct resolv_header * h, - struct resolv_question ** q, - struct resolv_answer ** an, - struct resolv_answer ** ns, - struct resolv_answer ** ar, - unsigned char * dest, int maxlen) +int encode_packet(struct resolv_header *h, + struct resolv_question **q, + struct resolv_answer **an, + struct resolv_answer **ns, + struct resolv_answer **ar, + unsigned char *dest, int maxlen) { - int i, total=0; + int i, total = 0; int j; i = encode_header(h, dest, maxlen); if (i < 0) return i; - + dest += i; maxlen -= i; total += i; - - for(j=0;jqdcount;j++) { + + for (j = 0; j < h->qdcount; j++) { i = encode_question(q[j], dest, maxlen); if (i < 0) return i; @@ -337,7 +334,7 @@ int encode_packet(struct resolv_header * h, total += i; } - for(j=0;jancount;j++) { + for (j = 0; j < h->ancount; j++) { i = encode_answer(an[j], dest, maxlen); if (i < 0) return i; @@ -345,7 +342,7 @@ int encode_packet(struct resolv_header * h, maxlen -= i; total += i; } - for(j=0;jnscount;j++) { + for (j = 0; j < h->nscount; j++) { i = encode_answer(ns[j], dest, maxlen); if (i < 0) return i; @@ -353,7 +350,7 @@ int encode_packet(struct resolv_header * h, maxlen -= i; total += i; } - for(j=0;jarcount;j++) { + for (j = 0; j < h->arcount; j++) { i = encode_answer(ar[j], dest, maxlen); if (i < 0) return i; @@ -361,57 +358,59 @@ int encode_packet(struct resolv_header * h, maxlen -= i; total += i; } - + return total; } #endif #ifdef L_decodep -int decode_packet(unsigned char * data, struct resolv_header * h) +int decode_packet(unsigned char *data, struct resolv_header *h) { return decode_header(data, h); } #endif #ifdef L_formquery -int form_query(int id, const char * name, int type, unsigned char * packet, int maxlen) +int form_query(int id, const char *name, int type, unsigned char *packet, + int maxlen) { struct resolv_header h; struct resolv_question q; - int i,j; - + int i, j; + memset(&h, 0, sizeof(h)); h.id = id; h.qdcount = 1; - - q.dotted = (char*)name; + + q.dotted = (char *) name; q.qtype = type; - q.qclass = 1 /*CLASS_IN*/; - + q.qclass = 1 /*CLASS_IN */ ; + i = encode_header(&h, packet, maxlen); if (i < 0) return i; - - j = encode_question(&q, packet+i, maxlen-i); + + j = encode_question(&q, packet + i, maxlen - i); if (j < 0) return j; - return i+j; + return i + j; } #endif #ifdef L_dnslookup int dns_caught_signal = 0; -void dns_catch_signal(int signo) { +void dns_catch_signal(int signo) +{ dns_caught_signal = 1; -} +} -int dns_lookup(const char * name, int type, int nscount, const char ** nsip, - unsigned char ** outpacket, struct resolv_answer * a) +int dns_lookup(const char *name, int type, int nscount, const char **nsip, + unsigned char **outpacket, struct resolv_answer *a) { - static int id=1; - int i,j,len; + static int id = 1; + int i, j, len; int fd; int pos; static int ns = 0; @@ -421,63 +420,63 @@ int dns_lookup(const char * name, int type, int nscount, const char ** nsip, struct resolv_header h; struct resolv_question q; int retries = 0; - unsigned char * packet = malloc(512); - + unsigned char *packet = malloc(512); + if (!packet) goto fail1; - + DPRINTF("Looking up type %d answer for '%s'\n", type, name); - + if (!nscount) goto fail1; - + ns %= nscount; - + fd = -1; - + while (retries++ < MAX_RETRIES) { - + if (fd != -1) close(fd); fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - - if (fd==-1) + + if (fd == -1) goto fail2; - - + + memset(packet, 0, 512); memset(&h, 0, sizeof(h)); h.id = ++id; h.qdcount = 1; h.rd = 1; - + DPRINTF("encoding header\n"); i = encode_header(&h, packet, 512); if (i < 0) goto fail3; - q.dotted = (char*)name; + q.dotted = (char *) name; q.qtype = type; - q.qclass = 1 /*CLASS_IN*/; - - j = encode_question(&q, packet+i, 512-i); + q.qclass = 1 /*CLASS_IN */ ; + + j = encode_question(&q, packet + i, 512 - i); if (j < 0) goto fail3; - - len = i+j; + + len = i + j; DPRINTF("On try %d, sending query to port %d of machine %s\n", - retries, DNS_SERVICE, nsip[ns]); + retries, DNS_SERVICE, nsip[ns]); sa.sin_family = AF_INET; sa.sin_port = htons(DNS_SERVICE); sa.sin_addr.s_addr = inet_addr(nsip[ns]); - if (connect(fd, (struct sockaddr*)&sa, sizeof(sa))==-1) { + if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) { if (errno == ENETUNREACH) { /* routing error, presume not transient */ goto tryall; @@ -485,57 +484,55 @@ int dns_lookup(const char * name, int type, int nscount, const char ** nsip, /* retry */ break; } - - DPRINTF("Transmitting packet of length %d, id=%d, qr=%d\n", - len, h.id, h.qr); + + DPRINTF("Transmitting packet of length %d, id=%d, qr=%d\n", + len, h.id, h.qr); send(fd, packet, len, 0); dns_caught_signal = 0; oldalarm = alarm(REPLY_TIMEOUT); oldhandler = signal(SIGALRM, dns_catch_signal); - + i = recv(fd, packet, 512, 0); - + alarm(0); signal(SIGALRM, oldhandler); alarm(oldalarm); - - DPRINTF("Timeout=%d, len=%d\n", - dns_caught_signal, i); - + + DPRINTF("Timeout=%d, len=%d\n", dns_caught_signal, i); + if (dns_caught_signal) /* timed out, so retry send and receive, to next nameserver on queue */ goto again; - + if (i < 12) /* too short ! */ goto again; - + decode_header(packet, &h); - - DPRINTF("id = %d, qr = %d\n", - h.id, h.qr); - + + DPRINTF("id = %d, qr = %d\n", h.id, h.qr); + if ((h.id != id) || (!h.qr)) /* unsolicited */ goto again; - + DPRINTF("Got response (i think)!\n"); DPRINTF("qrcount=%d,ancount=%d,nscount=%d,arcount=%d\n", - h.qdcount, h.ancount, h.nscount, h.arcount); + h.qdcount, h.ancount, h.nscount, h.arcount); DPRINTF("opcode=%d,aa=%d,tc=%d,rd=%d,ra=%d,rcode=%d\n", - h.opcode,h.aa,h.tc,h.rd,h.ra,h.rcode); - + h.opcode, h.aa, h.tc, h.rd, h.ra, h.rcode); + if ((h.rcode) || (h.ancount < 1)) { /* negative result, not present */ goto tryall; } - + pos = 12; - for(j=0;jdotted); DPRINTF("Answer type = |%d|\n", a->atype); - + close(fd); - + if (outpacket) *outpacket = packet; else free(packet); - return (0); /* success! */ + return (0); /* success! */ - tryall: + tryall: /* if there are other nameservers, give them a go, otherwise return with error */ if (retries >= nscount) break; - again: + again: ns = (ns + 1) % nscount; continue; } - - -fail3: + + + fail3: close(fd); -fail2: + fail2: free(packet); -fail1: + fail1: return -1; } #endif #ifdef L_resolveaddress -int resolve_address(const char * address, - int nscount, const char ** nsip, - struct in_addr * in) +int resolve_address(const char *address, + int nscount, const char **nsip, struct in_addr *in) { - unsigned char * packet; + unsigned char *packet; struct resolv_answer a; char temp[256]; int i; - int nest=0; - + int nest = 0; + if (!address || !in) return -1; - + strcpy(temp, address); - - for(;;) { - + + for (;;) { + i = dns_lookup(temp, 1, nscount, nsip, &packet, &a); - - if (i<0) + + if (i < 0) return -1; - + free(a.dotted); - - if (a.atype == 5) { /* CNAME*/ + + if (a.atype == 5) { /* CNAME */ i = decode_dotted(packet, a.rdoffset, temp, 256); free(packet); - - if (i <0) + + if (i < 0) return -1; if (++nest > MAX_RECURSE) return -1; continue; - } else if (a.atype == 1) { /* ADDRESS */ + } else if (a.atype == 1) { /* ADDRESS */ free(packet); break; } else { @@ -627,57 +623,56 @@ int resolve_address(const char * address, return -1; } } - + if (in) memcpy(in, a.rdata, 4); - + return 0; } #endif #ifdef L_resolvemailbox -int resolve_mailbox(const char * address, - int nscount, const char ** nsip, - struct in_addr * in) +int resolve_mailbox(const char *address, + int nscount, const char **nsip, struct in_addr *in) { struct resolv_answer a; - unsigned char * packet; + unsigned char *packet; char temp[256]; - int nest=0; + int nest = 0; int i; - + if (!address || !in) return -1; - + /* look up mail exchange */ i = dns_lookup(address, 15, nscount, nsip, &packet, &a); - + strcpy(temp, address); - - if (i>=0) { - i = decode_dotted(packet, a.rdoffset+2, temp, 256); + + if (i >= 0) { + i = decode_dotted(packet, a.rdoffset + 2, temp, 256); free(packet); } - - for(;;) { - + + for (;;) { + i = dns_lookup(temp, 1, nscount, nsip, &packet, &a); - - if (i<0) + + if (i < 0) return -1; - + free(a.dotted); - - if (a.atype == 5) { /* CNAME*/ + + if (a.atype == 5) { /* CNAME */ i = decode_dotted(packet, a.rdoffset, temp, 256); free(packet); - if (i<0) + if (i < 0) return i; if (++nest > MAX_RECURSE) return -1; continue; - } else if (a.atype == 1) { /* ADDRESS */ + } else if (a.atype == 1) { /* ADDRESS */ free(packet); break; } else { @@ -688,7 +683,7 @@ int resolve_mailbox(const char * address, if (in) memcpy(in, a.rdata, 4); - + return 0; } #endif @@ -709,7 +704,7 @@ int open_nameservers() if ((fp = fopen("/etc/resolv.conf", "r"))) { if ((arg = cfgfind(fp, "nameserver"))) { - for (i=1; arg[i]; i++) { + for (i = 1; arg[i]; i++) { nameserver[nameservers++] = strdup(arg[i]); } } @@ -720,9 +715,10 @@ int open_nameservers() #endif #ifdef L_closenameservers -void close_nameservers(void) { +void close_nameservers(void) +{ - while(nameservers>0) + while (nameservers > 0) free(nameserver[--nameservers]); } #endif @@ -730,85 +726,85 @@ void close_nameservers(void) { #ifdef L_resolvename -const char * resolve_name(const char * name, int mailbox) +const char *resolve_name(const char *name, int mailbox) { struct in_addr in; int i; - + /* shortcut: is it a valid IP address to begin with? */ if (inet_aton(name, &in)) return name; - + open_nameservers(); - + DPRINTF("looking up '%s', mailbox=%d, nameservers=%d\n", - name, mailbox, nameservers); - + name, mailbox, nameservers); + if (mailbox) i = resolve_mailbox(name, nameservers, nameserver, &in); else i = resolve_address(name, nameservers, nameserver, &in); - - if (i<0) + + if (i < 0) return 0; - + DPRINTF("success = '%s'\n", inet_ntoa(in)); - + return inet_ntoa(in); } #endif #ifdef L_gethostbyname -struct hostent * gethostbyname(const char * name) +struct hostent *gethostbyname(const char *name) { static struct hostent h; static char namebuf[256]; static struct in_addr in; static struct in_addr *addr_list[2]; - unsigned char * packet; + unsigned char *packet; struct resolv_answer a; int i; - int nest=0; + int nest = 0; open_nameservers(); - + if (!name) return 0; - + memset(&h, 0, sizeof(h)); - + addr_list[0] = ∈ addr_list[1] = 0; - + strcpy(namebuf, name); - - for(;;) { - + + for (;;) { + i = dns_lookup(namebuf, 1, nameservers, nameserver, &packet, &a); - - if (i<0) + + if (i < 0) return 0; - + strcpy(namebuf, a.dotted); free(a.dotted); - - - if (a.atype == 5) { /* CNAME*/ + + + if (a.atype == 5) { /* CNAME */ i = decode_dotted(packet, a.rdoffset, namebuf, 256); free(packet); - - if (i <0) + + if (i < 0) return 0; if (++nest > MAX_RECURSE) return 0; continue; - } else if (a.atype == 1) { /* ADDRESS */ + } else if (a.atype == 1) { /* ADDRESS */ memcpy(&in, a.rdata, sizeof(in)); h.h_name = namebuf; h.h_addrtype = AF_INET; h.h_length = sizeof(in); - h.h_addr_list = (char**)addr_list; + h.h_addr_list = (char **) addr_list; free(packet); break; } else { @@ -816,77 +812,75 @@ struct hostent * gethostbyname(const char * name) return 0; } } - + return &h; } #endif #ifdef L_gethostbyaddr -struct hostent * gethostbyaddr(const char * addr, int len, int type) +struct hostent *gethostbyaddr(const char *addr, int len, int type) { static struct hostent h; static char namebuf[256]; static struct in_addr in; static struct in_addr *addr_list[2]; - unsigned char * packet; + unsigned char *packet; struct resolv_answer a; int i; - int nest=0; - + int nest = 0; + if (!addr || (len != sizeof(in)) || (type != AF_INET)) return 0; - + memcpy(&in.s_addr, addr, len); open_nameservers(); - + memset(&h, 0, sizeof(h)); - + addr_list[0] = ∈ addr_list[1] = 0; - + sprintf(namebuf, "%d.%d.%d.%d.in-addr.arpa", - (in.s_addr >> 24) & 0xff, - (in.s_addr >> 16) & 0xff, - (in.s_addr >> 8) & 0xff, - (in.s_addr >> 0) & 0xff - ); - - for(;;) { - + (in.s_addr >> 24) & 0xff, + (in.s_addr >> 16) & 0xff, + (in.s_addr >> 8) & 0xff, (in.s_addr >> 0) & 0xff); + + for (;;) { + i = dns_lookup(namebuf, 12, nameservers, nameserver, &packet, &a); - - if (i<0) + + if (i < 0) return 0; - + strcpy(namebuf, a.dotted); free(a.dotted); - - if (a.atype == 5) { /* CNAME*/ + + if (a.atype == 5) { /* CNAME */ i = decode_dotted(packet, a.rdoffset, namebuf, 256); free(packet); - - if (i <0) + + if (i < 0) return 0; if (++nest > MAX_RECURSE) return 0; continue; - } else if (a.atype == 12) { /* ADDRESS */ + } else if (a.atype == 12) { /* ADDRESS */ i = decode_dotted(packet, a.rdoffset, namebuf, 256); free(packet); - + h.h_name = namebuf; h.h_addrtype = AF_INET; h.h_length = sizeof(in); - h.h_addr_list = (char**)addr_list; + h.h_addr_list = (char **) addr_list; break; } else { free(packet); return 0; } } - + return &h; } #endif diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c index 630037fb4..7a4dffe87 100644 --- a/libc/inet/rpc/auth_none.c +++ b/libc/inet/rpc/auth_none.c @@ -28,7 +28,9 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; +static char sccsid[] = + + "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* @@ -47,11 +49,11 @@ static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; /* * Authenticator operations routines */ -static void authnone_verf(); -static void authnone_destroy(); -static bool_t authnone_marshal(); -static bool_t authnone_validate(); -static bool_t authnone_refresh(); +static void authnone_verf(); +static void authnone_destroy(); +static bool_t authnone_marshal(); +static bool_t authnone_validate(); +static bool_t authnone_refresh(); static struct auth_ops ops = { authnone_verf, @@ -62,20 +64,19 @@ static struct auth_ops ops = { }; static struct authnone_private { - AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; - u_int mcnt; + AUTH no_client; + char marshalled_client[MAX_MARSHEL_SIZE]; + u_int mcnt; } *authnone_private; -AUTH * -authnone_create() +AUTH *authnone_create() { register struct authnone_private *ap = authnone_private; XDR xdr_stream; register XDR *xdrs; if (ap == 0) { - ap = (struct authnone_private *)calloc(1, sizeof (*ap)); + ap = (struct authnone_private *) calloc(1, sizeof(*ap)); if (ap == 0) return (0); authnone_private = ap; @@ -84,50 +85,44 @@ authnone_create() ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; ap->no_client.ah_ops = &ops; xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, - XDR_ENCODE); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); - (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); + xdrmem_create(xdrs, ap->marshalled_client, + (u_int) MAX_MARSHEL_SIZE, XDR_ENCODE); + (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); + (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); ap->mcnt = XDR_GETPOS(xdrs); XDR_DESTROY(xdrs); } return (&ap->no_client); } -/*ARGSUSED*/ -static bool_t -authnone_marshal(client, xdrs) - AUTH *client; - XDR *xdrs; + /*ARGSUSED*/ static bool_t authnone_marshal(client, xdrs) +AUTH *client; +XDR *xdrs; { register struct authnone_private *ap = authnone_private; if (ap == 0) return (0); - return ((*xdrs->x_ops->x_putbytes)(xdrs, - ap->marshalled_client, ap->mcnt)); + return ((*xdrs->x_ops->x_putbytes) (xdrs, + ap->marshalled_client, ap->mcnt)); } -static void -authnone_verf() +static void authnone_verf() { } -static bool_t -authnone_validate() +static bool_t authnone_validate() { return (TRUE); } -static bool_t -authnone_refresh() +static bool_t authnone_refresh() { return (FALSE); } -static void -authnone_destroy() +static void authnone_destroy() { } diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c index ffdfa11a0..dcd7df98f 100644 --- a/libc/inet/rpc/auth_unix.c +++ b/libc/inet/rpc/auth_unix.c @@ -28,7 +28,9 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; +static char sccsid[] = + + "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* @@ -56,11 +58,11 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; /* * Unix authenticator operations vector */ -static void authunix_nextverf(); -static bool_t authunix_marshal(); -static bool_t authunix_validate(); -static bool_t authunix_refresh(); -static void authunix_destroy(); +static void authunix_nextverf(); +static bool_t authunix_marshal(); +static bool_t authunix_validate(); +static bool_t authunix_refresh(); +static void authunix_destroy(); static struct auth_ops auth_unix_ops = { authunix_nextverf, @@ -74,12 +76,13 @@ static struct auth_ops auth_unix_ops = { * This struct is pointed to by the ah_private field of an auth_handle. */ struct audata { - struct opaque_auth au_origcred; /* original credentials */ - struct opaque_auth au_shcred; /* short hand cred */ - u_long au_shfaults; /* short hand cache faults */ - char au_marshed[MAX_AUTH_BYTES]; - u_int au_mpos; /* xdr pos at end of marshed */ + struct opaque_auth au_origcred; /* original credentials */ + struct opaque_auth au_shcred; /* short hand cred */ + u_long au_shfaults; /* short hand cache faults */ + char au_marshed[MAX_AUTH_BYTES]; + u_int au_mpos; /* xdr pos at end of marshed */ }; + #define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) static bool_t marshal_new_auth(); @@ -89,13 +92,12 @@ static bool_t marshal_new_auth(); * Create a unix style authenticator. * Returns an auth handle with the given stuff in it. */ -AUTH * -authunix_create(machname, uid, gid, len, aup_gids) - char *machname; - int uid; - int gid; - register int len; - int *aup_gids; +AUTH *authunix_create(machname, uid, gid, len, aup_gids) +char *machname; +int uid; +int gid; +register int len; +int *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -107,41 +109,41 @@ authunix_create(machname, uid, gid, len, aup_gids) /* * Allocate and set up auth handle */ - auth = (AUTH *)mem_alloc(sizeof(*auth)); + auth = (AUTH *) mem_alloc(sizeof(*auth)); #ifndef KERNEL if (auth == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); + (void) fprintf(stderr, "authunix_create: out of memory\n"); return (NULL); } #endif - au = (struct audata *)mem_alloc(sizeof(*au)); + au = (struct audata *) mem_alloc(sizeof(*au)); #ifndef KERNEL if (au == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); + (void) fprintf(stderr, "authunix_create: out of memory\n"); return (NULL); } #endif auth->ah_ops = &auth_unix_ops; - auth->ah_private = (caddr_t)au; + auth->ah_private = (caddr_t) au; auth->ah_verf = au->au_shcred = _null_auth; au->au_shfaults = 0; /* * fill in param struct from the given params */ - (void)gettimeofday(&now, (struct timezone *)0); + (void) gettimeofday(&now, (struct timezone *) 0); aup.aup_time = now.tv_sec; aup.aup_machname = machname; aup.aup_uid = uid; aup.aup_gid = gid; - aup.aup_len = (u_int)len; + aup.aup_len = (u_int) len; aup.aup_gids = aup_gids; /* * Serialize the parameters into origcred */ xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); - if (! xdr_authunix_parms(&xdrs, &aup)) + if (!xdr_authunix_parms(&xdrs, &aup)) abort(); au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); au->au_origcred.oa_flavor = AUTH_UNIX; @@ -149,11 +151,11 @@ authunix_create(machname, uid, gid, len, aup_gids) au->au_origcred.oa_base = mem_alloc((u_int) len); #else if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { - (void)fprintf(stderr, "authunix_create: out of memory\n"); + (void) fprintf(stderr, "authunix_create: out of memory\n"); return (NULL); } #endif - bcopy(mymem, au->au_origcred.oa_base, (u_int)len); + bcopy(mymem, au->au_origcred.oa_base, (u_int) len); /* * set auth handle to reflect new cred. @@ -167,8 +169,7 @@ authunix_create(machname, uid, gid, len, aup_gids) * Returns an auth handle with parameters determined by doing lots of * syscalls. */ -AUTH * -authunix_create_default() +AUTH *authunix_create_default() { register int len; char machname[MAX_MACHINE_NAME + 1]; @@ -190,27 +191,24 @@ authunix_create_default() * authunix operations */ -static void -authunix_nextverf(auth) - AUTH *auth; +static void authunix_nextverf(auth) +AUTH *auth; { /* no action necessary */ } -static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; +static bool_t authunix_marshal(auth, xdrs) +AUTH *auth; +XDR *xdrs; { register struct audata *au = AUTH_PRIVATE(auth); return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); } -static bool_t -authunix_validate(auth, verf) - register AUTH *auth; - struct opaque_auth verf; +static bool_t authunix_validate(auth, verf) +register AUTH *auth; +struct opaque_auth verf; { register struct audata *au; XDR xdrs; @@ -220,15 +218,14 @@ authunix_validate(auth, verf) xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE); if (au->au_shcred.oa_base != NULL) { - mem_free(au->au_shcred.oa_base, - au->au_shcred.oa_length); + mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); au->au_shcred.oa_base = NULL; } if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { auth->ah_cred = au->au_shcred; } else { xdrs.x_op = XDR_FREE; - (void)xdr_opaque_auth(&xdrs, &au->au_shcred); + (void) xdr_opaque_auth(&xdrs, &au->au_shcred); au->au_shcred.oa_base = NULL; auth->ah_cred = au->au_origcred; } @@ -237,9 +234,8 @@ authunix_validate(auth, verf) return (TRUE); } -static bool_t -authunix_refresh(auth) - register AUTH *auth; +static bool_t authunix_refresh(auth) +register AUTH *auth; { register struct audata *au = AUTH_PRIVATE(auth); struct authunix_parms aup; @@ -251,38 +247,37 @@ authunix_refresh(auth) /* there is no hope. Punt */ return (FALSE); } - au->au_shfaults ++; + au->au_shfaults++; /* first deserialize the creds back into a struct authunix_parms */ aup.aup_machname = NULL; - aup.aup_gids = (int *)NULL; + aup.aup_gids = (int *) NULL; xdrmem_create(&xdrs, au->au_origcred.oa_base, - au->au_origcred.oa_length, XDR_DECODE); + au->au_origcred.oa_length, XDR_DECODE); stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) + if (!stat) goto done; /* update the time and serialize in place */ - (void)gettimeofday(&now, (struct timezone *)0); + (void) gettimeofday(&now, (struct timezone *) 0); aup.aup_time = now.tv_sec; xdrs.x_op = XDR_ENCODE; XDR_SETPOS(&xdrs, 0); stat = xdr_authunix_parms(&xdrs, &aup); - if (! stat) + if (!stat) goto done; auth->ah_cred = au->au_origcred; marshal_new_auth(auth); -done: + done: /* free the struct authunix_parms created by deserializing */ xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, &aup); + (void) xdr_authunix_parms(&xdrs, &aup); XDR_DESTROY(&xdrs); return (stat); } -static void -authunix_destroy(auth) - register AUTH *auth; +static void authunix_destroy(auth) +register AUTH *auth; { register struct audata *au = AUTH_PRIVATE(auth); @@ -296,24 +291,23 @@ authunix_destroy(auth) if (auth->ah_verf.oa_base != NULL) mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); - mem_free((caddr_t)auth, sizeof(*auth)); + mem_free((caddr_t) auth, sizeof(*auth)); } /* * Marshals (pre-serializes) an auth struct. * sets private data, au_marshed and au_mpos */ -static bool_t -marshal_new_auth(auth) - register AUTH *auth; +static bool_t marshal_new_auth(auth) +register AUTH *auth; { - XDR xdr_stream; - register XDR *xdrs = &xdr_stream; + XDR xdr_stream; + register XDR *xdrs = &xdr_stream; register struct audata *au = AUTH_PRIVATE(auth); xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); - if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || - (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { + if ((!xdr_opaque_auth(xdrs, &(auth->ah_cred))) || + (!xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { perror("auth_none.c - Fatal marshalling problem"); } else { au->au_mpos = XDR_GETPOS(xdrs); diff --git a/libc/inet/rpc/authunix_prot.c b/libc/inet/rpc/authunix_prot.c index a60d99a57..cae173571 100644 --- a/libc/inet/rpc/authunix_prot.c +++ b/libc/inet/rpc/authunix_prot.c @@ -28,7 +28,9 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; +static char sccsid[] = + + "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; #endif /* @@ -47,20 +49,18 @@ static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; /* * XDR for unix authentication parameters. */ -bool_t -xdr_authunix_parms(xdrs, p) - register XDR *xdrs; - register struct authunix_parms *p; +bool_t xdr_authunix_parms(xdrs, p) +register XDR *xdrs; +register struct authunix_parms *p; { if (xdr_u_long(xdrs, &(p->aup_time)) - && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_int(xdrs, &(p->aup_uid)) - && xdr_int(xdrs, &(p->aup_gid)) - && xdr_array(xdrs, (caddr_t *)&(p->aup_gids), - &(p->aup_len), NGRPS, sizeof(int), xdr_int) ) { + && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) + && xdr_int(xdrs, &(p->aup_uid)) + && xdr_int(xdrs, &(p->aup_gid)) + && xdr_array(xdrs, (caddr_t *) & (p->aup_gids), + &(p->aup_len), NGRPS, sizeof(int), xdr_int)) { return (TRUE); } return (FALSE); } - diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c index 71803dd41..6a6f385cd 100644 --- a/libc/inet/rpc/bindresvport.c +++ b/libc/inet/rpc/bindresvport.c @@ -1,4 +1,6 @@ -static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; +static char sccsid[] = + + "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -41,8 +43,8 @@ static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 * Bind a socket to a privileged IP port */ bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; +int sd; +struct sockaddr_in *sin; { int res; static short port; @@ -54,9 +56,9 @@ bindresvport(sd, sin) #define ENDPORT (IPPORT_RESERVED - 1) #define NPORTS (ENDPORT - STARTPORT + 1) - if (sin == (struct sockaddr_in *)0) { + if (sin == (struct sockaddr_in *) 0) { sin = &myaddr; - bzero(sin, sizeof (*sin)); + bzero(sin, sizeof(*sin)); sin->sin_family = AF_INET; } else if (sin->sin_family != AF_INET) { errno = EPFNOSUPPORT; diff --git a/libc/inet/rpc/clnt_generic.c b/libc/inet/rpc/clnt_generic.c index fabcc2b32..ba5309492 100644 --- a/libc/inet/rpc/clnt_generic.c +++ b/libc/inet/rpc/clnt_generic.c @@ -43,12 +43,11 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; * returns client handle. Default options are set, which the user can * change using the rpc equivalent of ioctl()'s. */ -CLIENT * -clnt_create(hostname, prog, vers, proto) - char *hostname; - unsigned prog; - unsigned vers; - char *proto; +CLIENT *clnt_create(hostname, prog, vers, proto) +char *hostname; +unsigned prog; +unsigned vers; +char *proto; { struct hostent *h; struct protoent *p; @@ -67,7 +66,7 @@ clnt_create(hostname, prog, vers, proto) * Only support INET for now */ rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; + rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; return (NULL); } #ifdef __linux__ @@ -78,11 +77,11 @@ clnt_create(hostname, prog, vers, proto) #ifndef __linux__ bzero(sin.sin_zero, sizeof(sin.sin_zero)); #endif - bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); + bcopy(h->h_addr, (char *) &sin.sin_addr, h->h_length); p = getprotobyname(proto); if (p == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; return (NULL); } sock = RPC_ANYSOCK; @@ -108,7 +107,7 @@ clnt_create(hostname, prog, vers, proto) break; default: rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; return (NULL); } return (client); diff --git a/libc/inet/rpc/clnt_perror.c b/libc/inet/rpc/clnt_perror.c index 80f51aa79..84d2658ee 100644 --- a/libc/inet/rpc/clnt_perror.c +++ b/libc/inet/rpc/clnt_perror.c @@ -28,7 +28,9 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; +static char sccsid[] = + + "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; #endif /* @@ -50,22 +52,20 @@ extern char *strcpy(); static char *buf; -static char * -_buf() +static char *_buf() { if (buf == 0) - buf = (char *)malloc(256); + buf = (char *) malloc(256); return (buf); } /* * Print reply error info */ -char * -clnt_sperror(rpch, s) - CLIENT *rpch; - char *s; +char *clnt_sperror(rpch, s) +CLIENT *rpch; +char *s; { #if 0 struct rpc_err e; @@ -78,17 +78,17 @@ clnt_sperror(rpch, s) return (0); CLNT_GETERR(rpch, &e); - (void) sprintf(str, "%s: ", s); + (void) sprintf(str, "%s: ", s); str += strlen(str); - (void) strcpy(str, clnt_sperrno(e.re_status)); + (void) strcpy(str, clnt_sperrno(e.re_status)); str += strlen(str); switch (e.re_status) { case RPC_SUCCESS: case RPC_CANTENCODEARGS: case RPC_CANTDECODERES: - case RPC_TIMEDOUT: + case RPC_TIMEDOUT: case RPC_PROGUNAVAIL: case RPC_PROCUNAVAIL: case RPC_CANTDECODEARGS: @@ -102,57 +102,54 @@ clnt_sperror(rpch, s) case RPC_CANTSEND: case RPC_CANTRECV: - (void) sprintf(str, "; errno = %s", - sys_errlist[e.re_errno]); + (void) sprintf(str, "; errno = %s", sys_errlist[e.re_errno]); str += strlen(str); break; case RPC_VERSMISMATCH: (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); + "; low version = %lu, high version = %lu", + e.re_vers.low, e.re_vers.high); str += strlen(str); break; case RPC_AUTHERROR: err = auth_errmsg(e.re_why); - (void) sprintf(str,"; why = "); + (void) sprintf(str, "; why = "); str += strlen(str); if (err != NULL) { - (void) sprintf(str, "%s",err); + (void) sprintf(str, "%s", err); } else { (void) sprintf(str, - "(unknown authentication error - %d)", - (int) e.re_why); + "(unknown authentication error - %d)", + (int) e.re_why); } str += strlen(str); break; case RPC_PROGVERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); + (void) sprintf(str, + "; low version = %lu, high version = %lu", + e.re_vers.low, e.re_vers.high); str += strlen(str); break; - default: /* unknown */ - (void) sprintf(str, - "; s1 = %lu, s2 = %lu", - e.re_lb.s1, e.re_lb.s2); + default: /* unknown */ + (void) sprintf(str, + "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2); str += strlen(str); break; } (void) sprintf(str, "\n"); - return(strstart) ; + return (strstart); #endif } -void -clnt_perror(rpch, s) - CLIENT *rpch; - char *s; +void clnt_perror(rpch, s) +CLIENT *rpch; +char *s; { - (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); + (void) fprintf(stderr, "%s", clnt_sperror(rpch, s)); } @@ -160,58 +157,58 @@ struct rpc_errtab { enum clnt_stat status; char *message; }; + #if 0 -static struct rpc_errtab rpc_errlist[] = { - { RPC_SUCCESS, - "RPC: Success" }, - { RPC_CANTENCODEARGS, - "RPC: Can't encode arguments" }, - { RPC_CANTDECODERES, - "RPC: Can't decode result" }, - { RPC_CANTSEND, - "RPC: Unable to send" }, - { RPC_CANTRECV, - "RPC: Unable to receive" }, - { RPC_TIMEDOUT, - "RPC: Timed out" }, - { RPC_VERSMISMATCH, - "RPC: Incompatible versions of RPC" }, - { RPC_AUTHERROR, - "RPC: Authentication error" }, - { RPC_PROGUNAVAIL, - "RPC: Program unavailable" }, - { RPC_PROGVERSMISMATCH, - "RPC: Program/version mismatch" }, - { RPC_PROCUNAVAIL, - "RPC: Procedure unavailable" }, - { RPC_CANTDECODEARGS, - "RPC: Server can't decode arguments" }, - { RPC_SYSTEMERROR, - "RPC: Remote system error" }, - { RPC_UNKNOWNHOST, - "RPC: Unknown host" }, - { RPC_UNKNOWNPROTO, - "RPC: Unknown protocol" }, - { RPC_PMAPFAILURE, - "RPC: Port mapper failure" }, - { RPC_PROGNOTREGISTERED, - "RPC: Program not registered"}, - { RPC_FAILED, - "RPC: Failed (unspecified error)"} +static struct rpc_errtab rpc_errlist[] = { + {RPC_SUCCESS, + "RPC: Success"}, + {RPC_CANTENCODEARGS, + "RPC: Can't encode arguments"}, + {RPC_CANTDECODERES, + "RPC: Can't decode result"}, + {RPC_CANTSEND, + "RPC: Unable to send"}, + {RPC_CANTRECV, + "RPC: Unable to receive"}, + {RPC_TIMEDOUT, + "RPC: Timed out"}, + {RPC_VERSMISMATCH, + "RPC: Incompatible versions of RPC"}, + {RPC_AUTHERROR, + "RPC: Authentication error"}, + {RPC_PROGUNAVAIL, + "RPC: Program unavailable"}, + {RPC_PROGVERSMISMATCH, + "RPC: Program/version mismatch"}, + {RPC_PROCUNAVAIL, + "RPC: Procedure unavailable"}, + {RPC_CANTDECODEARGS, + "RPC: Server can't decode arguments"}, + {RPC_SYSTEMERROR, + "RPC: Remote system error"}, + {RPC_UNKNOWNHOST, + "RPC: Unknown host"}, + {RPC_UNKNOWNPROTO, + "RPC: Unknown protocol"}, + {RPC_PMAPFAILURE, + "RPC: Port mapper failure"}, + {RPC_PROGNOTREGISTERED, + "RPC: Program not registered"}, + {RPC_FAILED, + "RPC: Failed (unspecified error)"} }; #endif /* * This interface for use by clntrpc */ -char * -clnt_sperrno(stat) - enum clnt_stat stat; +char *clnt_sperrno(stat) +enum clnt_stat stat; { #if 0 int i; - for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { + for (i = 0; i < sizeof(rpc_errlist) / sizeof(struct rpc_errtab); i++) { if (rpc_errlist[i].status == stat) { return (rpc_errlist[i].message); } @@ -220,17 +217,15 @@ clnt_sperrno(stat) return ("RPC: (unknown error code)"); } -void -clnt_perrno(num) - enum clnt_stat num; +void clnt_perrno(num) +enum clnt_stat num; { - (void) fprintf(stderr,"%s",clnt_sperrno(num)); + (void) fprintf(stderr, "%s", clnt_sperrno(num)); } -char * -clnt_spcreateerror(s) - char *s; +char *clnt_spcreateerror(s) +char *s; { #if 0 extern int sys_nerr; @@ -238,25 +233,24 @@ clnt_spcreateerror(s) char *str = _buf(); if (str == 0) - return(0); + return (0); (void) sprintf(str, "%s: ", s); (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); switch (rpc_createerr.cf_stat) { case RPC_PMAPFAILURE: (void) strcat(str, " - "); - (void) strcat(str, - clnt_sperrno(rpc_createerr.cf_error.re_status)); + (void) strcat(str, clnt_sperrno(rpc_createerr.cf_error.re_status)); break; case RPC_SYSTEMERROR: (void) strcat(str, " - "); if (rpc_createerr.cf_error.re_errno > 0 - && rpc_createerr.cf_error.re_errno < sys_nerr) + && rpc_createerr.cf_error.re_errno < sys_nerr) (void) strcat(str, - sys_errlist[rpc_createerr.cf_error.re_errno]); + sys_errlist[rpc_createerr.cf_error.re_errno]); else (void) sprintf(&str[strlen(str)], "Error %d", - rpc_createerr.cf_error.re_errno); + rpc_createerr.cf_error.re_errno); break; } (void) strcat(str, "\n"); @@ -264,47 +258,45 @@ clnt_spcreateerror(s) #endif } -void -clnt_pcreateerror(s) - char *s; +void clnt_pcreateerror(s) +char *s; { - (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); + (void) fprintf(stderr, "%s", clnt_spcreateerror(s)); } struct auth_errtab { - enum auth_stat status; + enum auth_stat status; char *message; }; static struct auth_errtab auth_errlist[] = { - { AUTH_OK, - "Authentication OK" }, - { AUTH_BADCRED, - "Invalid client credential" }, - { AUTH_REJECTEDCRED, - "Server rejected credential" }, - { AUTH_BADVERF, - "Invalid client verifier" }, - { AUTH_REJECTEDVERF, - "Server rejected verifier" }, - { AUTH_TOOWEAK, - "Client credential too weak" }, - { AUTH_INVALIDRESP, - "Invalid server verifier" }, - { AUTH_FAILED, - "Failed (unspecified error)" }, + {AUTH_OK, + "Authentication OK"}, + {AUTH_BADCRED, + "Invalid client credential"}, + {AUTH_REJECTEDCRED, + "Server rejected credential"}, + {AUTH_BADVERF, + "Invalid client verifier"}, + {AUTH_REJECTEDVERF, + "Server rejected verifier"}, + {AUTH_TOOWEAK, + "Client credential too weak"}, + {AUTH_INVALIDRESP, + "Invalid server verifier"}, + {AUTH_FAILED, + "Failed (unspecified error)"}, }; -static char * -auth_errmsg(stat) - enum auth_stat stat; +static char *auth_errmsg(stat) +enum auth_stat stat; { int i; - for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { + for (i = 0; i < sizeof(auth_errlist) / sizeof(struct auth_errtab); i++) { if (auth_errlist[i].status == stat) { - return(auth_errlist[i].message); + return (auth_errlist[i].message); } } - return(NULL); + return (NULL); } diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c index 89059ae2d..7479b55d6 100644 --- a/libc/inet/rpc/clnt_raw.c +++ b/libc/inet/rpc/clnt_raw.c @@ -50,19 +50,19 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; * This is the "network" we will be moving stuff over. */ static struct clntraw_private { - CLIENT client_object; - XDR xdr_stream; - char _raw_buf[UDPMSGSIZE]; - char mashl_callmsg[MCALL_MSG_SIZE]; - u_int mcnt; + CLIENT client_object; + XDR xdr_stream; + char _raw_buf[UDPMSGSIZE]; + char mashl_callmsg[MCALL_MSG_SIZE]; + u_int mcnt; } *clntraw_private; -static enum clnt_stat clntraw_call(); -static void clntraw_abort(); -static void clntraw_geterr(); -static bool_t clntraw_freeres(); -static bool_t clntraw_control(); -static void clntraw_destroy(); +static enum clnt_stat clntraw_call(); +static void clntraw_abort(); +static void clntraw_geterr(); +static bool_t clntraw_freeres(); +static bool_t clntraw_control(); +static void clntraw_destroy(); static struct clnt_ops client_ops = { clntraw_call, @@ -73,23 +73,22 @@ static struct clnt_ops client_ops = { clntraw_control }; -void svc_getreq(); +void svc_getreq(); /* * Create a client handle for memory based rpc. */ -CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; +CLIENT *clntraw_create(prog, vers) +u_long prog; +u_long vers; { register struct clntraw_private *clp = clntraw_private; struct rpc_msg call_msg; XDR *xdrs = &clp->xdr_stream; - CLIENT *client = &clp->client_object; + CLIENT *client = &clp->client_object; if (clp == 0) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); + clp = (struct clntraw_private *) calloc(1, sizeof(*clp)); if (clp == 0) return (0); clntraw_private = clp; @@ -101,8 +100,8 @@ clntraw_create(prog, vers) call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = prog; call_msg.rm_call.cb_vers = vers; - xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); - if (! xdr_callhdr(xdrs, &call_msg)) { + xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); + if (!xdr_callhdr(xdrs, &call_msg)) { perror("clnt_raw.c - Fatal header serialization error."); } clp->mcnt = XDR_GETPOS(xdrs); @@ -121,15 +120,15 @@ clntraw_create(prog, vers) return (client); } -static enum clnt_stat +static enum clnt_stat clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - u_long proc; - xdrproc_t xargs; - caddr_t argsp; - xdrproc_t xresults; - caddr_t resultsp; - struct timeval timeout; +CLIENT *h; +u_long proc; +xdrproc_t xargs; +caddr_t argsp; +xdrproc_t xresults; +caddr_t resultsp; +struct timeval timeout; { register struct clntraw_private *clp = clntraw_private; register XDR *xdrs = &clp->xdr_stream; @@ -139,20 +138,19 @@ clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) if (clp == 0) return (RPC_FAILED); -call_again: + call_again: /* * send request */ xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, 0); - ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; - if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) { + ((struct rpc_msg *) clp->mashl_callmsg)->rm_xid++; + if ((!XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || + (!XDR_PUTLONG(xdrs, (long *) &proc)) || + (!AUTH_MARSHALL(h->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp))) { return (RPC_CANTENCODEARGS); } - (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ + (void) XDR_GETPOS(xdrs); /* called just to cause overhead */ /* * We have to call server input routine here because this is @@ -168,71 +166,65 @@ call_again: msg.acpted_rply.ar_verf = _null_auth; msg.acpted_rply.ar_results.where = resultsp; msg.acpted_rply.ar_results.proc = xresults; - if (! xdr_replymsg(xdrs, &msg)) + if (!xdr_replymsg(xdrs, &msg)) return (RPC_CANTDECODERES); _seterr_reply(&msg, &error); status = error.re_status; if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { + if (!AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { status = RPC_AUTHERROR; } - } /* end successful completion */ + } /* end successful completion */ else { if (AUTH_REFRESH(h->cl_auth)) goto call_again; - } /* end of unsuccessful completion */ + } /* end of unsuccessful completion */ if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { + if (!AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { status = RPC_AUTHERROR; } if (msg.acpted_rply.ar_verf.oa_base != NULL) { xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); + (void) xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); } } return (status); } -static void -clntraw_geterr() +static void clntraw_geterr() { } -static bool_t -clntraw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; +static bool_t clntraw_freeres(cl, xdr_res, res_ptr) +CLIENT *cl; +xdrproc_t xdr_res; +caddr_t res_ptr; { register struct clntraw_private *clp = clntraw_private; register XDR *xdrs = &clp->xdr_stream; bool_t rval; - if (clp == 0) - { + if (clp == 0) { rval = (bool_t) RPC_FAILED; return (rval); } xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); + return ((*xdr_res) (xdrs, res_ptr)); } -static void -clntraw_abort() +static void clntraw_abort() { } -static bool_t -clntraw_control() +static bool_t clntraw_control() { return (FALSE); } -static void -clntraw_destroy() +static void clntraw_destroy() { } diff --git a/libc/inet/rpc/clnt_simple.c b/libc/inet/rpc/clnt_simple.c index 043ce0a3e..77657ecf3 100644 --- a/libc/inet/rpc/clnt_simple.c +++ b/libc/inet/rpc/clnt_simple.c @@ -28,7 +28,9 @@ * Mountain View, California 94043 */ #if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; +static char sccsid[] = + + "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #endif /* @@ -45,16 +47,16 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #include static struct callrpc_private { - CLIENT *client; - int socket; - int oldprognum, oldversnum, valid; - char *oldhost; + CLIENT *client; + int socket; + int oldprognum, oldversnum, valid; + char *oldhost; } *callrpc_private; callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - char *host; - xdrproc_t inproc, outproc; - char *in, *out; +char *host; +xdrproc_t inproc, outproc; +char *in, *out; { register struct callrpc_private *crp = callrpc_private; struct sockaddr_in server_addr; @@ -63,7 +65,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) struct timeval timeout, tottimeout; if (crp == 0) { - crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); + crp = (struct callrpc_private *) calloc(1, sizeof(*crp)); if (crp == 0) return (0); callrpc_private = crp; @@ -73,12 +75,12 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) crp->oldhost[0] = 0; crp->socket = RPC_ANYSOCK; } - if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum - && strcmp(crp->oldhost, host) == 0) { - /* reuse old client */ + if (crp->valid && crp->oldprognum == prognum + && crp->oldversnum == versnum && strcmp(crp->oldhost, host) == 0) { + /* reuse old client */ } else { crp->valid = 0; - (void)close(crp->socket); + (void) close(crp->socket); crp->socket = RPC_ANYSOCK; if (crp->client) { clnt_destroy(crp->client); @@ -88,11 +90,12 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) return ((int) RPC_UNKNOWNHOST); timeout.tv_usec = 0; timeout.tv_sec = 5; - bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); + bcopy(hp->h_addr, (char *) &server_addr.sin_addr, hp->h_length); server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, - (u_long)versnum, timeout, &crp->socket)) == NULL) + server_addr.sin_port = 0; + if ((crp->client = clntudp_create(&server_addr, (u_long) prognum, + (u_long) versnum, timeout, + &crp->socket)) == NULL) return ((int) rpc_createerr.cf_stat); crp->valid = 1; crp->oldprognum = prognum; @@ -102,7 +105,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) tottimeout.tv_sec = 25; tottimeout.tv_usec = 0; clnt_stat = clnt_call(crp->client, procnum, inproc, in, - outproc, out, tottimeout); + outproc, out, tottimeout); /* * if call failed, empty cache */ diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c index 2222bc657..30422268a 100644 --- a/libc/inet/rpc/clnt_tcp.c +++ b/libc/inet/rpc/clnt_tcp.c @@ -30,7 +30,7 @@ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #endif - + /* * clnt_tcp.c, Implements a TCP/IP based, client side RPC. * @@ -61,15 +61,15 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; extern int errno; -static int readtcp(); -static int writetcp(); +static int readtcp(); +static int writetcp(); -static enum clnt_stat clnttcp_call(); -static void clnttcp_abort(); -static void clnttcp_geterr(); -static bool_t clnttcp_freeres(); -static bool_t clnttcp_control(); -static void clnttcp_destroy(); +static enum clnt_stat clnttcp_call(); +static void clnttcp_abort(); +static void clnttcp_geterr(); +static bool_t clnttcp_freeres(); +static bool_t clnttcp_control(); +static void clnttcp_destroy(); static struct clnt_ops tcp_ops = { clnttcp_call, @@ -81,15 +81,15 @@ static struct clnt_ops tcp_ops = { }; struct ct_data { - int ct_sock; - bool_t ct_closeit; - struct timeval ct_wait; - bool_t ct_waitset; /* wait set by clnt_control? */ - struct sockaddr_in ct_addr; - struct rpc_err ct_error; - char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ - u_int ct_mpos; /* pos after marshal */ - XDR ct_xdrs; + int ct_sock; + bool_t ct_closeit; + struct timeval ct_wait; + bool_t ct_waitset; /* wait set by clnt_control? */ + struct sockaddr_in ct_addr; + struct rpc_err ct_error; + char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ + u_int ct_mpos; /* pos after marshal */ + XDR ct_xdrs; }; /* @@ -106,30 +106,29 @@ struct ct_data { * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this * something more useful. */ -CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - register int *sockp; - u_int sendsz; - u_int recvsz; +CLIENT *clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) +struct sockaddr_in *raddr; +u_long prog; +u_long vers; +register int *sockp; +u_int sendsz; +u_int recvsz; { CLIENT *h; register struct ct_data *ct; struct timeval now; struct rpc_msg call_msg; - h = (CLIENT *)mem_alloc(sizeof(*h)); + h = (CLIENT *) mem_alloc(sizeof(*h)); if (h == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); + (void) fprintf(stderr, "clnttcp_create: out of memory\n"); rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } - ct = (struct ct_data *)mem_alloc(sizeof(*ct)); + ct = (struct ct_data *) mem_alloc(sizeof(*ct)); if (ct == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); + (void) fprintf(st