summaryrefslogtreecommitdiff
path: root/libc/inet
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
committerEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
commitc1fe19d4c1db610692365472a90f4661e48449c1 (patch)
treed0b0219ffca3c4c4256f55c4aea4513e43d6aecd /libc/inet
parent9efafb8bbc7408b04643dcd53825d971577b4d9d (diff)
Bug ugly formatting update
Diffstat (limited to 'libc/inet')
-rw-r--r--libc/inet/.indent.pro33
-rw-r--r--libc/inet/Makefile10
-rw-r--r--libc/inet/addr.c108
-rw-r--r--libc/inet/resolv.c552
-rw-r--r--libc/inet/rpc/auth_none.c57
-rw-r--r--libc/inet/rpc/auth_unix.c126
-rw-r--r--libc/inet/rpc/authunix_prot.c22
-rw-r--r--libc/inet/rpc/bindresvport.c12
-rw-r--r--libc/inet/rpc/clnt_generic.c19
-rw-r--r--libc/inet/rpc/clnt_perror.c218
-rw-r--r--libc/inet/rpc/clnt_raw.c106
-rw-r--r--libc/inet/rpc/clnt_simple.c39
-rw-r--r--libc/inet/rpc/clnt_tcp.c234
-rw-r--r--libc/inet/rpc/clnt_udp.c261
-rw-r--r--libc/inet/rpc/get_myaddress.c22
-rw-r--r--libc/inet/rpc/getrpcent.c74
-rw-r--r--libc/inet/rpc/getrpcport.c6
-rw-r--r--libc/inet/rpc/pmap_clnt.c40
-rw-r--r--libc/inet/rpc/pmap_getmaps.c20
-rw-r--r--libc/inet/rpc/pmap_getport.c26
-rw-r--r--libc/inet/rpc/pmap_prot.c17
-rw-r--r--libc/inet/rpc/pmap_prot2.c26
-rw-r--r--libc/inet/rpc/pmap_rmt.c212
-rw-r--r--libc/inet/rpc/rpc_callmsg.c74
-rw-r--r--libc/inet/rpc/rpc_commondata.c3
-rw-r--r--libc/inet/rpc/rpc_dtablesize.c6
-rw-r--r--libc/inet/rpc/rpc_prot.c124
-rw-r--r--libc/inet/rpc/svc.c301
-rw-r--r--libc/inet/rpc/svc_auth.c33
-rw-r--r--libc/inet/rpc/svc_auth_unix.c39
-rw-r--r--libc/inet/rpc/svc_raw.c81
-rw-r--r--libc/inet/rpc/svc_run.c13
-rw-r--r--libc/inet/rpc/svc_simple.c51
-rw-r--r--libc/inet/rpc/svc_tcp.c219
-rw-r--r--libc/inet/rpc/svc_udp.c229
-rw-r--r--libc/inet/rpc/xdr.c198
-rw-r--r--libc/inet/rpc/xdr_array.c52
-rw-r--r--libc/inet/rpc/xdr_float.c154
-rw-r--r--libc/inet/rpc/xdr_mem.c101
-rw-r--r--libc/inet/rpc/xdr_rec.c312
-rw-r--r--libc/inet/rpc/xdr_reference.c37
-rw-r--r--libc/inet/rpc/xdr_stdio.c132
42 files changed, 2166 insertions, 2233 deletions
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;j<h->qdcount;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;j<h->ancount;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;j<h->nscount;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;j<h->arcount;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;j<h.qdcount;j++) {
+ for (j = 0; j < h.qdcount; j++) {
DPRINTF("Skipping question %d at %d\n", j, pos);
i = length_question(packet, pos);
DPRINTF("Length of question %d is %d\n", j, i);
@@ -544,82 +541,81 @@ int dns_lookup(const char * name, int type, int nscount, const char ** nsip,
pos += i;
}
DPRINTF("Decoding answer at pos %d\n", pos);
-
+
i = decode_answer(packet, pos, a);
-
- if (i<0) {
+
+ if (i < 0) {
DPRINTF("failed decode %d\n", i);
goto again;
}
-
+
DPRINTF("Answer name = |%s|\n", a->dotted);
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] = &in;
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] = &in;
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 <strings.h>
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(stderr, "clnttcp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
@@ -140,10 +139,12 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
*/
if (raddr->sin_port == 0) {
u_short port;
+
if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) {
- mem_free((caddr_t)ct, sizeof(struct ct_data));
- mem_free((caddr_t)h, sizeof(CLIENT));
- return ((CLIENT *)NULL);
+ mem_free((caddr_t) ct, sizeof(struct ct_data));
+
+ mem_free((caddr_t) h, sizeof(CLIENT));
+ return ((CLIENT *) NULL);
}
raddr->sin_port = htons(port);
}
@@ -153,13 +154,13 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
*/
if (*sockp < 0) {
*sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- (void)bindresvport(*sockp, (struct sockaddr_in *)0);
+ (void) bindresvport(*sockp, (struct sockaddr_in *) 0);
if ((*sockp < 0)
- || (connect(*sockp, (struct sockaddr *)raddr,
- sizeof(*raddr)) < 0)) {
+ || (connect(*sockp, (struct sockaddr *) raddr,
+ sizeof(*raddr)) < 0)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
- (void)close(*sockp);
+ (void) close(*sockp);
goto fooy;
}
ct->ct_closeit = TRUE;
@@ -178,7 +179,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
/*
* Initialize call message
*/
- (void)gettimeofday(&now, (struct timezone *)0);
+ (void) gettimeofday(&now, (struct timezone *) 0);
call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec;
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
@@ -189,10 +190,10 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
* pre-serialize the staic part of the call msg and stash it away
*/
xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE,
- XDR_ENCODE);
- if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
+ XDR_ENCODE);
+ if (!xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
if (ct->ct_closeit) {
- (void)close(*sockp);
+ (void) close(*sockp);
}
goto fooy;
}
@@ -204,36 +205,38 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
* and authnone for authentication.
*/
xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
- (caddr_t)ct, readtcp, writetcp);
+ (caddr_t) ct, readtcp, writetcp);
h->cl_ops = &tcp_ops;
h->cl_private = (caddr_t) ct;
h->cl_auth = authnone_create();
return (h);
-fooy:
+ fooy:
/*
* Something goofed, free stuff and barf
*/
- mem_free((caddr_t)ct, sizeof(struct ct_data));
- mem_free((caddr_t)h, sizeof(CLIENT));
- return ((CLIENT *)NULL);
+ mem_free((caddr_t) ct, sizeof(struct ct_data));
+
+ mem_free((caddr_t) h, sizeof(CLIENT));
+ return ((CLIENT *) NULL);
}
static enum clnt_stat
-clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
- register CLIENT *h;
- u_long proc;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
- xdrproc_t xdr_results;
- caddr_t results_ptr;
- struct timeval timeout;
+clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr,
+ timeout)
+register CLIENT *h;
+u_long proc;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
+xdrproc_t xdr_results;
+caddr_t results_ptr;
+struct timeval timeout;
{
register struct ct_data *ct = (struct ct_data *) h->cl_private;
register XDR *xdrs = &(ct->ct_xdrs);
struct rpc_msg reply_msg;
u_long x_id;
- u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */
+ u_long *msg_x_id = (u_long *) (ct->ct_mcall); /* yuk */
register bool_t shipnow;
int refreshes = 2;
@@ -242,31 +245,31 @@ clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
}
shipnow =
- (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
- && timeout.tv_usec == 0) ? FALSE : TRUE;
+ (xdr_results == (xdrproc_t) 0 && timeout.tv_sec == 0
+ && timeout.tv_usec == 0) ? FALSE : TRUE;
-call_again:
+ call_again:
xdrs->x_op = XDR_ENCODE;
ct->ct_error.re_status = RPC_SUCCESS;
x_id = ntohl(--(*msg_x_id));
- if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
- (! XDR_PUTLONG(xdrs, (long *)&proc)) ||
- (! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
- (! (*xdr_args)(xdrs, args_ptr))) {
+ if ((!XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
+ (!XDR_PUTLONG(xdrs, (long *) &proc)) ||
+ (!AUTH_MARSHALL(h->cl_auth, xdrs)) ||
+ (!(*xdr_args) (xdrs, args_ptr))) {
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTENCODEARGS;
- (void)xdrrec_endofrecord(xdrs, TRUE);
+ (void) xdrrec_endofrecord(xdrs, TRUE);
return (ct->ct_error.re_status);
}
- if (! xdrrec_endofrecord(xdrs, shipnow))
+ if (!xdrrec_endofrecord(xdrs, shipnow))
return (ct->ct_error.re_status = RPC_CANTSEND);
- if (! shipnow)
+ if (!shipnow)
return (RPC_SUCCESS);
/*
* Hack to provide rpc-based message passing
*/
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
- return(ct->ct_error.re_status = RPC_TIMEDOUT);
+ return (ct->ct_error.re_status = RPC_TIMEDOUT);
}
@@ -278,10 +281,10 @@ call_again:
reply_msg.acpted_rply.ar_verf = _null_auth;
reply_msg.acpted_rply.ar_results.where = NULL;
reply_msg.acpted_rply.ar_results.proc = xdr_void;
- if (! xdrrec_skiprecord(xdrs))
+ if (!xdrrec_skiprecord(xdrs))
return (ct->ct_error.re_status);
/* now decode and validate the response header */
- if (! xdr_replymsg(xdrs, &reply_msg)) {
+ if (!xdr_replymsg(xdrs, &reply_msg)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
continue;
return (ct->ct_error.re_status);
@@ -295,74 +298,69 @@ call_again:
*/
_seterr_reply(&reply_msg, &(ct->ct_error));
if (ct->ct_error.re_status == RPC_SUCCESS) {
- if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
+ if (!AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
ct->ct_error.re_status = RPC_AUTHERROR;
ct->ct_error.re_why = AUTH_INVALIDRESP;
- } else if (! (*xdr_results)(xdrs, results_ptr)) {
+ } else if (!(*xdr_results) (xdrs, results_ptr)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTDECODERES;
}
/* free verifier ... */
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
- (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
+ (void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
- } /* end successful completion */
+ } /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (refreshes-- && AUTH_REFRESH(h->cl_auth))
goto call_again;
- } /* end of unsuccessful completion */
+ } /* end of unsuccessful completion */
return (ct->ct_error.re_status);
}
-static void
-clnttcp_geterr(h, errp)
- CLIENT *h;
- struct rpc_err *errp;
+static void clnttcp_geterr(h, errp)
+CLIENT *h;
+struct rpc_err *errp;
{
- register struct ct_data *ct =
- (struct ct_data *) h->cl_private;
+ register struct ct_data *ct = (struct ct_data *) h->cl_private;
*errp = ct->ct_error;
}
-static bool_t
-clnttcp_freeres(cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+static bool_t clnttcp_freeres(cl, xdr_res, res_ptr)
+CLIENT *cl;
+xdrproc_t xdr_res;
+caddr_t res_ptr;
{
- register struct ct_data *ct = (struct ct_data *)cl->cl_private;
+ register struct ct_data *ct = (struct ct_data *) cl->cl_private;
register XDR *xdrs = &(ct->ct_xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_res)(xdrs, res_ptr));
+ return ((*xdr_res) (xdrs, res_ptr));
}
-static void
-clnttcp_abort()
+static void clnttcp_abort()
{
}
-static bool_t
-clnttcp_control(cl, request, info)
- CLIENT *cl;
- int request;
- char *info;
+static bool_t clnttcp_control(cl, request, info)
+CLIENT *cl;
+int request;
+char *info;
{
- register struct ct_data *ct = (struct ct_data *)cl->cl_private;
+ register struct ct_data *ct = (struct ct_data *) cl->cl_private;
switch (request) {
case CLSET_TIMEOUT:
- ct->ct_wait = *(struct timeval *)info;
+ ct->ct_wait = *(struct timeval *) info;
ct->ct_waitset = TRUE;
break;
case CLGET_TIMEOUT:
- *(struct timeval *)info = ct->ct_wait;
+ *(struct timeval *) info = ct->ct_wait;
break;
case CLGET_SERVER_ADDR:
- *(struct sockaddr_in *)info = ct->ct_addr;
+ *(struct sockaddr_in *) info = ct->ct_addr;
break;
default:
return (FALSE);
@@ -371,19 +369,18 @@ clnttcp_control(cl, request, info)
}
-static void
-clnttcp_destroy(h)
- CLIENT *h;
+static void clnttcp_destroy(h)
+CLIENT *h;
{
- register struct ct_data *ct =
- (struct ct_data *) h->cl_private;
+ register struct ct_data *ct = (struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
- (void)close(ct->ct_sock);
+ (void) close(ct->ct_sock);
}
XDR_DESTROY(&(ct->ct_xdrs));
- mem_free((caddr_t)ct, sizeof(struct ct_data));
- mem_free((caddr_t)h, sizeof(CLIENT));
+ mem_free((caddr_t) ct, sizeof(struct ct_data));
+
+ mem_free((caddr_t) h, sizeof(CLIENT));
}
/*
@@ -391,11 +388,10 @@ clnttcp_destroy(h)
* Behaves like the system calls, read & write, but keeps some error state
* around for the rpc level.
*/
-static int
-readtcp(ct, buf, len)
- register struct ct_data *ct;
- caddr_t buf;
- register int len;
+static int readtcp(ct, buf, len)
+register struct ct_data *ct;
+caddr_t buf;
+register int len;
{
#ifdef FD_SETSIZE
fd_set mask;
@@ -412,11 +408,12 @@ readtcp(ct, buf, len)
if (len == 0)
return (0);
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
while (TRUE) {
readfds = mask;
- switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL,
- &(ct->ct_wait))) {
+ switch (select
+ (_rpc_dtablesize(), &readfds, (int *) NULL, (int *) NULL,
+ &(ct->ct_wait))) {
case 0:
ct->ct_error.re_status = RPC_TIMEDOUT;
return (-1);
@@ -436,7 +433,7 @@ readtcp(ct, buf, len)
/* premature eof */
ct->ct_error.re_errno = ECONNRESET;
ct->ct_error.re_status = RPC_CANTRECV;
- len = -1; /* it's really an error */
+ len = -1; /* it's really an error */
break;
case -1:
@@ -447,11 +444,10 @@ readtcp(ct, buf, len)
return (len);
}
-static int
-writetcp(ct, buf, len)
- struct ct_data *ct;
- caddr_t buf;
- int len;
+static int writetcp(ct, buf, len)
+struct ct_data *ct;
+caddr_t buf;
+int len;
{
register int i, cnt;
diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c
index 815cbb4ed..7857f86fd 100644
--- a/libc/inet/rpc/clnt_udp.c
+++ b/libc/inet/rpc/clnt_udp.c
@@ -50,12 +50,12 @@ extern int errno;
/*
* UDP bases client side rpc operations
*/
-static enum clnt_stat clntudp_call();
-static void clntudp_abort();
-static void clntudp_geterr();
-static bool_t clntudp_freeres();
-static bool_t clntudp_control();
-static void clntudp_destroy();
+static enum clnt_stat clntudp_call();
+static void clntudp_abort();
+static void clntudp_geterr();
+static bool_t clntudp_freeres();
+static bool_t clntudp_control();
+static void clntudp_destroy();
static struct clnt_ops udp_ops = {
clntudp_call,
@@ -70,19 +70,19 @@ static struct clnt_ops udp_ops = {
* Private data kept per client handle
*/
struct cu_data {
- int cu_sock;
- bool_t cu_closeit;
+ int cu_sock;
+ bool_t cu_closeit;
struct sockaddr_in cu_raddr;
- int cu_rlen;
- struct timeval cu_wait;
- struct timeval cu_total;
- struct rpc_err cu_error;
- XDR cu_outxdrs;
- u_int cu_xdrpos;
- u_int cu_sendsz;
- char *cu_outbuf;
- u_int cu_recvsz;
- char cu_inbuf[1];
+ int cu_rlen;
+ struct timeval cu_wait;
+ struct timeval cu_total;
+ struct rpc_err cu_error;
+ XDR cu_outxdrs;
+ u_int cu_xdrpos;
+ u_int cu_sendsz;
+ char *cu_outbuf;
+ u_int cu_recvsz;
+ char cu_inbuf[1];
};
/*
@@ -101,22 +101,22 @@ struct cu_data {
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
-CLIENT *
-clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
- struct sockaddr_in *raddr;
- u_long program;
- u_long version;
- struct timeval wait;
- register int *sockp;
- u_int sendsz;
- u_int recvsz;
+CLIENT *clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz,
+ recvsz)
+struct sockaddr_in *raddr;
+u_long program;
+u_long version;
+struct timeval wait;
+register int *sockp;
+u_int sendsz;
+u_int recvsz;
{
CLIENT *cl;
register struct cu_data *cu;
struct timeval now;
struct rpc_msg call_msg;
- cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
+ cl = (CLIENT *) mem_alloc(sizeof(CLIENT));
if (cl == NULL) {
(void) fprintf(stderr, "clntudp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
@@ -125,7 +125,7 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
}
sendsz = ((sendsz + 3) / 4) * 4;
recvsz = ((recvsz + 3) / 4) * 4;
- cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz);
+ cu = (struct cu_data *) mem_alloc(sizeof(*cu) + sendsz + recvsz);
if (cu == NULL) {
(void) fprintf(stderr, "clntudp_create: out of memory\n");
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
@@ -134,19 +134,20 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
}
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
- (void)gettimeofday(&now, (struct timezone *)0);
+ (void) gettimeofday(&now, (struct timezone *) 0);
if (raddr->sin_port == 0) {
u_short port;
+
if ((port =
- pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
+ pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
goto fooy;
}
raddr->sin_port = htons(port);
}
cl->cl_ops = &udp_ops;
- cl->cl_private = (caddr_t)cu;
+ cl->cl_private = (caddr_t) cu;
cu->cu_raddr = *raddr;
- cu->cu_rlen = sizeof (cu->cu_raddr);
+ cu->cu_rlen = sizeof(cu->cu_raddr);
cu->cu_wait = wait;
cu->cu_total.tv_sec = -1;
cu->cu_total.tv_usec = -1;
@@ -157,9 +158,8 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program;
call_msg.rm_call.cb_vers = version;
- xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf,
- sendsz, XDR_ENCODE);
- if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
+ xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
+ if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
goto fooy;
}
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
@@ -173,9 +173,9 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
goto fooy;
}
/* attempt to bind to prov port */
- (void)bindresvport(*sockp, (struct sockaddr_in *)0);
+ (void) bindresvport(*sockp, (struct sockaddr_in *) 0);
/* the sockets rpc controls are non-blocking */
- (void)ioctl(*sockp, FIONBIO, (char *) &dontblock);
+ (void) ioctl(*sockp, FIONBIO, (char *) &dontblock);
cu->cu_closeit = TRUE;
} else {
cu->cu_closeit = FALSE;
@@ -183,83 +183,82 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
cu->cu_sock = *sockp;
cl->cl_auth = authnone_create();
return (cl);
-fooy:
+ fooy:
if (cu)
- mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz);
+ mem_free((caddr_t) cu, sizeof(*cu) + sendsz + recvsz);
if (cl)
- mem_free((caddr_t)cl, sizeof(CLIENT));
- return ((CLIENT *)NULL);
+ mem_free((caddr_t) cl, sizeof(CLIENT));
+ return ((CLIENT *) NULL);
}
-CLIENT *
-clntudp_create(raddr, program, version, wait, sockp)
- struct sockaddr_in *raddr;
- u_long program;
- u_long version;
- struct timeval wait;
- register int *sockp;
+CLIENT *clntudp_create(raddr, program, version, wait, sockp)
+struct sockaddr_in *raddr;
+u_long program;
+u_long version;
+struct timeval wait;
+register int *sockp;
{
- return(clntudp_bufcreate(raddr, program, version, wait, sockp,
- UDPMSGSIZE, UDPMSGSIZE));
+ return (clntudp_bufcreate(raddr, program, version, wait, sockp,
+ UDPMSGSIZE, UDPMSGSIZE));
}
-static enum clnt_stat
+static enum clnt_stat
clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
- register CLIENT *cl; /* client handle */
- u_long proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- caddr_t argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- struct timeval utimeout; /* seconds to wait before giving up */
+register CLIENT *cl; /* client handle */
+u_long proc; /* procedure number */
+xdrproc_t xargs; /* xdr routine for args */
+caddr_t argsp; /* pointer to args */
+xdrproc_t xresults; /* xdr routine for results */
+caddr_t resultsp; /* pointer to results */
+struct timeval utimeout; /* seconds to wait before giving up */
{
- register struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ register struct cu_data *cu = (struct cu_data *) cl->cl_private;
register XDR *xdrs;
register int outlen;
register int inlen;
int fromlen;
+
#ifdef FD_SETSIZE
fd_set readfds;
fd_set mask;
#else
int readfds;
register int mask;
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
struct sockaddr_in from;
struct rpc_msg reply_msg;
XDR reply_xdrs;
struct timeval time_waited;
bool_t ok;
- int nrefreshes = 2; /* number of times to refresh cred */
+ int nrefreshes = 2; /* number of times to refresh cred */
struct timeval timeout;
if (cu->cu_total.tv_usec == -1) {
- timeout = utimeout; /* use supplied timeout */
+ timeout = utimeout; /* use supplied timeout */
} else {
- timeout = cu->cu_total; /* use default timeout */
+ timeout = cu->cu_total; /* use default timeout */
}
time_waited.tv_sec = 0;
time_waited.tv_usec = 0;
-call_again:
+ call_again:
xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, cu->cu_xdrpos);
/*
* the transaction is the first thing in the out buffer
*/
- (*(u_short *)(cu->cu_outbuf))++;
- if ((! XDR_PUTLONG(xdrs, (long *)&proc)) ||
- (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
- (! (*xargs)(xdrs, argsp)))
+ (*(u_short *) (cu->cu_outbuf))++;
+ if ((!XDR_PUTLONG(xdrs, (long *) &proc)) ||
+ (!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp)))
return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
- outlen = (int)XDR_GETPOS(xdrs);
+ outlen = (int) XDR_GETPOS(xdrs);
-send_again:
+ send_again:
if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
- (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen)
- != outlen) {
+ (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen)
+ != outlen) {
cu->cu_error.re_errno = errno;
return (cu->cu_error.re_status = RPC_CANTSEND);
}
@@ -283,11 +282,11 @@ send_again:
FD_SET(cu->cu_sock, &mask);
#else
mask = 1 << cu->cu_sock;
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
for (;;) {
readfds = mask;
- switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
- (int *)NULL, &(cu->cu_wait))) {
+ switch (select(_rpc_dtablesize(), &readfds, (int *) NULL,
+ (int *) NULL, &(cu->cu_wait))) {
case 0:
time_waited.tv_sec += cu->cu_wait.tv_sec;
@@ -298,37 +297,38 @@ send_again:
}
if ((time_waited.tv_sec < timeout.tv_sec) ||
((time_waited.tv_sec == timeout.tv_sec) &&
- (time_waited.tv_usec < timeout.tv_usec)))
- goto send_again;
+ (time_waited.tv_usec < timeout.tv_usec)))
+ goto send_again;
return (cu->cu_error.re_status = RPC_TIMEDOUT);
- /*
- * buggy in other cases because time_waited is not being
- * updated.
- */
+ /*
+ * buggy in other cases because time_waited is not being
+ * updated.
+ */
case -1:
if (errno == EINTR)
- continue;
+ continue;
cu->cu_error.re_errno = errno;
return (cu->cu_error.re_status = RPC_CANTRECV);
}
do {
fromlen = sizeof(struct sockaddr);
- inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
- (int) cu->cu_recvsz, 0,
- (struct sockaddr *)&from, &fromlen);
+
+ inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
+ (int) cu->cu_recvsz, 0,
+ (struct sockaddr *) &from, &fromlen);
} while (inlen < 0 && errno == EINTR);
if (inlen < 0) {
if (errno == EWOULDBLOCK)
- continue;
+ continue;
cu->cu_error.re_errno = errno;
return (cu->cu_error.re_status = RPC_CANTRECV);
}
if (inlen < sizeof(u_long))
- continue;
+ continue;
/* see if reply transaction id matches sent id */
- if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf)))
- continue;
+ if (*((u_long *) (cu->cu_inbuf)) != *((u_long *) (cu->cu_outbuf)))
+ continue;
/* we now assume we have the proper reply */
break;
}
@@ -336,107 +336,102 @@ send_again:
/*
* now decode and validate the response
*/
- xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE);
+ xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int) inlen, XDR_DECODE);
ok = xdr_replymsg(&reply_xdrs, &reply_msg);
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
if (ok) {
_seterr_reply(&reply_msg, &(cu->cu_error));
if (cu->cu_error.re_status == RPC_SUCCESS) {
- if (! AUTH_VALIDATE(cl->cl_auth,
- &reply_msg.acpted_rply.ar_verf)) {
+ if (!AUTH_VALIDATE(cl->cl_auth,
+ &reply_msg.acpted_rply.ar_verf)) {
cu->cu_error.re_status = RPC_AUTHERROR;
cu->cu_error.re_why = AUTH_INVALIDRESP;
}
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
xdrs->x_op = XDR_FREE;
- (void)xdr_opaque_auth(xdrs,
- &(reply_msg.acpted_rply.ar_verf));
- }
- } /* end successful completion */
+ (void) xdr_opaque_auth(xdrs,
+ &(reply_msg.acpted_rply.ar_verf));
+ }
+ } /* end successful completion */
else {
/* maybe our credentials need to be refreshed ... */
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) {
nrefreshes--;
goto call_again;
}
- } /* end of unsuccessful completion */
- } /* end of valid reply message */
+ } /* end of unsuccessful completion */
+ } /* end of valid reply message */
else {
cu->cu_error.re_status = RPC_CANTDECODERES;
}
return (cu->cu_error.re_status);
}
-static void
-clntudp_geterr(cl, errp)
- CLIENT *cl;
- struct rpc_err *errp;
+static void clntudp_geterr(cl, errp)
+CLIENT *cl;
+struct rpc_err *errp;
{
- register struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ register struct cu_data *cu = (struct cu_data *) cl->cl_private;
*errp = cu->cu_error;
}
-static bool_t
-clntudp_freeres(cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+static bool_t clntudp_freeres(cl, xdr_res, res_ptr)
+CLIENT *cl;
+xdrproc_t xdr_res;
+caddr_t res_ptr;
{
- register struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ register struct cu_data *cu = (struct cu_data *) cl->cl_private;
register XDR *xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_res)(xdrs, res_ptr));
+ return ((*xdr_res) (xdrs, res_ptr));
}
-static void
-clntudp_abort(/*h*/)
- /*CLIENT *h;*/
+static void clntudp_abort( /*h */ )
+ /*CLIENT *h; */
{
}
-static bool_t
-clntudp_control(cl, request, info)
- CLIENT *cl;
- int request;
- char *info;
+static bool_t clntudp_control(cl, request, info)
+CLIENT *cl;
+int request;
+char *info;
{
- register struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ register struct cu_data *cu = (struct cu_data *) cl->cl_private;
switch (request) {
case CLSET_TIMEOUT:
- cu->cu_total = *(struct timeval *)info;
+ cu->cu_total = *(struct timeval *) info;
break;
case CLGET_TIMEOUT:
- *(struct timeval *)info = cu->cu_total;
+ *(struct timeval *) info = cu->cu_total;
break;
case CLSET_RETRY_TIMEOUT:
- cu->cu_wait = *(struct timeval *)info;
+ cu->cu_wait = *(struct timeval *) info;
break;
case CLGET_RETRY_TIMEOUT:
- *(struct timeval *)info = cu->cu_wait;
+ *(struct timeval *) info = cu->cu_wait;
break;
case CLGET_SERVER_ADDR:
- *(struct sockaddr_in *)info = cu->cu_raddr;
+ *(struct sockaddr_in *) info = cu->cu_raddr;
break;
default:
return (FALSE);
}
return (TRUE);
}
-
-static void
-clntudp_destroy(cl)
- CLIENT *cl;
+
+static void clntudp_destroy(cl)
+CLIENT *cl;
{
- register struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ register struct cu_data *cu = (struct cu_data *) cl->cl_private;
if (cu->cu_closeit) {
- (void)close(cu->cu_sock);
+ (void) close(cu->cu_sock);
}
XDR_DESTROY(&(cu->cu_outxdrs));
- mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz));
- mem_free((caddr_t)cl, sizeof(CLIENT));
+ mem_free((caddr_t) cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz));
+ mem_free((caddr_t) cl, sizeof(CLIENT));
}
diff --git a/libc/inet/rpc/get_myaddress.c b/libc/inet/rpc/get_myaddress.c
index cbfc05b8d..95ddc71b4 100644
--- a/libc/inet/rpc/get_myaddress.c
+++ b/libc/inet/rpc/get_myaddress.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -51,7 +53,7 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
/* DO use gethostbyname because it's portable */
#include <netdb.h>
get_myaddress(addr)
- struct sockaddr_in *addr;
+struct sockaddr_in *addr;
{
char localhost[256 + 1];
struct hostent *hp;
@@ -70,7 +72,7 @@ get_myaddress(addr)
* don't use gethostbyname, which would invoke yellow pages
*/
get_myaddress(addr)
- struct sockaddr_in *addr;
+struct sockaddr_in *addr;
{
int s;
char buf[BUFSIZ];
@@ -79,25 +81,25 @@ get_myaddress(addr)
int len;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- perror("get_myaddress: socket");
- exit(1);
+ perror("get_myaddress: socket");
+ exit(1);
}
- ifc.ifc_len = sizeof (buf);
+ ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
- if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
+ if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {
perror("get_myaddress: ioctl (get interface configuration)");
exit(1);
}
ifr = ifc.ifc_req;
for (len = ifc.ifc_len; len; len -= sizeof ifreq) {
ifreq = *ifr;
- if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
+ if (ioctl(s, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
perror("get_myaddress: ioctl");
exit(1);
}
if ((ifreq.ifr_flags & IFF_UP) &&
- ifr->ifr_addr.sa_family == AF_INET) {
- *addr = *((struct sockaddr_in *)&ifr->ifr_addr);
+ ifr->ifr_addr.sa_family == AF_INET) {
+ *addr = *((struct sockaddr_in *) &ifr->ifr_addr);
addr->sin_port = htons(PMAPPORT);
break;
}
diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c
index b3b3ece4c..06c272c89 100644
--- a/libc/inet/rpc/getrpcent.c
+++ b/libc/inet/rpc/getrpcent.c
@@ -1,6 +1,8 @@
/* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -46,43 +48,43 @@ static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro";
* Internet version.
*/
struct rpcdata {
- FILE *rpcf;
- char *current;
- int currentlen;
- int stayopen;
+ FILE *rpcf;
+ char *current;
+ int currentlen;
+ int stayopen;
#define MAXALIASES 35
- char *rpc_aliases[MAXALIASES];
- struct rpcent rpc;
- char line[BUFSIZ+1];
- char *domain;
+ char *rpc_aliases[MAXALIASES];
+ struct rpcent rpc;
+ char line[BUFSIZ + 1];
+ char *domain;
} *rpcdata, *_rpcdata();
-static struct rpcent *interpret();
-struct hostent *gethostent();
-char *inet_ntoa();
+static struct rpcent *interpret();
+struct hostent *gethostent();
+char *inet_ntoa();
+
#ifndef __linux__
-static char *index();
+static char *index();
#else
char *index();
#endif
static char RPCDB[] = "/etc/rpc";
-static struct rpcdata *
-_rpcdata()
+static struct rpcdata *_rpcdata()
{
register struct rpcdata *d = rpcdata;
if (d == 0) {
- d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
+ d = (struct rpcdata *) calloc(1, sizeof(struct rpcdata));
+
rpcdata = d;
}
return (d);
}
-struct rpcent *
-getrpcbynumber(number)
- register int number;
+struct rpcent *getrpcbynumber(number)
+register int number;
{
register struct rpcdata *d = _rpcdata();
register struct rpcent *p;
@@ -106,14 +108,14 @@ struct rpcent *
getrpcbyname(const char *name)
#else
getrpcbyname(name)
- char *name;
+char *name;
#endif
{
struct rpcent *rpc;
char **rp;
setrpcent(0);
- while(rpc = getrpcent()) {
+ while (rpc = getrpcent()) {
if (strcmp(rpc->r_name, name) == 0)
return (rpc);
for (rp = rpc->r_aliases; *rp != NULL; rp++) {
@@ -129,7 +131,7 @@ getrpcbyname(name)
void
#endif
setrpcent(f)
- int f;
+int f;
{
register struct rpcdata *d = _rpcdata();
@@ -164,8 +166,7 @@ endrpcent()
}
}
-struct rpcent *
-getrpcent()
+struct rpcent *getrpcent()
{
struct rpcent *hp;
int reason;
@@ -174,17 +175,16 @@ getrpcent()
register struct rpcdata *d = _rpcdata();
if (d == 0)
- return(NULL);
+ return (NULL);
if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
return (NULL);
- if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
+ if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
return (NULL);
return interpret(d->line, strlen(d->line));
}
#ifdef __linux__
-static char *
-firstwhite(s)
+static char *firstwhite(s)
char *s;
{
char *s1, *s2;
@@ -196,14 +196,12 @@ char *s;
return (s1 < s2) ? s1 : s2;
else
return s1;
- }
- else
+ } else
return s2;
}
#endif
-static struct rpcent *
-interpret(val, len)
+static struct rpcent *interpret(val, len)
{
register struct rpcdata *d = _rpcdata();
char *p;
@@ -217,8 +215,7 @@ interpret(val, len)
if (*p == '#')
return (getrpcent());
cp = index(p, '#');
- if (cp == NULL)
- {
+ if (cp == NULL) {
cp = index(p, '\n');
if (cp == NULL)
return (getrpcent());
@@ -231,8 +228,7 @@ interpret(val, len)
return (getrpcent());
#else
cp = index(p, ' ');
- if (cp == NULL)
- {
+ if (cp == NULL) {
cp = index(p, '\t');
if (cp == NULL)
return (getrpcent());
@@ -252,8 +248,7 @@ interpret(val, len)
cp = index(p, ' ');
if (cp != NULL)
*cp++ = '\0';
- else
- {
+ else {
cp = index(p, '\t');
if (cp != NULL)
*cp++ = '\0';
@@ -273,8 +268,7 @@ interpret(val, len)
cp = index(p, ' ');
if (cp != NULL)
*cp++ = '\0';
- else
- {
+ else {
cp = index(p, '\t');
if (cp != NULL)
*cp++ = '\0';
diff --git a/libc/inet/rpc/getrpcport.c b/libc/inet/rpc/getrpcport.c
index 9b13bac6b..af4f7daf6 100644
--- a/libc/inet/rpc/getrpcport.c
+++ b/libc/inet/rpc/getrpcport.c
@@ -1,6 +1,6 @@
/* @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC */
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
+static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
#endif
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -41,7 +41,7 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
#include <sys/socket.h>
getrpcport(host, prognum, versnum, proto)
- char *host;
+char *host;
{
struct sockaddr_in addr;
struct hostent *hp;
@@ -50,6 +50,6 @@ getrpcport(host, prognum, versnum, proto)
return (0);
bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length);
addr.sin_family = AF_INET;
- addr.sin_port = 0;
+ addr.sin_port = 0;
return (pmap_getport(&addr, prognum, versnum, proto));
}
diff --git a/libc/inet/rpc/pmap_clnt.c b/libc/inet/rpc/pmap_clnt.c
index 09220e77b..921575e02 100644
--- a/libc/inet/rpc/pmap_clnt.c
+++ b/libc/inet/rpc/pmap_clnt.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -52,12 +54,11 @@ void clnt_perror();
* Set a mapping between program,version and port.
* Calls the pmap service remotely to do the mapping.
*/
-bool_t
-pmap_set(program, version, protocol, port)
- u_long program;
- u_long version;
- int protocol;
- u_short port;
+bool_t pmap_set(program, version, protocol, port)
+u_long program;
+u_long version;
+int protocol;
+u_short port;
{
struct sockaddr_in myaddress;
int socket = -1;
@@ -67,20 +68,21 @@ pmap_set(program, version, protocol, port)
get_myaddress(&myaddress);
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
- timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
- if (client == (CLIENT *)NULL)
+ timeout, &socket, RPCSMALLMSGSIZE,
+ RPCSMALLMSGSIZE);
+ if (client == (CLIENT *) NULL)
return (FALSE);
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_prot = protocol;
parms.pm_port = port;
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
- tottimeout) != RPC_SUCCESS) {
+ tottimeout) != RPC_SUCCESS) {
clnt_perror(client, "Cannot register service");
return (FALSE);
}
CLNT_DESTROY(client);
- (void)close(socket);
+ (void) close(socket);
return (rslt);
}
@@ -88,10 +90,9 @@ pmap_set(program, version, protocol, port)
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
-bool_t
-pmap_unset(program, version)
- u_long program;
- u_long version;
+bool_t pmap_unset(program, version)
+u_long program;
+u_long version;
{
struct sockaddr_in myaddress;
int socket = -1;
@@ -101,15 +102,16 @@ pmap_unset(program, version)
get_myaddress(&myaddress);
client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
- timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
- if (client == (CLIENT *)NULL)
+ timeout, &socket, RPCSMALLMSGSIZE,
+ RPCSMALLMSGSIZE);
+ if (client == (CLIENT *) NULL)
return (FALSE);
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_port = parms.pm_prot = 0;
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
- tottimeout);
+ tottimeout);
CLNT_DESTROY(client);
- (void)close(socket);
+ (void) close(socket);
return (rslt);
}
diff --git a/libc/inet/rpc/pmap_getmaps.c b/libc/inet/rpc/pmap_getmaps.c
index 98803d3c5..837875328 100644
--- a/libc/inet/rpc/pmap_getmaps.c
+++ b/libc/inet/rpc/pmap_getmaps.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -57,11 +59,10 @@ extern int errno;
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
-struct pmaplist *
-pmap_getmaps(address)
- struct sockaddr_in *address;
+struct pmaplist *pmap_getmaps(address)
+struct sockaddr_in *address;
{
- struct pmaplist *head = (struct pmaplist *)NULL;
+ struct pmaplist *head = (struct pmaplist *) NULL;
int socket = -1;
struct timeval minutetimeout;
register CLIENT *client;
@@ -69,16 +70,15 @@ pmap_getmaps(address)
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons(PMAPPORT);
- client = clnttcp_create(address, PMAPPROG,
- PMAPVERS, &socket, 50, 500);
- if (client != (CLIENT *)NULL) {
+ client = clnttcp_create(address, PMAPPROG, PMAPVERS, &socket, 50, 500);
+ if (client != (CLIENT *) NULL) {
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
- &head, minutetimeout) != RPC_SUCCESS) {
+ &head, minutetimeout) != RPC_SUCCESS) {
clnt_perror(client, "pmap_getmaps rpc problem");
}
CLNT_DESTROY(client);
}
- (void)close(socket);
+ (void) close(socket);
address->sin_port = 0;
return (head);
}
diff --git a/libc/inet/rpc/pmap_getport.c b/libc/inet/rpc/pmap_getport.c
index 5eb2eee3b..122105d8c 100644
--- a/libc/inet/rpc/pmap_getport.c
+++ b/libc/inet/rpc/pmap_getport.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -52,12 +54,11 @@ static struct timeval tottimeout = { 60, 0 };
* Calls the pmap service remotely to do the lookup.
* Returns 0 if no map exists.
*/
-u_short
-pmap_getport(address, program, version, protocol)
- struct sockaddr_in *address;
- u_long program;
- u_long version;
- u_int protocol;
+u_short pmap_getport(address, program, version, protocol)
+struct sockaddr_in *address;
+u_long program;
+u_long version;
+u_int protocol;
{
u_short port = 0;
int socket = -1;
@@ -66,14 +67,15 @@ pmap_getport(address, program, version, protocol)
address->sin_port = htons(PMAPPORT);
client = clntudp_bufcreate(address, PMAPPROG,
- PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
- if (client != (CLIENT *)NULL) {
+ PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE,
+ RPCSMALLMSGSIZE);
+ if (client != (CLIENT *) NULL) {
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_prot = protocol;
- parms.pm_port = 0; /* not needed or used */
+ parms.pm_port = 0; /* not needed or used */
if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms,
- xdr_u_short, &port, tottimeout) != RPC_SUCCESS){
+ xdr_u_short, &port, tottimeout) != RPC_SUCCESS) {
rpc_createerr.cf_stat = RPC_PMAPFAILURE;
clnt_geterr(client, &rpc_createerr.cf_error);
} else if (port == 0) {
@@ -81,7 +83,7 @@ pmap_getport(address, program, version, protocol)
}
CLNT_DESTROY(client);
}
- (void)close(socket);
+ (void) close(socket);
address->sin_port = 0;
return (port);
}
diff --git a/libc/inet/rpc/pmap_prot.c b/libc/inet/rpc/pmap_prot.c
index 643c2ff6a..ec8b5af79 100644
--- a/libc/inet/rpc/pmap_prot.c
+++ b/libc/inet/rpc/pmap_prot.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -43,15 +45,14 @@ static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/pmap_prot.h>
-bool_t
-xdr_pmap(xdrs, regs)
- XDR *xdrs;
- struct pmap *regs;
+bool_t xdr_pmap(xdrs, regs)
+XDR *xdrs;
+struct pmap *regs;
{
- if (xdr_u_long(xdrs, &regs->pm_prog) &&
- xdr_u_long(xdrs, &regs->pm_vers) &&
+ if (xdr_u_long(xdrs, &regs->pm_prog) &&
+ xdr_u_long(xdrs, &regs->pm_vers) &&
xdr_u_long(xdrs, &regs->pm_prot))
- return (xdr_u_long(xdrs, &regs->pm_port));
+ return (xdr_u_long(xdrs, &regs->pm_port));
return (FALSE);
}
diff --git a/libc/inet/rpc/pmap_prot2.c b/libc/inet/rpc/pmap_prot2.c
index e2a8214d4..1a6207728 100644
--- a/libc/inet/rpc/pmap_prot2.c
+++ b/libc/inet/rpc/pmap_prot2.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -81,10 +83,9 @@ static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
* the net, yet is the data that the pointer points to which is interesting;
* this sounds like a job for xdr_reference!
*/
-bool_t
-xdr_pmaplist(xdrs, rp)
- register XDR *xdrs;
- register struct pmaplist **rp;
+bool_t xdr_pmaplist(xdrs, rp)
+register XDR *xdrs;
+register struct pmaplist **rp;
{
/*
* more_elements is pre-computed in case the direction is
@@ -96,21 +97,22 @@ xdr_pmaplist(xdrs, rp)
register struct pmaplist **next;
while (TRUE) {
- more_elements = (bool_t)(*rp != NULL);
- if (! xdr_bool(xdrs, &more_elements))
+ more_elements = (bool_t) (*rp != NULL);
+ if (!xdr_bool(xdrs, &more_elements))
return (FALSE);
- if (! more_elements)
- return (TRUE); /* we are done */
+ if (!more_elements)
+ return (TRUE); /* we are done */
/*
* the unfortunate side effect of non-recursion is that in
* the case of freeing we must remember the next object
* before we free the current object ...
*/
if (freeing)
- next = &((*rp)->pml_next);
- if (! xdr_reference(xdrs, (caddr_t *)rp,
- (u_int)sizeof(struct pmaplist), xdr_pmap))
+ next = &((*rp)->pml_next);
+ if (!xdr_reference(xdrs, (caddr_t *) rp,
+ (u_int) sizeof(struct pmaplist), xdr_pmap))
return (FALSE);
+
rp = (freeing) ? next : &((*rp)->pml_next);
}
}
diff --git a/libc/inet/rpc/pmap_rmt.c b/libc/inet/rpc/pmap_rmt.c
index 1921b74c1..1f2b47cba 100644
--- a/libc/inet/rpc/pmap_rmt.c
+++ b/libc/inet/rpc/pmap_rmt.c
@@ -63,13 +63,14 @@ static struct timeval timeout = { 3, 0 };
* programs to do a lookup and call in one step.
*/
enum clnt_stat
-pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr)
- struct sockaddr_in *addr;
- u_long prog, vers, proc;
- xdrproc_t xdrargs, xdrres;
- caddr_t argsp, resp;
- struct timeval tout;
- u_long *port_ptr;
+pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout,
+ port_ptr)
+struct sockaddr_in *addr;
+u_long prog, vers, proc;
+xdrproc_t xdrargs, xdrres;
+caddr_t argsp, resp;
+struct timeval tout;
+u_long *port_ptr;
{
int socket = -1;
register CLIENT *client;
@@ -79,7 +80,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
addr->sin_port = htons(PMAPPORT);
client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket);
- if (client != (CLIENT *)NULL) {
+ if (client != (CLIENT *) NULL) {
a.prog = prog;
a.vers = vers;
a.proc = proc;
@@ -89,12 +90,12 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
r.results_ptr = resp;
r.xdr_results = xdrres;
stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a,
- xdr_rmtcallres, &r, tout);
+ xdr_rmtcallres, &r, tout);
CLNT_DESTROY(client);
} else {
stat = RPC_FAILED;
}
- (void)close(socket);
+ (void) close(socket);
addr->sin_port = 0;
return (stat);
}
@@ -104,27 +105,25 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
* XDR remote call arguments
* written for XDR_ENCODE direction only
*/
-bool_t
-xdr_rmtcall_args(xdrs, cap)
- register XDR *xdrs;
- register struct rmtcallargs *cap;
+bool_t xdr_rmtcall_args(xdrs, cap)
+register XDR *xdrs;
+register struct rmtcallargs *cap;
{
u_int lenposition, argposition, position;
if (xdr_u_long(xdrs, &(cap->prog)) &&
- xdr_u_long(xdrs, &(cap->vers)) &&
- xdr_u_long(xdrs, &(cap->proc))) {
+ xdr_u_long(xdrs, &(cap->vers)) && xdr_u_long(xdrs, &(cap->proc))) {
lenposition = XDR_GETPOS(xdrs);
- if (! xdr_u_long(xdrs, &(cap->arglen)))
- return (FALSE);
+ if (!xdr_u_long(xdrs, &(cap->arglen)))
+ return (FALSE);
argposition = XDR_GETPOS(xdrs);
- if (! (*(cap->xdr_args))(xdrs, cap->args_ptr))
- return (FALSE);
+ if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
+ return (FALSE);
position = XDR_GETPOS(xdrs);
- cap->arglen = (u_long)position - (u_long)argposition;
+ cap->arglen = (u_long) position - (u_long) argposition;
XDR_SETPOS(xdrs, lenposition);
- if (! xdr_u_long(xdrs, &(cap->arglen)))
- return (FALSE);
+ if (!xdr_u_long(xdrs, &(cap->arglen)))
+ return (FALSE);
XDR_SETPOS(xdrs, position);
return (TRUE);
}
@@ -135,18 +134,17 @@ xdr_rmtcall_args(xdrs, cap)
* XDR remote call results
* written for XDR_DECODE direction only
*/
-bool_t
-xdr_rmtcallres(xdrs, crp)
- register XDR *xdrs;
- register struct rmtcallres *crp;
+bool_t xdr_rmtcallres(xdrs, crp)
+register XDR *xdrs;
+register struct rmtcallres *crp;
{
caddr_t port_ptr;
- port_ptr = (caddr_t)crp->port_ptr;
- if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
- xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
- crp->port_ptr = (u_long *)port_ptr;
- return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
+ port_ptr = (caddr_t) crp->port_ptr;
+ if (xdr_reference(xdrs, &port_ptr, sizeof(u_long),
+ xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
+ crp->port_ptr = (u_long *) port_ptr;
+ return ((*(crp->xdr_results)) (xdrs, crp->results_ptr));
}
return (FALSE);
}
@@ -158,11 +156,10 @@ xdr_rmtcallres(xdrs, crp)
* routines which only support udp/ip .
*/
-static int
-getbroadcastnets(addrs, sock, buf)
- struct in_addr *addrs;
- int sock; /* any valid socket will do */
- char *buf; /* why allocxate more when we can use existing... */
+static int getbroadcastnets(addrs, sock, buf)
+struct in_addr *addrs;
+int sock; /* any valid socket will do */
+char *buf; /* why allocxate more when we can use existing... */
{
#ifdef __linux__
struct sockaddr_in addr;
@@ -176,45 +173,46 @@ getbroadcastnets(addrs, sock, buf)
return 1;
#else
struct ifconf ifc;
- struct ifreq ifreq, *ifr;
+ struct ifreq ifreq, *ifr;
struct sockaddr_in *sin;
- int n, i;
+ int n, i;
- ifc.ifc_len = UDPMSGSIZE;
- ifc.ifc_buf = buf;
- if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
- perror("broadcast: ioctl (get interface configuration)");
- return (0);
- }
- ifr = ifc.ifc_req;
- for (i = 0, n = ifc.ifc_len/sizeof (struct ifreq); n > 0; n--, ifr++) {
- ifreq = *ifr;
- if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
- perror("broadcast: ioctl (get interface flags)");
- continue;
- }
- if ((ifreq.ifr_flags & IFF_BROADCAST) &&
- (ifreq.ifr_flags & IFF_UP) &&
- ifr->ifr_addr.sa_family == AF_INET) {
- sin = (struct sockaddr_in *)&ifr->ifr_addr;
-#ifdef SIOCGIFBRDADDR /* 4.3BSD */
- if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) {
+ ifc.ifc_len = UDPMSGSIZE;
+ ifc.ifc_buf = buf;
+ if (ioctl(sock, SIOCGIFCONF, (char *) &ifc) < 0) {
+ perror("broadcast: ioctl (get interface configuration)");
+ return (0);
+ }
+ ifr = ifc.ifc_req;
+ for (i = 0, n = ifc.ifc_len / sizeof(struct ifreq); n > 0; n--, ifr++) {
+ ifreq = *ifr;
+ if (ioctl(sock, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
+ perror("broadcast: ioctl (get interface flags)");
+ continue;
+ }
+ if ((ifreq.ifr_flags & IFF_BROADCAST) &&
+ (ifreq.ifr_flags & IFF_UP) &&
+ ifr->ifr_addr.sa_family == AF_INET) {
+ sin = (struct sockaddr_in *) &ifr->ifr_addr;
+#ifdef SIOCGIFBRDADDR /* 4.3BSD */
+ if (ioctl(sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0) {
#if 1
-printf("%s(%d): no inet_makeaddr()\n", __FILE__, __LINE__);
+ printf("%s(%d): no inet_makeaddr()\n", __FILE__, __LINE__);
#else
addrs[i++] = inet_makeaddr(inet_netof
- (sin->sin_addr.s_addr), INADDR_ANY);
+ (sin->sin_addr.s_addr),
+ INADDR_ANY);
#endif
} else {
- addrs[i++] = ((struct sockaddr_in*)
- &ifreq.ifr_addr)->sin_addr;
+ addrs[i++] = ((struct sockaddr_in *)
+ &ifreq.ifr_addr)->sin_addr;
}
-#else /* 4.2 BSD */
+#else /* 4.2 BSD */
#if 1
-printf("%s(%d): no inet_makeaddr()\n", __FILE__, __LINE__);
+ printf("%s(%d): no inet_makeaddr()\n", __FILE__, __LINE__);
#else
addrs[i++] = inet_makeaddr(inet_netof
- (sin->sin_addr.s_addr), INADDR_ANY);
+ (sin->sin_addr.s_addr), INADDR_ANY);
#endif
#endif
}
@@ -223,18 +221,19 @@ printf("%s(%d): no inet_makeaddr()\n", __FILE__, __LINE__);
#endif
}
-typedef bool_t (*resultproc_t)();
+typedef bool_t(*resultproc_t) ();
-enum clnt_stat
-clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
- u_long prog; /* program number */
- u_long vers; /* version number */
- u_long proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- caddr_t argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- resultproc_t eachresult; /* call with each result obtained */
+enum clnt_stat
+clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp,
+ eachresult)
+u_long prog; /* program number */
+u_long vers; /* version number */
+u_long proc; /* procedure number */
+xdrproc_t xargs; /* xdr routine for args */
+caddr_t argsp; /* pointer to args */
+xdrproc_t xresults; /* xdr routine for results */
+caddr_t resultsp; /* pointer to results */
+resultproc_t eachresult; /* call with each result obtained */
{
enum clnt_stat stat;
AUTH *unix_auth = authunix_create_default();
@@ -243,23 +242,24 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
int outlen, inlen, fromlen, nets;
register int sock;
int on = 1;
+
#ifdef FD_SETSIZE
fd_set mask;
fd_set readfds;
#else
int readfds;
register int mask;
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
register int i;
bool_t done = FALSE;
register u_long xid;
u_long port;
struct in_addr addrs[20];
- struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
+ struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
struct rmtcallargs a;
struct rmtcallres r;
struct rpc_msg msg;
- struct timeval t;
+ struct timeval t;
char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE];
/*
@@ -272,25 +272,25 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
goto done_broad;
}
#ifdef SO_BROADCAST
- if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
+ if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0) {
perror("Cannot set socket option SO_BROADCAST");
stat = RPC_CANTSEND;
goto done_broad;
}
-#endif /* def SO_BROADCAST */
+#endif /* def SO_BROADCAST */
#ifdef FD_SETSIZE
FD_ZERO(&mask);
FD_SET(sock, &mask);
#else
mask = (1 << sock);
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
nets = getbroadcastnets(addrs, sock, inbuf);
- bzero((char *)&baddr, sizeof (baddr));
+ bzero((char *) &baddr, sizeof(baddr));
baddr.sin_family = AF_INET;
baddr.sin_port = htons(PMAPPORT);
baddr.sin_addr.s_addr = htonl(INADDR_ANY);
/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */
- (void)gettimeofday(&t, (struct timezone *)0);
+ (void) gettimeofday(&t, (struct timezone *) 0);
msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec;
t.tv_usec = 0;
msg.rm_direction = CALL;
@@ -309,11 +309,11 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
r.xdr_results = xresults;
r.results_ptr = resultsp;
xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
- if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) {
+ if ((!xdr_callmsg(xdrs, &msg)) || (!xdr_rmtcall_args(xdrs, &a))) {
stat = RPC_CANTENCODEARGS;
goto done_broad;
}
- outlen = (int)xdr_getpos(xdrs);
+ outlen = (int) xdr_getpos(xdrs);
xdr_destroy(xdrs);
/*
* Basic loop: broadcast a packet and wait a while for response(s).
@@ -323,8 +323,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
for (i = 0; i < nets; i++) {
baddr.sin_addr = addrs[i];
if (sendto(sock, outbuf, outlen, 0,
- (struct sockaddr *)&baddr,
- sizeof (struct sockaddr)) != outlen) {
+ (struct sockaddr *) &baddr,
+ sizeof(struct sockaddr)) != outlen) {
perror("Cannot send broadcast packet");
stat = RPC_CANTSEND;
goto done_broad;
@@ -334,30 +334,31 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
stat = RPC_SUCCESS;
goto done_broad;
}
- recv_again:
+ recv_again:
msg.acpted_rply.ar_verf = _null_auth;
- msg.acpted_rply.ar_results.where = (caddr_t)&r;
- msg.acpted_rply.ar_results.proc = xdr_rmtcallres;
+ msg.acpted_rply.ar_results.where = (caddr_t) & r;
+ msg.acpted_rply.ar_results.proc = xdr_rmtcallres;
readfds = mask;
- switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
- (int *)NULL, &t)) {
+ switch (select(_rpc_dtablesize(), &readfds, (int *) NULL,
+ (int *) NULL, &t)) {
- case 0: /* timed out */
+ case 0: /* timed out */
stat = RPC_TIMEDOUT;
continue;
- case -1: /* some kind of error */
+ case -1: /* some kind of error */
if (errno == EINTR)
goto recv_again;
perror("Broadcast select problem");
stat = RPC_CANTRECV;
goto done_broad;
- } /* end of select results switch */
- try_again:
+ } /* end of select results switch */
+ try_again:
fromlen = sizeof(struct sockaddr);
+
inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0,
- (struct sockaddr *)&raddr, &fromlen);
+ (struct sockaddr *) &raddr, &fromlen);
if (inlen < 0) {
if (errno == EINTR)
goto try_again;
@@ -371,13 +372,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
* see if reply transaction id matches sent id.
* If so, decode the results.
*/
- xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE);
+ xdrmem_create(xdrs, inbuf, (u_int) inlen, XDR_DECODE);
if (xdr_replymsg(xdrs, &msg)) {
if ((msg.rm_xid == xid) &&
(msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
(msg.acpted_rply.ar_stat == SUCCESS)) {
- raddr.sin_port = htons((u_short)port);
- done = (*eachresult)(resultsp, &raddr);
+ raddr.sin_port = htons((u_short) port);
+ done = (*eachresult) (resultsp, &raddr);
}
/* otherwise, we just ignore the errors ... */
} else {
@@ -390,8 +391,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
}
xdrs->x_op = XDR_FREE;
msg.acpted_rply.ar_results.proc = xdr_void;
- (void)xdr_replymsg(xdrs, &msg);
- (void)(*xresults)(xdrs, resultsp);
+ (void) xdr_replymsg(xdrs, &msg);
+ (void) (*xresults) (xdrs, resultsp);
xdr_destroy(xdrs);
if (done) {
stat = RPC_SUCCESS;
@@ -400,9 +401,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
goto recv_again;
}
}
-done_broad:
- (void)close(sock);
+ done_broad:
+ (void) close(sock);
AUTH_DESTROY(unix_auth);
return (stat);
}
-
diff --git a/libc/inet/rpc/rpc_callmsg.c b/libc/inet/rpc/rpc_callmsg.c
index d9d815a6f..1bd6bb6d6 100644
--- a/libc/inet/rpc/rpc_callmsg.c
+++ b/libc/inet/rpc/rpc_callmsg.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -45,10 +47,9 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
/*
* XDR a call message
*/
-bool_t
-xdr_callmsg(xdrs, cmsg)
- register XDR *xdrs;
- register struct rpc_msg *cmsg;
+bool_t xdr_callmsg(xdrs, cmsg)
+register XDR *xdrs;
+register struct rpc_msg *cmsg;
{
register long *buf;
register struct opaque_auth *oa;
@@ -61,9 +62,9 @@ xdr_callmsg(xdrs, cmsg)
return (FALSE);
}
buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
- + RNDUP(cmsg->rm_call.cb_cred.oa_length)
- + 2 * BYTES_PER_XDR_UNIT
- + RNDUP(cmsg->rm_call.cb_verf.oa_length));
+ + RNDUP(cmsg->rm_call.cb_cred.oa_length)
+ + 2 * BYTES_PER_XDR_UNIT
+ + RNDUP(cmsg->rm_call.cb_verf.oa_length));
if (buf != NULL) {
IXDR_PUT_LONG(buf, cmsg->rm_xid);
IXDR_PUT_ENUM(buf, cmsg->rm_direction);
@@ -81,17 +82,17 @@ xdr_callmsg(xdrs, cmsg)
IXDR_PUT_ENUM(buf, oa->oa_flavor);
IXDR_PUT_LONG(buf, oa->oa_length);
if (oa->oa_length) {
- bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
- buf += RNDUP(oa->oa_length) / sizeof (long);
+ bcopy(oa->oa_base, (caddr_t) buf, oa->oa_length);
+ buf += RNDUP(oa->oa_length) / sizeof(long);
}
oa = &cmsg->rm_call.cb_verf;
IXDR_PUT_ENUM(buf, oa->oa_flavor);
IXDR_PUT_LONG(buf, oa->oa_length);
if (oa->oa_length) {
- bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
+ bcopy(oa->oa_base, (caddr_t) buf, oa->oa_length);
/* no real need....
- buf += RNDUP(oa->oa_length) / sizeof (long);
- */
+ buf += RNDUP(oa->oa_length) / sizeof (long);
+ */
}
return (TRUE);
}
@@ -101,6 +102,7 @@ xdr_callmsg(xdrs, cmsg)
if (buf != NULL) {
cmsg->rm_xid = IXDR_GET_LONG(buf);
cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
+
if (cmsg->rm_direction != CALL) {
return (FALSE);
}
@@ -125,23 +127,22 @@ xdr_callmsg(xdrs, cmsg)
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
- oa->oa_length) == FALSE) {
+ oa->oa_length) == FALSE) {
return (FALSE);
}
} else {
- bcopy((caddr_t)buf, oa->oa_base,
- oa->oa_length);
+ bcopy((caddr_t) buf, oa->oa_base, oa->oa_length);
/* no real need....
- buf += RNDUP(oa->oa_length) /
- sizeof (long);
- */
+ buf += RNDUP(oa->oa_length) /
+ sizeof (long);
+ */
}
}
oa = &cmsg->rm_call.cb_verf;
buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
- xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
+ xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
return (FALSE);
}
} else {
@@ -159,32 +160,29 @@ xdr_callmsg(xdrs, cmsg)
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
- oa->oa_length) == FALSE) {
+ oa->oa_length) == FALSE) {
return (FALSE);
}
} else {
- bcopy((caddr_t)buf, oa->oa_base,
- oa->oa_length);
+ bcopy((caddr_t) buf, oa->oa_base, oa->oa_length);
/* no real need...
- buf += RNDUP(oa->oa_length) /
- sizeof (long);
- */
+ buf += RNDUP(oa->oa_length) /
+ sizeof (long);
+ */
}
}
return (TRUE);
}
}
- if (
- xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
- xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
- (cmsg->rm_direction == CALL) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
- (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) &&
- xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
- return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
+ if (xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
+ xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) &&
+ (cmsg->rm_direction == CALL) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+ (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) &&
+ xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)))
+ return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
return (FALSE);
}
-
diff --git a/libc/inet/rpc/rpc_commondata.c b/libc/inet/rpc/rpc_commondata.c
index 75cead087..39648d284 100644
--- a/libc/inet/rpc/rpc_commondata.c
+++ b/libc/inet/rpc/rpc_commondata.c
@@ -33,9 +33,10 @@
* by public interfaces
*/
struct opaque_auth _null_auth;
+
#ifdef FD_SETSIZE
fd_set svc_fdset;
#else
int svc_fds;
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
struct rpc_createerr rpc_createerr;
diff --git a/libc/inet/rpc/rpc_dtablesize.c b/libc/inet/rpc/rpc_dtablesize.c
index a8488172e..960bb4699 100644
--- a/libc/inet/rpc/rpc_dtablesize.c
+++ b/libc/inet/rpc/rpc_dtablesize.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
+static char sccsid[] =
+
+ "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
#endif
/*
@@ -38,7 +40,7 @@ static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
_rpc_dtablesize()
{
static int size;
-
+
if (size == 0) {
size = getdtablesize();
}
diff --git a/libc/inet/rpc/rpc_prot.c b/libc/inet/rpc/rpc_prot.c
index 4b1319ad5..e3c873b44 100644
--- a/libc/inet/rpc/rpc_prot.c
+++ b/libc/inet/rpc/rpc_prot.c
@@ -56,27 +56,25 @@ struct opaque_auth _null_auth;
* XDR an opaque authentication struct
* (see auth.h)
*/
-bool_t
-xdr_opaque_auth(xdrs, ap)
- register XDR *xdrs;
- register struct opaque_auth *ap;
+bool_t xdr_opaque_auth(xdrs, ap)
+register XDR *xdrs;
+register struct opaque_auth *ap;
{
if (xdr_enum(xdrs, &(ap->oa_flavor)))
return (xdr_bytes(xdrs, &ap->oa_base,
- &ap->oa_length, MAX_AUTH_BYTES));
+ &ap->oa_length, MAX_AUTH_BYTES));
return (FALSE);
}
/*
* XDR a DES block
*/
-bool_t
-xdr_des_block(xdrs, blkp)
- register XDR *xdrs;
- register des_block *blkp;
+bool_t xdr_des_block(xdrs, blkp)
+register XDR *xdrs;
+register des_block *blkp;
{
- return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
+ return (xdr_opaque(xdrs, (caddr_t) blkp, sizeof(des_block)));
}
/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
@@ -84,74 +82,72 @@ xdr_des_block(xdrs, blkp)
/*
* XDR the MSG_ACCEPTED part of a reply message union
*/
-bool_t
-xdr_accepted_reply(xdrs, ar)
- register XDR *xdrs;
- register struct accepted_reply *ar;
+bool_t xdr_accepted_reply(xdrs, ar)
+register XDR *xdrs;
+register struct accepted_reply *ar;
{
/* personalized union, rather than calling xdr_union */
- if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
+ if (!xdr_opaque_auth(xdrs, &(ar->ar_verf)))
return (FALSE);
- if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
+ if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat)))
return (FALSE);
switch (ar->ar_stat) {
case SUCCESS:
- return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
+ return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where));
case PROG_MISMATCH:
- if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
+ if (!xdr_u_long(xdrs, &(ar->ar_vers.low)))
return (FALSE);
return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
}
- return (TRUE); /* TRUE => open ended set of problems */
+ return (TRUE); /* TRUE => open ended set of problems */
}
/*
* XDR the MSG_DENIED part of a reply message union
*/
-bool_t
-xdr_rejected_reply(xdrs, rr)
- register XDR *xdrs;
- register struct rejected_reply *rr;
+bool_t xdr_rejected_reply(xdrs, rr)
+register XDR *xdrs;
+register struct rejected_reply *rr;
{
/* personalized union, rather than calling xdr_union */
- if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
+ if (!xdr_enum(xdrs, (enum_t *) & (rr->rj_stat)))
return (FALSE);
switch (rr->rj_stat) {
case RPC_MISMATCH:
- if (! xdr_u_long(xdrs, &(rr->rj_vers.low)))
+ if (!xdr_u_long(xdrs, &(rr->rj_vers.low)))
return (FALSE);
return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
case AUTH_ERROR:
- return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
+ return (xdr_enum(xdrs, (enum_t *) & (rr->rj_why)));
}
return (FALSE);
}
static struct xdr_discrim reply_dscrm[3] = {
- { (int)MSG_ACCEPTED, xdr_accepted_reply },
- { (int)MSG_DENIED, xdr_rejected_reply },
- { __dontcare__, NULL_xdrproc_t } };
+ {(int) MSG_ACCEPTED, xdr_accepted_reply},
+ {(int) MSG_DENIED, xdr_rejected_reply},
+ {__dontcare__, NULL_xdrproc_t}
+};
/*
* XDR a reply message
*/
-bool_t
-xdr_replymsg(xdrs, rmsg)
- register XDR *xdrs;
- register struct rpc_msg *rmsg;
+bool_t xdr_replymsg(xdrs, rmsg)
+register XDR *xdrs;
+register struct rpc_msg *rmsg;
{
- if (
- xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
- xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
- (rmsg->rm_direction == REPLY) )
- return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
- (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
+ if (xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
+ xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) &&
+ (rmsg->rm_direction == REPLY))
+ return (xdr_union(xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat),
+ (caddr_t) & (rmsg->rm_reply.ru), reply_dscrm,
+ NULL_xdrproc_t));
return (FALSE);
}
@@ -161,30 +157,28 @@ xdr_replymsg(xdrs, rmsg)
* The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
-bool_t
-xdr_callhdr(xdrs, cmsg)
- register XDR *xdrs;
- register struct rpc_msg *cmsg;
+bool_t xdr_callhdr(xdrs, cmsg)
+register XDR *xdrs;
+register struct rpc_msg *cmsg;
{
cmsg->rm_direction = CALL;
cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
if (
- (xdrs->x_op == XDR_ENCODE) &&
- xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
- xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
- xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) )
- return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
+ (xdrs->x_op == XDR_ENCODE) &&
+ xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
+ xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+ xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)))
+ return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
return (FALSE);
}
/* ************************** Client utility routine ************* */
-static void
-accepted(acpt_stat, error)
- register enum accept_stat acpt_stat;
- register struct rpc_err *error;
+static void accepted(acpt_stat, error)
+register enum accept_stat acpt_stat;
+register struct rpc_err *error;
{
switch (acpt_stat) {
@@ -215,14 +209,13 @@ accepted(acpt_stat, error)
}
/* something's wrong, but we don't know what ... */
error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)MSG_ACCEPTED;
- error->re_lb.s2 = (long)acpt_stat;
+ error->re_lb.s1 = (long) MSG_ACCEPTED;
+ error->re_lb.s2 = (long) acpt_stat;
}
-static void
-rejected(rjct_stat, error)
- register enum reject_stat rjct_stat;
- register struct rpc_err *error;
+static void rejected(rjct_stat, error)
+register enum reject_stat rjct_stat;
+register struct rpc_err *error;
{
switch (rjct_stat) {
@@ -237,17 +230,16 @@ rejected(rjct_stat, error)
}
/* something's wrong, but we don't know what ... */
error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)MSG_DENIED;
- error->re_lb.s2 = (long)rjct_stat;
+ error->re_lb.s1 = (long) MSG_DENIED;
+ error->re_lb.s2 = (long) rjct_stat;
}
/*
* given a reply message, fills in the error
*/
-void
-_seterr_reply(msg, error)
- register struct rpc_msg *msg;
- register struct rpc_err *error;
+void _seterr_reply(msg, error)
+register struct rpc_msg *msg;
+register struct rpc_err *error;
{
/* optimized for normal, SUCCESSful case */
@@ -267,7 +259,7 @@ _seterr_reply(msg, error)
default:
error->re_status = RPC_FAILED;
- error->re_lb.s1 = (long)(msg->rm_reply.rp_stat);
+ error->re_lb.s1 = (long) (msg->rm_reply.rp_stat);
break;
}
switch (error->re_status) {
diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c
index 9d0092d8a..1ba12efd5 100644
--- a/libc/inet/rpc/svc.c
+++ b/libc/inet/rpc/svc.c
@@ -56,10 +56,10 @@ static SVCXPRT **xports;
#define NOFILE 32
static SVCXPRT *xports[NOFILE];
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
#define NULL_SVC ((struct svc_callout *)0)
-#define RQCRED_SIZE 400 /* this size is excessive */
+#define RQCRED_SIZE 400 /* this size is excessive */
/*
* The services list
@@ -69,9 +69,9 @@ static SVCXPRT *xports[NOFILE];
*/
static struct svc_callout {
struct svc_callout *sc_next;
- u_long sc_prog;
- u_long sc_vers;
- void (*sc_dispatch)();
+ u_long sc_prog;
+ u_long sc_vers;
+ void (*sc_dispatch) ();
} *svc_head;
static struct svc_callout *svc_find();
@@ -81,9 +81,8 @@ static struct svc_callout *svc_find();
/*
* Activate a transport handle.
*/
-void
-xprt_register(xprt)
- SVCXPRT *xprt;
+void xprt_register(xprt)
+SVCXPRT *xprt;
{
register int sock = xprt->xp_sock;
@@ -101,30 +100,29 @@ xprt_register(xprt)
xports[sock] = xprt;
svc_fds |= (1 << sock);
}
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
}
/*
* De-activate a transport handle.
*/
-void
-xprt_unregister(xprt)
- SVCXPRT *xprt;
-{
+void xprt_unregister(xprt)
+SVCXPRT *xprt;
+{
register int sock = xprt->xp_sock;
#ifdef FD_SETSIZE
if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) {
- xports[sock] = (SVCXPRT *)0;
+ xports[sock] = (SVCXPRT *) 0;
FD_CLR(sock, &svc_fdset);
}
#else
if ((sock < NOFILE) && (xports[sock] == xprt)) {
- xports[sock] = (SVCXPRT *)0;
+ xports[sock] = (SVCXPRT *) 0;
svc_fds &= ~(1 << sock);
}
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
}
@@ -135,24 +133,24 @@ xprt_unregister(xprt)
* The dispatch routine will be called when a rpc request for this
* program number comes in.
*/
-bool_t
-svc_register(xprt, prog, vers, dispatch, protocol)
- SVCXPRT *xprt;
- u_long prog;
- u_long vers;
- void (*dispatch)();
- int protocol;
+bool_t svc_register(xprt, prog, vers, dispatch, protocol)
+SVCXPRT *xprt;
+u_long prog;
+u_long vers;
+void (*dispatch) ();
+int protocol;
{
struct svc_callout *prev;
register struct svc_callout *s;
if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) {
if (s->sc_dispatch == dispatch)
- goto pmap_it; /* he is registering another xptr */
+ goto pmap_it; /* he is registering another xptr */
return (FALSE);
}
- s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout));
- if (s == (struct svc_callout *)0) {
+ s = (struct svc_callout *) mem_alloc(sizeof(struct svc_callout));
+
+ if (s == (struct svc_callout *) 0) {
return (FALSE);
}
s->sc_prog = prog;
@@ -160,7 +158,7 @@ svc_register(xprt, prog, vers, dispatch, protocol)
s->sc_dispatch = dispatch;
s->sc_next = svc_head;
svc_head = s;
-pmap_it:
+ pmap_it:
/* now register the information with the local binder service */
if (protocol) {
return (pmap_set(prog, vers, protocol, xprt->xp_port));
@@ -171,10 +169,9 @@ pmap_it:
/*
* Remove a service program from the callout list.
*/
-void
-svc_unregister(prog, vers)
- u_long prog;
- u_long vers;
+void svc_unregister(prog, vers)
+u_long prog;
+u_long vers;
{
struct svc_callout *prev;
register struct svc_callout *s;
@@ -188,19 +185,19 @@ svc_unregister(prog, vers)
}
s->sc_next = NULL_SVC;
mem_free((char *) s, (u_int) sizeof(struct svc_callout));
+
/* now unregister the information with the local binder service */
- (void)pmap_unset(prog, vers);
+ (void) pmap_unset(prog, vers);
}
/*
* Search the callout list for a program number, return the callout
* struct.
*/
-static struct svc_callout *
-svc_find(prog, vers, prev)
- u_long prog;
- u_long vers;
- struct svc_callout **prev;
+static struct svc_callout *svc_find(prog, vers, prev)
+u_long prog;
+u_long vers;
+struct svc_callout **prev;
{
register struct svc_callout *s, *p;
@@ -210,7 +207,7 @@ svc_find(prog, vers, prev)
goto done;
p = s;
}
-done:
+ done:
*prev = p;
return (s);
}
@@ -220,29 +217,27 @@ done:
/*
* Send a reply to an rpc request
*/
-bool_t
-svc_sendreply(xprt, xdr_results, xdr_location)
- register SVCXPRT *xprt;
- xdrproc_t xdr_results;
- caddr_t xdr_location;
+bool_t svc_sendreply(xprt, xdr_results, xdr_location)
+register SVCXPRT *xprt;
+xdrproc_t xdr_results;
+caddr_t xdr_location;
{
- struct rpc_msg rply;
+ struct rpc_msg rply;
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
+ rply.rm_direction = REPLY;
+ rply.rm_reply.rp_stat = MSG_ACCEPTED;
+ rply.acpted_rply.ar_verf = xprt->xp_verf;
rply.acpted_rply.ar_stat = SUCCESS;
rply.acpted_rply.ar_results.where = xdr_location;
rply.acpted_rply.ar_results.proc = xdr_results;
- return (SVC_REPLY(xprt, &rply));
+ return (SVC_REPLY(xprt, &rply));
}
/*
* No procedure error reply
*/
-void
-svcerr_noproc(xprt)
- register SVCXPRT *xprt;
+void svcerr_noproc(xprt)
+register SVCXPRT *xprt;
{
struct rpc_msg rply;
@@ -256,42 +251,39 @@ svcerr_noproc(xprt)
/*
* Can't decode args error reply
*/
-void
-svcerr_decode(xprt)
- register SVCXPRT *xprt;
+void svcerr_decode(xprt)
+register SVCXPRT *xprt;
{
- struct rpc_msg rply;
+ struct rpc_msg rply;
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
+ rply.rm_direction = REPLY;
+ rply.rm_reply.rp_stat = MSG_ACCEPTED;
rply.acpted_rply.ar_verf = xprt->xp_verf;
rply.acpted_rply.ar_stat = GARBAGE_ARGS;
- SVC_REPLY(xprt, &rply);
+ SVC_REPLY(xprt, &rply);
}
/*
* Some system error
*/
-void
-svcerr_systemerr(xprt)
- register SVCXPRT *xprt;
+void svcerr_systemerr(xprt)
+register SVCXPRT *xprt;
{
- struct rpc_msg rply;
+ struct rpc_msg rply;
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
+ rply.rm_direction = REPLY;
+ rply.rm_reply.rp_stat = MSG_ACCEPTED;
rply.acpted_rply.ar_verf = xprt->xp_verf;
rply.acpted_rply.ar_stat = SYSTEM_ERR;
- SVC_REPLY(xprt, &rply);
+ SVC_REPLY(xprt, &rply);
}
/*
* Authentication error reply
*/
-void
-svcerr_auth(xprt, why)
- SVCXPRT *xprt;
- enum auth_stat why;
+void svcerr_auth(xprt, why)
+SVCXPRT *xprt;
+enum auth_stat why;
{
struct rpc_msg rply;
@@ -305,9 +297,8 @@ svcerr_auth(xprt, why)
/*
* Auth too weak error reply
*/
-void
-svcerr_weakauth(xprt)
- SVCXPRT *xprt;
+void svcerr_weakauth(xprt)
+SVCXPRT *xprt;
{
svcerr_auth(xprt, AUTH_TOOWEAK);
@@ -316,15 +307,14 @@ svcerr_weakauth(xprt)
/*
* Program unavailable error reply
*/
-void
-svcerr_noprog(xprt)
- register SVCXPRT *xprt;
+void svcerr_noprog(xprt)
+register SVCXPRT *xprt;
{
- struct rpc_msg rply;
+ struct rpc_msg rply;
- rply.rm_direction = REPLY;
- rply.rm_reply.rp_stat = MSG_ACCEPTED;
- rply.acpted_rply.ar_verf = xprt->xp_verf;
+ rply.rm_direction = REPLY;
+ rply.rm_reply.rp_stat = MSG_ACCEPTED;
+ rply.acpted_rply.ar_verf = xprt->xp_verf;
rply.acpted_rply.ar_stat = PROG_UNAVAIL;
SVC_REPLY(xprt, &rply);
}
@@ -332,11 +322,10 @@ svcerr_noprog(xprt)
/*
* Program version mismatch error reply
*/
-void
-svcerr_progvers(xprt, low_vers, high_vers)
- register SVCXPRT *xprt;
- u_long low_vers;
- u_long high_vers;
+void svcerr_progvers(xprt, low_vers, high_vers)
+register SVCXPRT *xprt;
+u_long low_vers;
+u_long high_vers;
{
struct rpc_msg rply;
@@ -367,9 +356,8 @@ svcerr_progvers(xprt, low_vers, high_vers)
* is mallocated in kernel land.
*/
-void
-svc_getreq(rdfds)
- int rdfds;
+void svc_getreq(rdfds)
+int rdfds;
{
#ifdef FD_SETSIZE
fd_set readfds;
@@ -386,19 +374,18 @@ svc_getreq(rdfds)
int readfds = rdfds & svc_fds;
svc_getreqset(&readfds);
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
}
-void
-svc_getreqset(readfds)
+void svc_getreqset(readfds)
#ifdef FD_SETSIZE
- fd_set *readfds;
+fd_set *readfds;
{
#else
- int *readfds;
+int *readfds;
{
- int readfds_local = *readfds;
-#endif /* def FD_SETSIZE */
+ int readfds_local = *readfds;
+#endif /* def FD_SETSIZE */
enum xprt_stat stat;
struct rpc_msg msg;
int prog_found;
@@ -411,82 +398,82 @@ svc_getreqset(readfds)
register u_long *maskp;
register int setsize;
register int sock;
- char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];
+ char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE];
+
msg.rm_call.cb_cred.oa_base = cred_area;
msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
- r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
+ r.rq_clntcred = &(cred_area[2 * MAX_AUTH_BYTES]);
#ifdef FD_SETSIZE
- setsize = _rpc_dtablesize();
+ setsize = _rpc_dtablesize();
#ifdef __linux__
/*#define NFDBITS 32*/
- maskp = (u_long *)readfds;
+ maskp = (u_long *) readfds;
#else
- maskp = (u_long *)readfds->fds_bits;
+ maskp = (u_long *) readfds->fds_bits;
#endif
for (sock = 0; sock < setsize; sock += NFDBITS) {
- for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) {
- /* sock has input waiting */
- xprt = xports[sock + bit - 1];
+ for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) {
+ /* sock has input waiting */
+ xprt = xports[sock + bit - 1];
#else
for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) {
- if ((readfds_local & 1) != 0) {
- /* sock has input waiting */
- xprt = xports[sock];
-#endif /* def FD_SETSIZE */
- /* now receive msgs from xprtprt (support batch calls) */
- do {
- if (SVC_RECV(xprt, &msg)) {
-
- /* now find the exported program and call it */
- register struct svc_callout *s;
- enum auth_stat why;
-
- r.rq_xprt = xprt;
- r.rq_prog = msg.rm_call.cb_prog;
- r.rq_vers = msg.rm_call.cb_vers;
- r.rq_proc = msg.rm_call.cb_proc;
- r.rq_cred = msg.rm_call.cb_cred;
- /* first authenticate the message */
- if ((why= _authenticate(&r, &msg)) != AUTH_OK) {
- svcerr_auth(xprt, why);
- goto call_done;
+ if ((readfds_local & 1) != 0) {
+ /* sock has input waiting */
+ xprt = xports[sock];
+#endif /* def FD_SETSIZE */
+ /* now receive msgs from xprtprt (support batch calls) */
+ do {
+ if (SVC_RECV(xprt, &msg)) {
+
+ /* now find the exported program and call it */
+ register struct svc_callout *s;
+ enum auth_stat why;
+
+ r.rq_xprt = xprt;
+ r.rq_prog = msg.rm_call.cb_prog;
+ r.rq_vers = msg.rm_call.cb_vers;
+ r.rq_proc = msg.rm_call.cb_proc;
+ r.rq_cred = msg.rm_call.cb_cred;
+ /* first authenticate the message */
+ if ((why = _authenticate(&r, &msg)) != AUTH_OK) {
+ svcerr_auth(xprt, why);
+ goto call_done;
+ }
+ /* now match message with a registered service */
+ prog_found = FALSE;
+ low_vers = 0 - 1;
+ high_vers = 0;
+ for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
+ if (s->sc_prog == r.rq_prog) {
+ if (s->sc_vers == r.rq_vers) {
+ (*s->sc_dispatch) (&r, xprt);
+ goto call_done;
+ } /* found correct version */
+ prog_found = TRUE;
+ if (s->sc_vers < low_vers)
+ low_vers = s->sc_vers;
+ if (s->sc_vers > high_vers)
+ high_vers = s->sc_vers;
+ } /* found correct program */
+ }
+ /*
+ * if we got here, the program or version
+ * is not served ...
+ */
+ if (prog_found)
+ svcerr_progvers(xprt, low_vers, high_vers);
+ else
+ svcerr_noprog(xprt);
+ /* Fall through to ... */
}
- /* now match message with a registered service*/
- prog_found = FALSE;
- low_vers = 0 - 1;
- high_vers = 0;
- for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
- if (s->sc_prog == r.rq_prog) {
- if (s->sc_vers == r.rq_vers) {
- (*s->sc_dispatch)(&r, xprt);
- goto call_done;
- } /* found correct version */
- prog_found = TRUE;
- if (s->sc_vers < low_vers)
- low_vers = s->sc_vers;
- if (s->sc_vers > high_vers)
- high_vers = s->sc_vers;
- } /* found correct program */
+ call_done:
+ if ((stat = SVC_STAT(xprt)) == XPRT_DIED) {
+ SVC_DESTROY(xprt);
+ break;
}
- /*
- * if we got here, the program or version
- * is not served ...
- */
- if (prog_found)
- svcerr_progvers(xprt,
- low_vers, high_vers);
- else
- svcerr_noprog(xprt);
- /* Fall through to ... */
- }
- call_done:
- if ((stat = SVC_STAT(xprt)) == XPRT_DIED){
- SVC_DESTROY(xprt);
- break;
- }
- } while (stat == XPRT_MOREREQS);
- }
+ } while (stat == XPRT_MOREREQS);
+ }
}
}
diff --git a/libc/inet/rpc/svc_auth.c b/libc/inet/rpc/svc_auth.c
index ab7ab6942..60e4fa74b 100644
--- a/libc/inet/rpc/svc_auth.c
+++ b/libc/inet/rpc/svc_auth.c
@@ -1,5 +1,7 @@
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -54,18 +56,19 @@ static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/
*
*/
-enum auth_stat _svcauth_null(); /* no authentication */
-enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */
+enum auth_stat _svcauth_null(); /* no authentication */
+enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */
enum auth_stat _svcauth_short(); /* short hand unix style */
static struct {
- enum auth_stat (*authenticator)();
+ enum auth_stat (*authenticator) ();
} svcauthsw[] = {
- _svcauth_null, /* AUTH_NULL */
- _svcauth_unix, /* AUTH_UNIX */
- _svcauth_short, /* AUTH_SHORT */
+ _svcauth_null, /* AUTH_NULL */
+ _svcauth_unix, /* AUTH_UNIX */
+ _svcauth_short, /* AUTH_SHORT */
};
-#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */
+
+#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */
/*
@@ -86,10 +89,9 @@ static struct {
* There is an assumption that any flavour less than AUTH_NULL is
* invalid.
*/
-enum auth_stat
-_authenticate(rqst, msg)
- register struct svc_req *rqst;
- struct rpc_msg *msg;
+enum auth_stat _authenticate(rqst, msg)
+register struct svc_req *rqst;
+struct rpc_msg *msg;
{
register int cred_flavor;
@@ -98,16 +100,15 @@ _authenticate(rqst, msg)
rqst->rq_xprt->xp_verf.oa_length = 0;
cred_flavor = rqst->rq_cred.oa_flavor;
if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) {
- return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg));
+ return ((*(svcauthsw[cred_flavor].authenticator)) (rqst, msg));
}
return (AUTH_REJECTEDCRED);
}
-enum auth_stat
-_svcauth_null(/*rqst, msg*/)
+enum auth_stat _svcauth_null( /*rqst, msg */ )
/*struct svc_req *rqst;
- struct rpc_msg *msg;*/
+ struct rpc_msg *msg; */
{
return (AUTH_OK);
diff --git a/libc/inet/rpc/svc_auth_unix.c b/libc/inet/rpc/svc_auth_unix.c
index ea00b7895..212f9cb3a 100644
--- a/libc/inet/rpc/svc_auth_unix.c
+++ b/libc/inet/rpc/svc_auth_unix.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
#endif
/*
@@ -48,10 +50,9 @@ static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
/*
* Unix longhand authenticator
*/
-enum auth_stat
-_svcauth_unix(rqst, msg)
- register struct svc_req *rqst;
- register struct rpc_msg *msg;
+enum auth_stat _svcauth_unix(rqst, msg)
+register struct svc_req *rqst;
+register struct rpc_msg *msg;
{
register enum auth_stat stat;
XDR xdrs;
@@ -59,7 +60,7 @@ _svcauth_unix(rqst, msg)
register long *buf;
struct area {
struct authunix_parms area_aup;
- char area_machname[MAX_MACHINE_NAME+1];
+ char area_machname[MAX_MACHINE_NAME + 1];
int area_gids[NGRPS];
} *area;
u_int auth_len;
@@ -70,8 +71,9 @@ _svcauth_unix(rqst, msg)
aup = &area->area_aup;
aup->aup_machname = area->area_machname;
aup->aup_gids = area->area_gids;
- auth_len = (u_int)msg->rm_call.cb_cred.oa_length;
- xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE);
+ auth_len = (u_int) msg->rm_call.cb_cred.oa_length;
+ xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,
+ XDR_DECODE);
buf = XDR_INLINE(&xdrs, auth_len);
if (buf != NULL) {
aup->aup_time = IXDR_GET_LONG(buf);
@@ -80,10 +82,11 @@ _svcauth_unix(rqst, msg)
stat = AUTH_BADCRED;
goto done;
}
- bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len);
+ bcopy((caddr_t) buf, aup->aup_machname, (u_int) str_len);
aup->aup_machname[str_len] = 0;
str_len = RNDUP(str_len);
- buf += str_len / sizeof (long);
+ buf += str_len / sizeof(long);
+
aup->aup_uid = IXDR_GET_LONG(buf);
aup->aup_gid = IXDR_GET_LONG(buf);
gid_len = IXDR_GET_U_LONG(buf);
@@ -101,20 +104,20 @@ _svcauth_unix(rqst, msg)
*/
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) {
(void) printf("bad auth_len gid %d str %d auth %d\n",
- gid_len, str_len, auth_len);
+ gid_len, str_len, auth_len);
stat = AUTH_BADCRED;
goto done;
}
- } else if (! xdr_authunix_parms(&xdrs, aup)) {
+ } else if (!xdr_authunix_parms(&xdrs, aup)) {
xdrs.x_op = XDR_FREE;
- (void)xdr_authunix_parms(&xdrs, aup);
+ (void) xdr_authunix_parms(&xdrs, aup);
stat = AUTH_BADCRED;
goto done;
}
rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL;
rqst->rq_xprt->xp_verf.oa_length = 0;
stat = AUTH_OK;
-done:
+ done:
XDR_DESTROY(&xdrs);
return (stat);
}
@@ -124,11 +127,9 @@ done:
* Shorthand unix authenticator
* Looks up longhand in a cache.
*/
-/*ARGSUSED*/
-enum auth_stat
-_svcauth_short(rqst, msg)
- struct svc_req *rqst;
- struct rpc_msg *msg;
+ /*ARGSUSED*/ enum auth_stat _svcauth_short(rqst, msg)
+struct svc_req *rqst;
+struct rpc_msg *msg;
{
return (AUTH_REJECTEDCRED);
}
diff --git a/libc/inet/rpc/svc_raw.c b/libc/inet/rpc/svc_raw.c
index 1170ecec8..c13ea5e06 100644
--- a/libc/inet/rpc/svc_raw.c
+++ b/libc/inet/rpc/svc_raw.c
@@ -47,18 +47,18 @@ static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";
* This is the "network" that we will be moving data over
*/
static struct svcraw_private {
- char _raw_buf[UDPMSGSIZE];
- SVCXPRT server;
- XDR xdr_stream;
- char verf_body[MAX_AUTH_BYTES];
+ char _raw_buf[UDPMSGSIZE];
+ SVCXPRT server;
+ XDR xdr_stream;
+ char verf_body[MAX_AUTH_BYTES];
} *svcraw_private;
-static bool_t svcraw_recv();
-static enum xprt_stat svcraw_stat();
-static bool_t svcraw_getargs();
-static bool_t svcraw_reply();
-static bool_t svcraw_freeargs();
-static void svcraw_destroy();
+static bool_t svcraw_recv();
+static enum xprt_stat svcraw_stat();
+static bool_t svcraw_getargs();
+static bool_t svcraw_reply();
+static bool_t svcraw_freeargs();
+static void svcraw_destroy();
static struct xp_ops server_ops = {
svcraw_recv,
@@ -69,13 +69,12 @@ static struct xp_ops server_ops = {
svcraw_destroy
};
-SVCXPRT *
-svcraw_create()
+SVCXPRT *svcraw_create()
{
register struct svcraw_private *srp = svcraw_private;
if (srp == 0) {
- srp = (struct svcraw_private *)calloc(1, sizeof (*srp));
+ srp = (struct svcraw_private *) calloc(1, sizeof(*srp));
if (srp == 0)
return (0);
}
@@ -87,17 +86,15 @@ svcraw_create()
return (&srp->server);
}
-static enum xprt_stat
-svcraw_stat()
+static enum xprt_stat svcraw_stat()
{
return (XPRT_IDLE);
}
-static bool_t
-svcraw_recv(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+static bool_t svcraw_recv(xprt, msg)
+SVCXPRT *xprt;
+struct rpc_msg *msg;
{
register struct svcraw_private *srp = svcraw_private;
register XDR *xdrs;
@@ -107,15 +104,14 @@ svcraw_recv(xprt, msg)
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_DECODE;
XDR_SETPOS(xdrs, 0);
- if (! xdr_callmsg(xdrs, msg))
- return (FALSE);
+ if (!xdr_callmsg(xdrs, msg))
+ return (FALSE);
return (TRUE);
}
-static bool_t
-svcraw_reply(xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+static bool_t svcraw_reply(xprt, msg)
+SVCXPRT *xprt;
+struct rpc_msg *msg;
{
register struct svcraw_private *srp = svcraw_private;
register XDR *xdrs;
@@ -125,31 +121,29 @@ svcraw_reply(xprt, msg)
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, 0);
- if (! xdr_replymsg(xdrs, msg))
- return (FALSE);
- (void)XDR_GETPOS(xdrs); /* called just for overhead */
+ if (!xdr_replymsg(xdrs, msg))
+ return (FALSE);
+ (void) XDR_GETPOS(xdrs); /* called just for overhead */
return (TRUE);
}
-static bool_t
-svcraw_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+static bool_t svcraw_getargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
{
register struct svcraw_private *srp = svcraw_private;
if (srp == 0)
return (FALSE);
- return ((*xdr_args)(&srp->xdr_stream, args_ptr));
+ return ((*xdr_args) (&srp->xdr_stream, args_ptr));
}
-static bool_t
-svcraw_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
-{
+static bool_t svcraw_freeargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
+{
register struct svcraw_private *srp = svcraw_private;
register XDR *xdrs;
@@ -157,10 +151,9 @@ svcraw_freeargs(xprt, xdr_args, args_ptr)
return (FALSE);
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
-}
+ return ((*xdr_args) (xdrs, args_ptr));
+}
-static void
-svcraw_destroy()
+static void svcraw_destroy()
{
}
diff --git a/libc/inet/rpc/svc_run.c b/libc/inet/rpc/svc_run.c
index c1c3e0478..092fcb9a8 100644
--- a/libc/inet/rpc/svc_run.c
+++ b/libc/inet/rpc/svc_run.c
@@ -39,14 +39,13 @@ static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
#include <rpc/rpc.h>
#include <sys/errno.h>
-void
-svc_run()
+void svc_run()
{
#ifdef FD_SETSIZE
fd_set readfds;
#else
- int readfds;
-#endif /* def FD_SETSIZE */
+ int readfds;
+#endif /* def FD_SETSIZE */
extern int errno;
for (;;) {
@@ -54,9 +53,9 @@ svc_run()
readfds = svc_fdset;
#else
readfds = svc_fds;
-#endif /* def FD_SETSIZE */
- switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0,
- (struct timeval *)0)) {
+#endif /* def FD_SETSIZE */
+ switch (select(_rpc_dtablesize(), &readfds, (int *) 0, (int *) 0,
+ (struct timeval *) 0)) {
case -1:
if (errno == EINTR) {
continue;
diff --git a/libc/inet/rpc/svc_simple.c b/libc/inet/rpc/svc_simple.c
index d6bcbd3c0..3c75de3f0 100644
--- a/libc/inet/rpc/svc_simple.c
+++ b/libc/inet/rpc/svc_simple.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -44,9 +46,9 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
#include <netdb.h>
static struct proglst {
- char *(*p_progname)();
- int p_prognum;
- int p_procnum;
+ char *(*p_progname) ();
+ int p_prognum;
+ int p_procnum;
xdrproc_t p_inproc, p_outproc;
struct proglst *p_nxt;
} *proglst;
@@ -55,13 +57,13 @@ static SVCXPRT *transp;
struct proglst *pl;
registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
- char *(*progname)();
- xdrproc_t inproc, outproc;
+char *(*progname) ();
+xdrproc_t inproc, outproc;
{
-
+
if (procnum == NULLPROC) {
(void) fprintf(stderr,
- "can't reassign procedure number %d\n", NULLPROC);
+ "can't reassign procedure number %d\n", NULLPROC);
return (-1);
}
if (transp == 0) {
@@ -71,14 +73,15 @@ registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
return (-1);
}
}
- (void) pmap_unset((u_long)prognum, (u_long)versnum);
- if (!svc_register(transp, (u_long)prognum, (u_long)versnum,
- universal, IPPROTO_UDP)) {
- (void) fprintf(stderr, "couldn't register prog %d vers %d\n",
- prognum, versnum);
+ (void) pmap_unset((u_long) prognum, (u_long) versnum);
+ if (!svc_register(transp, (u_long) prognum, (u_long) versnum,
+ universal, IPPROTO_UDP)) {
+ (void) fprintf(stderr, "couldn't register prog %d vers %d\n",
+ prognum, versnum);
return (-1);
}
- pl = (struct proglst *)malloc(sizeof(struct proglst));
+ pl = (struct proglst *) malloc(sizeof(struct proglst));
+
if (pl == NULL) {
(void) fprintf(stderr, "registerrpc: out of memory\n");
return (-1);
@@ -93,10 +96,9 @@ registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
return (0);
}
-static void
-universal(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
+static void universal(rqstp, transp)
+struct svc_req *rqstp;
+SVCXPRT *transp;
{
int prog, proc;
char *outdata;
@@ -107,7 +109,7 @@ universal(rqstp, transp)
* enforce "procnum 0 is echo" convention
*/
if (rqstp->rq_proc == NULLPROC) {
- if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) {
+ if (svc_sendreply(transp, xdr_void, (char *) NULL) == FALSE) {
(void) fprintf(stderr, "xxx\n");
exit(1);
}
@@ -118,26 +120,25 @@ universal(rqstp, transp)
for (pl = proglst; pl != NULL; pl = pl->p_nxt)
if (pl->p_prognum == prog && pl->p_procnum == proc) {
/* decode arguments into a CLEAN buffer */
- bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */
+ bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */
if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) {
svcerr_decode(transp);
return;
}
- outdata = (*(pl->p_progname))(xdrbuf);
+ outdata = (*(pl->p_progname)) (xdrbuf);
if (outdata == NULL && pl->p_outproc != xdr_void)
/* there was an error */
return;
if (!svc_sendreply(transp, pl->p_outproc, outdata)) {
(void) fprintf(stderr,
- "trouble replying to prog %d\n",
- pl->p_prognum);
+ "trouble replying to prog %d\n",
+ pl->p_prognum);
exit(1);
}
/* free the decoded arguments */
- (void)svc_freeargs(transp, pl->p_inproc, xdrbuf);
+ (void) svc_freeargs(transp, pl->p_inproc, xdrbuf);
return;
}
(void) fprintf(stderr, "never registered prog %d\n", prog);
exit(1);
}
-
diff --git a/libc/inet/rpc/svc_tcp.c b/libc/inet/rpc/svc_tcp.c
index 837e70c82..0008eaa0c 100644
--- a/libc/inet/rpc/svc_tcp.c
+++ b/libc/inet/rpc/svc_tcp.c
@@ -51,12 +51,12 @@ extern errno;
/*
* Ops vector for TCP/IP based rpc service handle
*/
-static bool_t svctcp_recv();
-static enum xprt_stat svctcp_stat();
-static bool_t svctcp_getargs();
-static bool_t svctcp_reply();
-static bool_t svctcp_freeargs();
-static void svctcp_destroy();
+static bool_t svctcp_recv();
+static enum xprt_stat svctcp_stat();
+static bool_t svctcp_getargs();
+static bool_t svctcp_reply();
+static bool_t svctcp_freeargs();
+static void svctcp_destroy();
static struct xp_ops svctcp_op = {
svctcp_recv,
@@ -70,8 +70,8 @@ static struct xp_ops svctcp_op = {
/*
* Ops vector for TCP/IP rendezvous handler
*/
-static bool_t rendezvous_request();
-static enum xprt_stat rendezvous_stat();
+static bool_t rendezvous_request();
+static enum xprt_stat rendezvous_stat();
static struct xp_ops svctcp_rendezvous_op = {
rendezvous_request,
@@ -85,12 +85,12 @@ static struct xp_ops svctcp_rendezvous_op = {
static int readtcp(), writetcp();
static SVCXPRT *makefd_xprt();
-struct tcp_rendezvous { /* kept in xprt->xp_p1 */
+struct tcp_rendezvous { /* kept in xprt->xp_p1 */
u_int sendsize;
u_int recvsize;
};
-struct tcp_conn { /* kept in xprt->xp_p1 */
+struct tcp_conn { /* kept in xprt->xp_p1 */
enum xprt_stat strm_stat;
u_long x_id;
XDR xdrs;
@@ -117,11 +117,10 @@ struct tcp_conn { /* kept in xprt->xp_p1 */
* how big the send and receive buffers are via the second and third parms;
* 0 => use the system default.
*/
-SVCXPRT *
-svctcp_create(sock, sendsize, recvsize)
- register int sock;
- u_int sendsize;
- u_int recvsize;
+SVCXPRT *svctcp_create(sock, sendsize, recvsize)
+register int sock;
+u_int sendsize;
+u_int recvsize;
{
bool_t madesock = FALSE;
register SVCXPRT *xprt;
@@ -132,37 +131,37 @@ svctcp_create(sock, sendsize, recvsize)
if (sock == RPC_ANYSOCK) {
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
perror("svc_tcp.c - tcp socket creation problem");
- return ((SVCXPRT *)NULL);
+ return ((SVCXPRT *) NULL);
}
madesock = TRUE;
}
- bzero((char *)&addr, sizeof (addr));
+ bzero((char *) &addr, sizeof(addr));
addr.sin_family = AF_INET;
if (bindresvport(sock, &addr)) {
addr.sin_port = 0;
- (void)bind(sock, (struct sockaddr *)&addr, len);
+ (void) bind(sock, (struct sockaddr *) &addr, len);
}
- if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) ||
- (listen(sock, 2) != 0)) {
+ if ((getsockname(sock, (struct sockaddr *) &addr, &len) != 0) ||
+ (listen(sock, 2) != 0)) {
perror("svctcp_.c - cannot getsockname or listen");
if (madesock)
- (void)close(sock);
- return ((SVCXPRT *)NULL);
+ (void) close(sock);
+ return ((SVCXPRT *) NULL);
}
- r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r));
+ r = (struct tcp_rendezvous *) mem_alloc(sizeof(*r));
if (r == NULL) {
(void) fprintf(stderr, "svctcp_create: out of memory\n");
return (NULL);
}
r->sendsize = sendsize;
r->recvsize = recvsize;
- xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
+ xprt = (SVCXPRT *) mem_alloc(sizeof(SVCXPRT));
if (xprt == NULL) {
(void) fprintf(stderr, "svctcp_create: out of memory\n");
return (NULL);
}
xprt->xp_p2 = NULL;
- xprt->xp_p1 = (caddr_t)r;
+ xprt->xp_p1 = (caddr_t) r;
xprt->xp_verf = _null_auth;
xprt->xp_ops = &svctcp_rendezvous_op;
xprt->xp_port = ntohs(addr.sin_port);
@@ -175,69 +174,68 @@ svctcp_create(sock, sendsize, recvsize)
* Like svtcp_create(), except the routine takes any *open* UNIX file
* descriptor as its first input.
*/
-SVCXPRT *
-svcfd_create(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+SVCXPRT *svcfd_create(fd, sendsize, recvsize)
+int fd;
+u_int sendsize;
+u_int recvsize;
{
return (makefd_xprt(fd, sendsize, recvsize));
}
-static SVCXPRT *
-makefd_xprt(fd, sendsize, recvsize)
- int fd;
- u_int sendsize;
- u_int recvsize;
+static SVCXPRT *makefd_xprt(fd, sendsize, recvsize)
+int fd;
+u_int sendsize;
+u_int recvsize;
{
register SVCXPRT *xprt;
register struct tcp_conn *cd;
-
- xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
- if (xprt == (SVCXPRT *)NULL) {
+
+ xprt = (SVCXPRT *) mem_alloc(sizeof(SVCXPRT));
+ if (xprt == (SVCXPRT *) NULL) {
(void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n");
goto done;
}
- cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn));
- if (cd == (struct tcp_conn *)NULL) {
+ cd = (struct tcp_conn *) mem_alloc(sizeof(struct tcp_conn));
+
+ if (cd == (struct tcp_conn *) NULL) {
(void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n");
mem_free((char *) xprt, sizeof(SVCXPRT));
- xprt = (SVCXPRT *)NULL;
+ xprt = (SVCXPRT *) NULL;
goto done;
}
cd->strm_stat = XPRT_IDLE;
xdrrec_create(&(cd->xdrs), sendsize, recvsize,
- (caddr_t)xprt, readtcp, writetcp);
+ (caddr_t) xprt, readtcp, writetcp);
xprt->xp_p2 = NULL;
- xprt->xp_p1 = (caddr_t)cd;
+ xprt->xp_p1 = (caddr_t) cd;
xprt->xp_verf.oa_base = cd->verf_body;
xprt->xp_addrlen = 0;
- xprt->xp_ops = &svctcp_op; /* truely deals with calls */
- xprt->xp_port = 0; /* this is a connection, not a rendezvouser */
+ xprt->xp_ops = &svctcp_op; /* truely deals with calls */
+ xprt->xp_port = 0; /* this is a connection, not a rendezvouser */
xprt->xp_sock = fd;
xprt_register(xprt);
- done:
+ done:
return (xprt);
}
-static bool_t
-rendezvous_request(xprt)
- register SVCXPRT *xprt;
+static bool_t rendezvous_request(xprt)
+register SVCXPRT *xprt;
{
int sock;
struct tcp_rendezvous *r;
struct sockaddr_in addr;
int len;
- r = (struct tcp_rendezvous *)xprt->xp_p1;
- again:
+ r = (struct tcp_rendezvous *) xprt->xp_p1;
+ again:
len = sizeof(struct sockaddr_in);
- if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr,
- &len)) < 0) {
+
+ if ((sock = accept(xprt->xp_sock, (struct sockaddr *) &addr,
+ &len)) < 0) {
if (errno == EINTR)
goto again;
- return (FALSE);
+ return (FALSE);
}
/*
* make a new transporter (re-uses xprt)
@@ -245,24 +243,22 @@ rendezvous_request(xprt)
xprt = makefd_xprt(sock, r->sendsize, r->recvsize);
xprt->xp_raddr = addr;
xprt->xp_addrlen = len;
- return (FALSE); /* there is never an rpc msg to be processed */
+ return (FALSE); /* there is never an rpc msg to be processed */
}
-static enum xprt_stat
-rendezvous_stat()
+static enum xprt_stat rendezvous_stat()
{
return (XPRT_IDLE);
}
-static void
-svctcp_destroy(xprt)
- register SVCXPRT *xprt;
+static void svctcp_destroy(xprt)
+register SVCXPRT *xprt;
{
- register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
+ register struct tcp_conn *cd = (struct tcp_conn *) xprt->xp_p1;
xprt_unregister(xprt);
- (void)close(xprt->xp_sock);
+ (void) close(xprt->xp_sock);
if (xprt->xp_port != 0) {
/* a rendezvouser socket */
xprt->xp_port = 0;
@@ -270,8 +266,9 @@ svctcp_destroy(xprt)
/* an actual connection socket */
XDR_DESTROY(&(cd->xdrs));
}
- mem_free((caddr_t)cd, sizeof(struct tcp_conn));
- mem_free((caddr_t)xprt, sizeof(SVCXPRT));
+ mem_free((caddr_t) cd, sizeof(struct tcp_conn));
+
+ mem_free((caddr_t) xprt, sizeof(SVCXPRT));
}
/*
@@ -285,13 +282,13 @@ static struct timeval wait_per_try = { 35, 0 };
* any error is fatal and the connection is closed.
* (And a read of zero bytes is a half closed stream => error.)
*/
-static int
-readtcp(xprt, buf, len)
- register SVCXPRT *xprt;
- caddr_t buf;
- register int len;
+static int readtcp(xprt, buf, len)
+register SVCXPRT *xprt;
+caddr_t buf;
+register int len;
{
register int sock = xprt->xp_sock;
+
#ifdef FD_SETSIZE
fd_set mask;
fd_set readfds;
@@ -301,11 +298,11 @@ readtcp(xprt, buf, len)
#else
register int mask = 1 << sock;
int readfds;
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
do {
readfds = mask;
- if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL,
- &wait_per_try) <= 0) {
+ if (select(_rpc_dtablesize(), &readfds, (int *) NULL, (int *) NULL,
+ &wait_per_try) <= 0) {
if (errno == EINTR) {
continue;
}
@@ -315,12 +312,12 @@ readtcp(xprt, buf, len)
} while (!FD_ISSET(sock, &readfds));
#else
} while (readfds != mask);
-#endif /* def FD_SETSIZE */
+#endif /* def FD_SETSIZE */
if ((len = read(sock, buf, len)) > 0) {
return (len);
}
-fatal_err:
- ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED;
+ fatal_err:
+ ((struct tcp_conn *) (xprt->xp_p1))->strm_stat = XPRT_DIED;
return (-1);
}
@@ -328,49 +325,43 @@ fatal_err:
* writes data to the tcp connection.
* Any error is fatal and the connection is closed.
*/
-static int
-writetcp(xprt, buf, len)
- register SVCXPRT *xprt;
- caddr_t buf;
- int len;
+static int writetcp(xprt, buf, len)
+register SVCXPRT *xprt;
+caddr_t buf;
+int len;
{
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = write(xprt->xp_sock, buf, cnt)) < 0) {
- ((struct tcp_conn *)(xprt->xp_p1))->strm_stat =
- XPRT_DIED;
+ ((struct tcp_conn *) (xprt->xp_p1))->strm_stat = XPRT_DIED;
return (-1);
}
}
return (len);
}
-static enum xprt_stat
-svctcp_stat(xprt)
- SVCXPRT *xprt;
+static enum xprt_stat svctcp_stat(xprt)
+SVCXPRT *xprt;
{
- register struct tcp_conn *cd =
- (struct tcp_conn *)(xprt->xp_p1);
+ register struct tcp_conn *cd = (struct tcp_conn *) (xprt->xp_p1);
if (cd->strm_stat == XPRT_DIED)
return (XPRT_DIED);
- if (! xdrrec_eof(&(cd->xdrs)))
+ if (!xdrrec_eof(&(cd->xdrs)))
return (XPRT_MOREREQS);
return (XPRT_IDLE);
}
-static bool_t
-svctcp_recv(xprt, msg)
- SVCXPRT *xprt;
- register struct rpc_msg *msg;
+static bool_t svctcp_recv(xprt, msg)
+SVCXPRT *xprt;
+register struct rpc_msg *msg;
{
- register struct tcp_conn *cd =
- (struct tcp_conn *)(xprt->xp_p1);
+ register struct tcp_conn *cd = (struct tcp_conn *) (xprt->xp_p1);
register XDR *xdrs = &(cd->xdrs);
xdrs->x_op = XDR_DECODE;
- (void)xdrrec_skiprecord(xdrs);
+ (void) xdrrec_skiprecord(xdrs);
if (xdr_callmsg(xdrs, msg)) {
cd->x_id = msg->rm_xid;
return (TRUE);
@@ -378,42 +369,38 @@ svctcp_recv(xprt, msg)
return (FALSE);
}
-static bool_t
-svctcp_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+static bool_t svctcp_getargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
{
- return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr));
+ return ((*xdr_args)
+ (&(((struct tcp_conn *) (xprt->xp_p1))->xdrs), args_ptr));
}
-static bool_t
-svctcp_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+static bool_t svctcp_freeargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
{
- register XDR *xdrs =
- &(((struct tcp_conn *)(xprt->xp_p1))->xdrs);
+ register XDR *xdrs = &(((struct tcp_conn *) (xprt->xp_p1))->xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return ((*xdr_args) (xdrs, args_ptr));
}
-static bool_t
-svctcp_reply(xprt, msg)
- SVCXPRT *xprt;
- register struct rpc_msg *msg;
+static bool_t svctcp_reply(xprt, msg)
+SVCXPRT *xprt;
+register struct rpc_msg *msg;
{
- register struct tcp_conn *cd =
- (struct tcp_conn *)(xprt->xp_p1);
+ register struct tcp_conn *cd = (struct tcp_conn *) (xprt->xp_p1);
register XDR *xdrs = &(cd->xdrs);
register bool_t stat;
xdrs->x_op = XDR_ENCODE;
msg->rm_xid = cd->x_id;
stat = xdr_replymsg(xdrs, msg);
- (void)xdrrec_endofrecord(xdrs, TRUE);
+ (void) xdrrec_endofrecord(xdrs, TRUE);
return (stat);
}
diff --git a/libc/inet/rpc/svc_udp.c b/libc/inet/rpc/svc_udp.c
index 69ef7a1ce..b8495a127 100644
--- a/libc/inet/rpc/svc_udp.c
+++ b/libc/inet/rpc/svc_udp.c
@@ -48,12 +48,12 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
#define rpc_buffer(xprt) ((xprt)->xp_p1)
#define MAX(a, b) ((a > b) ? a : b)
-static bool_t svcudp_recv();
-static bool_t svcudp_reply();
-static enum xprt_stat svcudp_stat();
-static bool_t svcudp_getargs();
-static bool_t svcudp_freeargs();
-static void svcudp_destroy();
+static bool_t svcudp_recv();
+static bool_t svcudp_reply();
+static enum xprt_stat svcudp_stat();
+static bool_t svcudp_getargs();
+static bool_t svcudp_freeargs();
+static void svcudp_destroy();
static struct xp_ops svcudp_op = {
svcudp_recv,
@@ -70,12 +70,13 @@ extern int errno;
* kept in xprt->xp_p2
*/
struct svcudp_data {
- u_int su_iosz; /* byte size of send.recv buffer */
- u_long su_xid; /* transaction id */
- XDR su_xdrs; /* XDR handle */
- char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */
- char * su_cache; /* cached data, NULL if no cache */
+ u_int su_iosz; /* byte size of send.recv buffer */
+ u_long su_xid; /* transaction id */
+ XDR su_xdrs; /* XDR handle */
+ char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */
+ char *su_cache; /* cached data, NULL if no cache */
};
+
#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2))
/*
@@ -91,10 +92,9 @@ struct svcudp_data {
* see (svc.h, xprt_register).
* The routines returns NULL if a problem occurred.
*/
-SVCXPRT *
-svcudp_bufcreate(sock, sendsz, recvsz)
- register int sock;
- u_int sendsz, recvsz;
+SVCXPRT *svcudp_bufcreate(sock, sendsz, recvsz)
+register int sock;
+u_int sendsz, recvsz;
{
bool_t madesock = FALSE;
register SVCXPRT *xprt;
@@ -105,41 +105,41 @@ svcudp_bufcreate(sock, sendsz, recvsz)
if (sock == RPC_ANYSOCK) {
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
perror("svcudp_create: socket creation problem");
- return ((SVCXPRT *)NULL);
+ return ((SVCXPRT *) NULL);
}
madesock = TRUE;
}
- bzero((char *)&addr, sizeof (addr));
+ bzero((char *) &addr, sizeof(addr));
addr.sin_family = AF_INET;
if (bindresvport(sock, &addr)) {
addr.sin_port = 0;
- (void)bind(sock, (struct sockaddr *)&addr, len);
+ (void) bind(sock, (struct sockaddr *) &addr, len);
}
- if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) {
+ if (getsockname(sock, (struct sockaddr *) &addr, &len) != 0) {
perror("svcudp_create - cannot getsockname");
if (madesock)
- (void)close(sock);
- return ((SVCXPRT *)NULL);
+ (void) close(sock);
+ return ((SVCXPRT *) NULL);
}
- xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
+ xprt = (SVCXPRT *) mem_alloc(sizeof(SVCXPRT));
if (xprt == NULL) {
- (void)fprintf(stderr, "svcudp_create: out of memory\n");
+ (void) fprintf(stderr, "svcudp_create: out of memory\n");
return (NULL);
}
- su = (struct svcudp_data *)mem_alloc(sizeof(*su));
+ su = (struct svcudp_data *) mem_alloc(sizeof(*su));
if (su == NULL) {
- (void)fprintf(stderr, "svcudp_create: out of memory\n");
+ (void) fprintf(stderr, "svcudp_create: out of memory\n");
return (NULL);
}
su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4;
if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) {
- (void)fprintf(stderr, "svcudp_create: out of memory\n");
+ (void) fprintf(stderr, "svcudp_create: out of memory\n");
return (NULL);
}
- xdrmem_create(
- &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE);
+ xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
+ XDR_DECODE);
su->su_cache = NULL;
- xprt->xp_p2 = (caddr_t)su;
+ xprt->xp_p2 = (caddr_t) su;
xprt->xp_verf.oa_base = su->su_verfbody;
xprt->xp_ops = &svcudp_op;
xprt->xp_port = ntohs(addr.sin_port);
@@ -148,26 +148,23 @@ svcudp_bufcreate(sock, sendsz, recvsz)
return (xprt);
}
-SVCXPRT *
-svcudp_create(sock)
- int sock;
+SVCXPRT *svcudp_create(sock)
+int sock;
{
- return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE));
+ return (svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE));
}
-static enum xprt_stat
-svcudp_stat(xprt)
- SVCXPRT *xprt;
+static enum xprt_stat svcudp_stat(xprt)
+SVCXPRT *xprt;
{
- return (XPRT_IDLE);
+ return (XPRT_IDLE);
}
-static bool_t
-svcudp_recv(xprt, msg)
- register SVCXPRT *xprt;
- struct rpc_msg *msg;
+static bool_t svcudp_recv(xprt, msg)
+register SVCXPRT *xprt;
+struct rpc_msg *msg;
{
register struct svcudp_data *su = su_data(xprt);
register XDR *xdrs = &(su->su_xdrs);
@@ -175,33 +172,35 @@ svcudp_recv(xprt, msg)
char *reply;
u_long replylen;
- again:
+ again:
xprt->xp_addrlen = sizeof(struct sockaddr_in);
+
rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz,
- 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen));
+ 0, (struct sockaddr *) &(xprt->xp_raddr),
+ &(xprt->xp_addrlen));
if (rlen == -1 && errno == EINTR)
goto again;
- if (rlen < 4*sizeof(u_long))
+ if (rlen < 4 * sizeof(u_long))
return (FALSE);
xdrs->x_op = XDR_DECODE;
XDR_SETPOS(xdrs, 0);
- if (! xdr_callmsg(xdrs, msg))
+ if (!xdr_callmsg(xdrs, msg))
return (FALSE);
su->su_xid = msg->rm_xid;
if (su->su_cache != NULL) {
if (cache_get(xprt, msg, &reply, &replylen)) {
(void) sendto(xprt->xp_sock, reply, (int) replylen, 0,
- (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen);
+ (struct sockaddr *) &xprt->xp_raddr,
+ xprt->xp_addrlen);
return (TRUE);
}
}
return (TRUE);
}
-static bool_t
-svcudp_reply(xprt, msg)
- register SVCXPRT *xprt;
- struct rpc_msg *msg;
+static bool_t svcudp_reply(xprt, msg)
+register SVCXPRT *xprt;
+struct rpc_msg *msg;
{
register struct svcudp_data *su = su_data(xprt);
register XDR *xdrs = &(su->su_xdrs);
@@ -212,10 +211,10 @@ svcudp_reply(xprt, msg)
XDR_SETPOS(xdrs, 0);
msg->rm_xid = su->su_xid;
if (xdr_replymsg(xdrs, msg)) {
- slen = (int)XDR_GETPOS(xdrs);
+ slen = (int) XDR_GETPOS(xdrs);
if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0,
- (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen)
- == slen) {
+ (struct sockaddr *) &(xprt->xp_raddr), xprt->xp_addrlen)
+ == slen) {
stat = TRUE;
if (su->su_cache && slen >= 0) {
cache_set(xprt, (u_long) slen);
@@ -225,40 +224,38 @@ svcudp_reply(xprt, msg)
return (stat);
}
-static bool_t
-svcudp_getargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+static bool_t svcudp_getargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
{
- return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr));
+ return ((*xdr_args) (&(su_data(xprt)->su_xdrs), args_ptr));
}
-static bool_t
-svcudp_freeargs(xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+static bool_t svcudp_freeargs(xprt, xdr_args, args_ptr)
+SVCXPRT *xprt;
+xdrproc_t xdr_args;
+caddr_t args_ptr;
{
register XDR *xdrs = &(su_data(xprt)->su_xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return ((*xdr_args) (xdrs, args_ptr));
}
-static void
-svcudp_destroy(xprt)
- register SVCXPRT *xprt;
+static void svcudp_destroy(xprt)
+register SVCXPRT *xprt;
{
register struct svcudp_data *su = su_data(xprt);
xprt_unregister(xprt);
- (void)close(xprt->xp_sock);
+ (void) close(xprt->xp_sock);
XDR_DESTROY(&(su->su_xdrs));
mem_free(rpc_buffer(xprt), su->su_iosz);
- mem_free((caddr_t)su, sizeof(struct svcudp_data));
- mem_free((caddr_t)xprt, sizeof(SVCXPRT));
+ mem_free((caddr_t) su, sizeof(struct svcudp_data));
+
+ mem_free((caddr_t) xprt, sizeof(SVCXPRT));
}
@@ -270,7 +267,7 @@ svcudp_destroy(xprt)
* Buffers are sent again if retransmissions are detected.
*/
-#define SPARSENESS 4 /* 75% sparse */
+#define SPARSENESS 4 /* 75% sparse */
#define CACHE_PERROR(msg) \
(void) fprintf(stderr,"%s\n", msg)
@@ -279,7 +276,7 @@ svcudp_destroy(xprt)
(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
#define BZERO(addr, type, size) \
- bzero((char *) addr, sizeof(type) * (int) (size))
+ bzero((char *) addr, sizeof(type) * (int) (size))
/*
* An entry in the cache
@@ -297,12 +294,12 @@ struct cache_node {
/*
* The cached reply and length
*/
- char * cache_reply;
+ char *cache_reply;
u_long cache_replylen;
/*
- * Next node on the list, if there is a collision
+ * Next node on the list, if there is a collision
*/
- cache_ptr cache_next;
+ cache_ptr cache_next;
};
@@ -311,14 +308,14 @@ struct cache_node {
* The entire cache
*/
struct udp_cache {
- u_long uc_size; /* size of cache */
- cache_ptr *uc_entries; /* hash table of entries in cache */
- cache_ptr *uc_fifo; /* fifo list of entries in cache */
- u_long uc_nextvictim; /* points to next victim in fifo list */
- u_long uc_prog; /* saved program number */
- u_long uc_vers; /* saved version number */
- u_long uc_proc; /* saved procedure number */
- struct sockaddr_in uc_addr; /* saved caller's address */
+ u_long uc_size; /* size of cache */
+ cache_ptr *uc_entries; /* hash table of entries in cache */
+ cache_ptr *uc_fifo; /* fifo list of entries in cache */
+ u_long uc_nextvictim; /* points to next victim in fifo list */
+ u_long uc_prog; /* saved program number */
+ u_long uc_vers; /* saved version number */
+ u_long uc_proc; /* saved procedure number */
+ struct sockaddr_in uc_addr; /* saved caller's address */
};
@@ -326,7 +323,7 @@ struct udp_cache {
* the hashing function
*/
#define CACHE_LOC(transp, xid) \
- (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
+ (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
/*
@@ -334,49 +331,48 @@ struct udp_cache {
* Note: there is no disable.
*/
svcudp_enablecache(transp, size)
- SVCXPRT *transp;
- u_long size;
+SVCXPRT *transp;
+u_long size;
{
struct svcudp_data *su = su_data(transp);
struct udp_cache *uc;
if (su->su_cache != NULL) {
CACHE_PERROR("enablecache: cache already enabled");
- return(0);
+ return (0);
}
uc = ALLOC(struct udp_cache, 1);
if (uc == NULL) {
CACHE_PERROR("enablecache: could not allocate cache");
- return(0);
+ return (0);
}
uc->uc_size = size;
uc->uc_nextvictim = 0;
uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS);
if (uc->uc_entries == NULL) {
CACHE_PERROR("enablecache: could not allocate cache data");
- return(0);
+ return (0);
}
BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS);
uc->uc_fifo = ALLOC(cache_ptr, size);
if (uc->uc_fifo == NULL) {
CACHE_PERROR("enablecache: could not allocate cache fifo");
- return(0);
+ return (0);
}
BZERO(uc->uc_fifo, cache_ptr, size);
su->su_cache = (char *) uc;
- return(1);
+ return (1);
}
/*
* Set an entry in the cache
*/
-static
-cache_set(xprt, replylen)
- SVCXPRT *xprt;
- u_long replylen;
+static cache_set(xprt, replylen)
+SVCXPRT *xprt;
+u_long replylen;
{
- register cache_ptr victim;
+ register cache_ptr victim;
register cache_ptr *vicp;
register struct svcudp_data *su = su_data(xprt);
struct udp_cache *uc = (struct udp_cache *) su->su_cache;
@@ -384,16 +380,15 @@ cache_set(xprt, replylen)
char *newbuf;
/*
- * Find space for the new entry, either by
+ * Find space for the new entry, either by
* reusing an old entry, or by mallocing a new one
*/
victim = uc->uc_fifo[uc->uc_nextvictim];
if (victim != NULL) {
loc = CACHE_LOC(xprt, victim->cache_xid);
- for (vicp = &uc->uc_entries[loc];
- *vicp != NULL && *vicp != victim;
- vicp = &(*vicp)->cache_next)
- ;
+ for (vicp = &uc->uc_entries[loc];
+ *vicp != NULL && *vicp != victim;
+ vicp = &(*vicp)->cache_next);
if (*vicp == NULL) {
CACHE_PERROR("cache_set: victim not found");
return;
@@ -402,6 +397,7 @@ cache_set(xprt, replylen)
newbuf = victim->cache_reply;
} else {
victim = ALLOC(struct cache_node, 1);
+
if (victim == NULL) {
CACHE_PERROR("cache_set: victim alloc failed");
return;
@@ -419,14 +415,15 @@ cache_set(xprt, replylen)
victim->cache_replylen = replylen;
victim->cache_reply = rpc_buffer(xprt);
rpc_buffer(xprt) = newbuf;
- xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE);
+ xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
+ XDR_ENCODE);
victim->cache_xid = su->su_xid;
victim->cache_proc = uc->uc_proc;
victim->cache_vers = uc->uc_vers;
victim->cache_prog = uc->uc_prog;
victim->cache_addr = uc->uc_addr;
loc = CACHE_LOC(xprt, victim->cache_xid);
- victim->cache_next = uc->uc_entries[loc];
+ victim->cache_next = uc->uc_entries[loc];
uc->uc_entries[loc] = victim;
uc->uc_fifo[uc->uc_nextvictim++] = victim;
uc->uc_nextvictim %= uc->uc_size;
@@ -436,12 +433,11 @@ cache_set(xprt, replylen)
* Try to get an entry from the cache
* return 1 if found, 0 if not found
*/
-static
-cache_get(xprt, msg, replyp, replylenp)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
- char **replyp;
- u_long *replylenp;
+static cache_get(xprt, msg, replyp, replylenp)
+SVCXPRT *xprt;
+struct rpc_msg *msg;
+char **replyp;
+u_long *replylenp;
{
u_int loc;
register cache_ptr ent;
@@ -453,13 +449,13 @@ cache_get(xprt, msg, replyp, replylenp)
loc = CACHE_LOC(xprt, su->su_xid);
for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {
if (ent->cache_xid == su->su_xid &&
- ent->cache_proc == uc->uc_proc &&
- ent->cache_vers == uc->uc_vers &&
- ent->cache_prog == uc->uc_prog &&
- EQADDR(ent->cache_addr, uc->uc_addr)) {
+ ent->cache_proc == uc->uc_proc &&
+ ent->cache_vers == uc->uc_vers &&
+ ent->cache_prog == uc->uc_prog &&
+ EQADDR(ent->cache_addr, uc->uc_addr)) {
*replyp = ent->cache_reply;
*replylenp = ent->cache_replylen;
- return(1);
+ return (1);
}
}
/*
@@ -470,6 +466,5 @@ cache_get(xprt, msg, replyp, replylenp)
uc->uc_vers = msg->rm_call.cb_vers;
uc->uc_prog = msg->rm_call.cb_prog;
uc->uc_addr = xprt->xp_raddr;
- return(0);
+ return (0);
}
-
diff --git a/libc/inet/rpc/xdr.c b/libc/inet/rpc/xdr.c
index cc2783813..88600732a 100644
--- a/libc/inet/rpc/xdr.c
+++ b/libc/inet/rpc/xdr.c
@@ -62,22 +62,20 @@ static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
* Free a data structure using XDR
* Not a filter, but a convenient utility nonetheless
*/
-void
-xdr_free(proc, objp)
- xdrproc_t proc;
- char *objp;
+void xdr_free(proc, objp)
+xdrproc_t proc;
+char *objp;
{
XDR x;
-
+
x.x_op = XDR_FREE;
- (*proc)(&x, objp);
+ (*proc) (&x, objp);
}
/*
* XDR nothing
*/
-bool_t
-xdr_void(/* xdrs, addr */)
+bool_t xdr_void( /* xdrs, addr */ )
/* XDR *xdrs; */
/* caddr_t addr; */
{
@@ -88,20 +86,19 @@ xdr_void(/* xdrs, addr */)
/*
* XDR integers
*/
-bool_t
-xdr_int(xdrs, ip)
- XDR *xdrs;
- int *ip;
+bool_t xdr_int(xdrs, ip)
+XDR *xdrs;
+int *ip;
{
#ifdef lint
- (void) (xdr_short(xdrs, (short *)ip));
- return (xdr_long(xdrs, (long *)ip));
+ (void) (xdr_short(xdrs, (short *) ip));
+ return (xdr_long(xdrs, (long *) ip));
#else
- if (sizeof (int) == sizeof (long)) {
- return (xdr_long(xdrs, (long *)ip));
+ if (sizeof(int) == sizeof(long)) {
+ return (xdr_long(xdrs, (long *) ip));
} else {
- return (xdr_short(xdrs, (short *)ip));
+ return (xdr_short(xdrs, (short *) ip));
}
#endif
}
@@ -109,20 +106,19 @@ xdr_int(xdrs, ip)
/*
* XDR unsigned integers
*/
-bool_t
-xdr_u_int(xdrs, up)
- XDR *xdrs;
- u_int *up;
+bool_t xdr_u_int(xdrs, up)
+XDR *xdrs;
+u_int *up;
{
#ifdef lint
- (void) (xdr_short(xdrs, (short *)up));
- return (xdr_u_long(xdrs, (u_long *)up));
+ (void) (xdr_short(xdrs, (short *) up));
+ return (xdr_u_long(xdrs, (u_long *) up));
#else
- if (sizeof (u_int) == sizeof (u_long)) {
- return (xdr_u_long(xdrs, (u_long *)up));
+ if (sizeof(u_int) == sizeof(u_long)) {
+ return (xdr_u_long(xdrs, (u_long *) up));
} else {
- return (xdr_short(xdrs, (short *)up));
+ return (xdr_short(xdrs, (short *) up));
}
#endif
}
@@ -131,10 +127,9 @@ xdr_u_int(xdrs, up)
* XDR long integers
* same as xdr_u_long - open coded to save a proc call!
*/
-bool_t
-xdr_long(xdrs, lp)
- register XDR *xdrs;
- long *lp;
+bool_t xdr_long(xdrs, lp)
+register XDR *xdrs;
+long *lp;
{
if (xdrs->x_op == XDR_ENCODE)
@@ -153,16 +148,15 @@ xdr_long(xdrs, lp)
* XDR unsigned long integers
* same as xdr_long - open coded to save a proc call!
*/
-bool_t
-xdr_u_long(xdrs, ulp)
- register XDR *xdrs;
- u_long *ulp;
+bool_t xdr_u_long(xdrs, ulp)
+register XDR *xdrs;
+u_long *ulp;
{
if (xdrs->x_op == XDR_DECODE)
- return (XDR_GETLONG(xdrs, (long *)ulp));
+ return (XDR_GETLONG(xdrs, (long *) ulp));
if (xdrs->x_op == XDR_ENCODE)
- return (XDR_PUTLONG(xdrs, (long *)ulp));
+ return (XDR_PUTLONG(xdrs, (long *) ulp));
if (xdrs->x_op == XDR_FREE)
return (TRUE);
return (FALSE);
@@ -171,10 +165,9 @@ xdr_u_long(xdrs, ulp)
/*
* XDR short integers
*/
-bool_t
-xdr_short(xdrs, sp)
- register XDR *xdrs;
- short *sp;
+bool_t xdr_short(xdrs, sp)
+register XDR *xdrs;
+short *sp;
{
long l;
@@ -200,17 +193,16 @@ xdr_short(xdrs, sp)
/*
* XDR unsigned short integers
*/
-bool_t
-xdr_u_short(xdrs, usp)
- register XDR *xdrs;
- u_short *usp;
+bool_t xdr_u_short(xdrs, usp)
+register XDR *xdrs;
+u_short *usp;
{
u_long l;
switch (xdrs->x_op) {
case XDR_ENCODE:
- l = (u_long) *usp;
+ l = (u_long) * usp;
return (XDR_PUTLONG(xdrs, &l));
case XDR_DECODE:
@@ -230,10 +222,9 @@ xdr_u_short(xdrs, usp)
/*
* XDR a char
*/
-bool_t
-xdr_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
+bool_t xdr_char(xdrs, cp)
+XDR *xdrs;
+char *cp;
{
int i;
@@ -248,10 +239,9 @@ xdr_char(xdrs, cp)
/*
* XDR an unsigned char
*/
-bool_t
-xdr_u_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
+bool_t xdr_u_char(xdrs, cp)
+XDR *xdrs;
+char *cp;
{
u_int u;
@@ -266,10 +256,9 @@ xdr_u_char(xdrs, cp)
/*
* XDR booleans
*/
-bool_t
-xdr_bool(xdrs, bp)
- register XDR *xdrs;
- bool_t *bp;
+bool_t xdr_bool(xdrs, bp)
+register XDR *xdrs;
+bool_t *bp;
{
long lb;
@@ -295,10 +284,9 @@ xdr_bool(xdrs, bp)
/*
* XDR enumerations
*/
-bool_t
-xdr_enum(xdrs, ep)
- XDR *xdrs;
- enum_t *ep;
+bool_t xdr_enum(xdrs, ep)
+XDR *xdrs;
+enum_t *ep;
{
#ifndef lint
enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
@@ -306,16 +294,16 @@ xdr_enum(xdrs, ep)
/*
* enums are treated as ints
*/
- if (sizeof (enum sizecheck) == sizeof (long)) {
- return (xdr_long(xdrs, (long *)ep));
- } else if (sizeof (enum sizecheck) == sizeof (short)) {
- return (xdr_short(xdrs, (short *)ep));
+ if (sizeof(enum sizecheck) == sizeof(long)) {
+ return (xdr_long(xdrs, (long *) ep));
+ } else if (sizeof(enum sizecheck) == sizeof(short)) {
+ return (xdr_short(xdrs, (short *) ep));
} else {
return (FALSE);
}
#else
- (void) (xdr_short(xdrs, (short *)ep));
- return (xdr_long(xdrs, (long *)ep));
+ (void) (xdr_short(xdrs, (short *) ep));
+ return (xdr_long(xdrs, (long *) ep));
#endif
}
@@ -324,11 +312,10 @@ xdr_enum(xdrs, ep)
* Allows the specification of a fixed size sequence of opaque bytes.
* cp points to the opaque object and cnt gives the byte length.
*/
-bool_t
-xdr_opaque(xdrs, cp, cnt)
- register XDR *xdrs;
- caddr_t cp;
- register u_int cnt;
+bool_t xdr_opaque(xdrs, cp, cnt)
+register XDR *xdrs;
+caddr_t cp;
+register u_int cnt;
{
register u_int rndup;
static crud[BYTES_PER_XDR_UNIT];
@@ -376,20 +363,19 @@ xdr_opaque(xdrs, cp, cnt)
* *cpp is a pointer to the bytes, *sizep is the count.
* If *cpp is NULL maxsize bytes are allocated
*/
-bool_t
-xdr_bytes(xdrs, cpp, sizep, maxsize)
- register XDR *xdrs;
- char **cpp;
- register u_int *sizep;
- u_int maxsize;
+bool_t xdr_bytes(xdrs, cpp, sizep, maxsize)
+register XDR *xdrs;
+char **cpp;
+register u_int *sizep;
+u_int maxsize;
{
- register char *sp = *cpp; /* sp is the actual string pointer */
+ register char *sp = *cpp; /* sp is the actual string pointer */
register u_int nodesize;
/*
* first deal with the length since xdr bytes are counted
*/
- if (! xdr_u_int(xdrs, sizep)) {
+ if (!xdr_u_int(xdrs, sizep)) {
return (FALSE);
}
nodesize = *sizep;
@@ -407,7 +393,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
return (TRUE);
}
if (sp == NULL) {
- *cpp = sp = (char *)mem_alloc(nodesize);
+ *cpp = sp = (char *) mem_alloc(nodesize);
}
if (sp == NULL) {
(void) fprintf(stderr, "xdr_bytes: out of memory\n");
@@ -431,10 +417,9 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
/*
* Implemented here due to commonality of the object.
*/
-bool_t
-xdr_netobj(xdrs, np)
- XDR *xdrs;
- struct netobj *np;
+bool_t xdr_netobj(xdrs, np)
+XDR *xdrs;
+struct netobj *np;
{
return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
@@ -451,20 +436,19 @@ xdr_netobj(xdrs, np)
* routine may be called.
* If there is no specific or default routine an error is returned.
*/
-bool_t
-xdr_union(xdrs, dscmp, unp, choices, dfault)
- register XDR *xdrs;
- enum_t *dscmp; /* enum to decide which arm to work on */
- char *unp; /* the union itself */
- struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
- xdrproc_t dfault; /* default xdr routine */
+bool_t xdr_union(xdrs, dscmp, unp, choices, dfault)
+register XDR *xdrs;
+enum_t *dscmp; /* enum to decide which arm to work on */
+char *unp; /* the union itself */
+struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
+xdrproc_t dfault; /* default xdr routine */
{
register enum_t dscm;
/*
* we deal with the discriminator; it's an enum
*/
- if (! xdr_enum(xdrs, dscmp)) {
+ if (!xdr_enum(xdrs, dscmp)) {
return (FALSE);
}
dscm = *dscmp;
@@ -475,14 +459,14 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
*/
for (; choices->proc != NULL_xdrproc_t; choices++) {
if (choices->value == dscm)
- return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED));
+ return ((*(choices->proc)) (xdrs, unp, LASTUNSIGNED));
}
/*
* no match - execute the default xdr routine if there is one
*/
return ((dfault == NULL_xdrproc_t) ? FALSE :
- (*dfault)(xdrs, unp, LASTUNSIGNED));
+ (*dfault) (xdrs, unp, LASTUNSIGNED));
}
@@ -500,13 +484,12 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
* storage is allocated. The last parameter is the max allowed length
* of the string as specified by a protocol.
*/
-bool_t
-xdr_string(xdrs, cpp, maxsize)
- register XDR *xdrs;
- char **cpp;
- u_int maxsize;
+bool_t xdr_string(xdrs, cpp, maxsize)
+register XDR *xdrs;
+char **cpp;
+u_int maxsize;
{
- register char *sp = *cpp; /* sp is the actual string pointer */
+ register char *sp = *cpp; /* sp is the actual string pointer */
u_int size;
u_int nodesize;
@@ -516,14 +499,14 @@ xdr_string(xdrs, cpp, maxsize)
switch (xdrs->x_op) {
case XDR_FREE:
if (sp == NULL) {
- return(TRUE); /* already free */
+ return (TRUE); /* already free */
}
/* fall through... */
case XDR_ENCODE:
size = strlen(sp);
break;
}
- if (! xdr_u_int(xdrs, &size)) {
+ if (!xdr_u_int(xdrs, &size)) {
return (FALSE);
}
if (size > maxsize) {
@@ -541,7 +524,7 @@ xdr_string(xdrs, cpp, maxsize)
return (TRUE);
}
if (sp == NULL)
- *cpp = sp = (char *)mem_alloc(nodesize);
+ *cpp = sp = (char *) mem_alloc(nodesize);
if (sp == NULL) {
(void) fprintf(stderr, "xdr_string: out of memory\n");
return (FALSE);
@@ -564,10 +547,9 @@ xdr_string(xdrs, cpp, maxsize)
* Wrapper for xdr_string that can be called directly from
* routines like clnt_call
*/
-bool_t
-xdr_wrapstring(xdrs, cpp)
- XDR *xdrs;
- char **cpp;
+bool_t xdr_wrapstring(xdrs, cpp)
+XDR *xdrs;
+char **cpp;
{
if (xdr_string(xdrs, cpp, LASTUNSIGNED)) {
return (TRUE);
diff --git a/libc/inet/rpc/xdr_array.c b/libc/inet/rpc/xdr_array.c
index 7c2831ccd..1e6101719 100644
--- a/libc/inet/rpc/xdr_array.c
+++ b/libc/inet/rpc/xdr_array.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -55,23 +57,22 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* elsize is the size (in bytes) of each element, and elproc is the
* xdr procedure to call to handle each element of the array.
*/
-bool_t
-xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
- register XDR *xdrs;
- caddr_t *addrp; /* array pointer */
- u_int *sizep; /* number of elements */
- u_int maxsize; /* max numberof elements */
- u_int elsize; /* size in bytes of each element */
- xdrproc_t elproc; /* xdr routine to handle each element */
+bool_t xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
+register XDR *xdrs;
+caddr_t *addrp; /* array pointer */
+u_int *sizep; /* number of elements */
+u_int maxsize; /* max numberof elements */
+u_int elsize; /* size in bytes of each element */
+xdrproc_t elproc; /* xdr routine to handle each element */
{
register u_int i;
register caddr_t target = *addrp;
- register u_int c; /* the actual element count */
+ register u_int c; /* the actual element count */
register bool_t stat = TRUE;
register u_int nodesize;
/* like strings, arrays are really counted arrays */
- if (! xdr_u_int(xdrs, sizep)) {
+ if (!xdr_u_int(xdrs, sizep)) {
return (FALSE);
}
c = *sizep;
@@ -91,8 +92,7 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
return (TRUE);
*addrp = target = mem_alloc(nodesize);
if (target == NULL) {
- (void) fprintf(stderr,
- "xdr_array: out of memory\n");
+ (void) fprintf(stderr, "xdr_array: out of memory\n");
return (FALSE);
}
bzero(target, nodesize);
@@ -100,13 +100,13 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
case XDR_FREE:
return (TRUE);
- }
-
+ }
+
/*
* now we xdr each element of array
*/
for (i = 0; (i < c) && stat; i++) {
- stat = (*elproc)(xdrs, target, LASTUNSIGNED);
+ stat = (*elproc) (xdrs, target, LASTUNSIGNED);
target += elsize;
}
@@ -130,24 +130,22 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
* > elemsize: size of each element
* > xdr_elem: routine to XDR each element
*/
-bool_t
-xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
- register XDR *xdrs;
- register char *basep;
- register u_int nelem;
- register u_int elemsize;
- register xdrproc_t xdr_elem;
+bool_t xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
+register XDR *xdrs;
+register char *basep;
+register u_int nelem;
+register u_int elemsize;
+register xdrproc_t xdr_elem;
{
register u_int i;
register char *elptr;
elptr = basep;
for (i = 0; i < nelem; i++) {
- if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) {
- return(FALSE);
+ if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) {
+ return (FALSE);
}
elptr += elemsize;
}
- return(TRUE);
+ return (TRUE);
}
-
diff --git a/libc/inet/rpc/xdr_float.c b/libc/inet/rpc/xdr_float.c
index ce7b6e07f..f8eb5e99c 100644
--- a/libc/inet/rpc/xdr_float.c
+++ b/libc/inet/rpc/xdr_float.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -59,18 +61,18 @@ static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
#ifdef vax
/* What IEEE single precision floating point looks like on a Vax */
-struct ieee_single {
- unsigned int mantissa: 23;
- unsigned int exp : 8;
- unsigned int sign : 1;
+struct ieee_single {
+ unsigned int mantissa:23;
+ unsigned int exp:8;
+ unsigned int sign:1;
};
/* Vax single precision floating point */
-struct vax_single {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
+struct vax_single {
+ unsigned int mantissa1:7;
+ unsigned int exp:8;
+ unsigned int sign:1;
+ unsigned int mantissa2:16;
};
#define VAX_SNG_BIAS 0x81
@@ -80,17 +82,20 @@ static struct sgl_limits {
struct vax_single s;
struct ieee_single ieee;
} sgl_limits[2] = {
- {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */
- { 0x0, 0xff, 0x0 }}, /* Max IEEE */
- {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */
- { 0x0, 0x0, 0x0 }} /* Min IEEE */
+ { {
+ 0x7f, 0xff, 0x0, 0xffff}, /* Max Vax */
+ {
+ 0x0, 0xff, 0x0}}, /* Max IEEE */
+ { {
+ 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
+ {
+ 0x0, 0x0, 0x0}} /* Min IEEE */
};
-#endif /* vax */
+#endif /* vax */
-bool_t
-xdr_float(xdrs, fp)
- register XDR *xdrs;
- register float *fp;
+bool_t xdr_float(xdrs, fp)
+register XDR *xdrs;
+register float *fp;
{
#if !defined(mc68000) && !defined(sparc)
struct ieee_single is;
@@ -102,12 +107,13 @@ xdr_float(xdrs, fp)
case XDR_ENCODE:
#if defined(mc68000) || defined(sparc)
- return (XDR_PUTLONG(xdrs, (long *)fp));
+ return (XDR_PUTLONG(xdrs, (long *) fp));
#else
- vs = *((struct vax_single *)fp);
+ vs = *((struct vax_single *) fp);
for (i = 0, lim = sgl_limits;
- i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
- i++, lim++) {
+
+ i < sizeof(sgl_limits) / sizeof(struct sgl_limits);
+ i++, lim++) {
if ((vs.mantissa2 == lim->s.mantissa2) &&
(vs.exp == lim->s.exp) &&
(vs.mantissa1 == lim->s.mantissa1)) {
@@ -117,21 +123,22 @@ xdr_float(xdrs, fp)
}
is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2;
- shipit:
+ shipit:
is.sign = vs.sign;
- return (XDR_PUTLONG(xdrs, (long *)&is));
+ return (XDR_PUTLONG(xdrs, (long *) &is));
#endif
case XDR_DECODE:
#if defined(mc68000) || defined(sparc)
- return (XDR_GETLONG(xdrs, (long *)fp));
+ return (XDR_GETLONG(xdrs, (long *) fp));
#else
- vsp = (struct vax_single *)fp;
- if (!XDR_GETLONG(xdrs, (long *)&is))
+ vsp = (struct vax_single *) fp;
+ if (!XDR_GETLONG(xdrs, (long *) &is))
return (FALSE);
for (i = 0, lim = sgl_limits;
- i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
- i++, lim++) {
+
+ i < sizeof(sgl_limits) / sizeof(struct sgl_limits);
+ i++, lim++) {
if ((is.exp == lim->ieee.exp) &&
(is.mantissa == lim->ieee.mantissa)) {
*vsp = lim->s;
@@ -141,7 +148,7 @@ xdr_float(xdrs, fp)
vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
vsp->mantissa2 = is.mantissa;
vsp->mantissa1 = (is.mantissa >> 16);
- doneit:
+ doneit:
vsp->sign = is.sign;
return (TRUE);
#endif
@@ -158,21 +165,21 @@ xdr_float(xdrs, fp)
#ifdef vax
/* What IEEE double precision floating point looks like on a Vax */
-struct ieee_double {
- unsigned int mantissa1 : 20;
- unsigned int exp : 11;
- unsigned int sign : 1;
- unsigned int mantissa2 : 32;
+struct ieee_double {
+ unsigned int mantissa1:20;
+ unsigned int exp:11;
+ unsigned int sign:1;
+ unsigned int mantissa2:32;
};
/* Vax double precision floating point */
-struct vax_double {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
- unsigned int mantissa3 : 16;
- unsigned int mantissa4 : 16;
+struct vax_double {
+ unsigned int mantissa1:7;
+ unsigned int exp:8;
+ unsigned int sign:1;
+ unsigned int mantissa2:16;
+ unsigned int mantissa3:16;
+ unsigned int mantissa4:16;
};
#define VAX_DBL_BIAS 0x81
@@ -180,27 +187,31 @@ struct vax_double {
#define MASK(nbits) ((1 << nbits) - 1)
static struct dbl_limits {
- struct vax_double d;
- struct ieee_double ieee;
+ struct vax_double d;
+ struct ieee_double ieee;
} dbl_limits[2] = {
- {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */
- { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */
- {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
- { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
+ { {
+ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff}, /* Max Vax */
+ {
+ 0x0, 0x7ff, 0x0, 0x0}}, /* Max IEEE */
+ { {
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
+ {
+ 0x0, 0x0, 0x0, 0x0}} /* Min IEEE */
};
-#endif /* vax */
+#endif /* vax */
-bool_t
-xdr_double(xdrs, dp)
- register XDR *xdrs;
- double *dp;
+bool_t xdr_double(xdrs, dp)
+register XDR *xdrs;
+double *dp;
{
register long *lp;
+
#if !defined(mc68000) && !defined(sparc)
- struct ieee_double id;
- struct vax_double vd;
+ struct ieee_double id;
+ struct vax_double vd;
register struct dbl_limits *lim;
int i;
#endif
@@ -209,12 +220,13 @@ xdr_double(xdrs, dp)
case XDR_ENCODE:
#if defined(mc68000) || defined(sparc)
- lp = (long *)dp;
+ lp = (long *) dp;
#else
- vd = *((struct vax_double *)dp);
+ vd = *((struct vax_double *) dp);
for (i = 0, lim = dbl_limits;
- i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
- i++, lim++) {
+
+ i < sizeof(dbl_limits) / sizeof(struct dbl_limits);
+ i++, lim++) {
if ((vd.mantissa4 == lim->d.mantissa4) &&
(vd.mantissa3 == lim->d.mantissa3) &&
(vd.mantissa2 == lim->d.mantissa2) &&
@@ -227,25 +239,25 @@ xdr_double(xdrs, dp)
id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) |
- (vd.mantissa3 << 13) |
- ((vd.mantissa4 >> 3) & MASK(13));
- shipit:
+ (vd.mantissa3 << 13) | ((vd.mantissa4 >> 3) & MASK(13));
+ shipit:
id.sign = vd.sign;
- lp = (long *)&id;
+ lp = (long *) &id;
#endif
return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp));
case XDR_DECODE:
#if defined(mc68000) || defined(sparc)
- lp = (long *)dp;
+ lp = (long *) dp;
return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp));
#else
- lp = (long *)&id;
+ lp = (long *) &id;
if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))
return (FALSE);
for (i = 0, lim = dbl_limits;
- i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
- i++, lim++) {
+
+ i < sizeof(dbl_limits) / sizeof(struct dbl_limits);
+ i++, lim++) {
if ((id.mantissa2 == lim->ieee.mantissa2) &&
(id.mantissa1 == lim->ieee.mantissa1) &&
(id.exp == lim->ieee.exp)) {
@@ -256,12 +268,12 @@ xdr_double(xdrs, dp)
vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
vd.mantissa1 = (id.mantissa1 >> 13);
vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
- (id.mantissa2 >> 29);
+ (id.mantissa2 >> 29);
vd.mantissa3 = (id.mantissa2 >> 13);
vd.mantissa4 = (id.mantissa2 << 3);
- doneit:
+ doneit:
vd.sign = id.sign;
- *dp = *((double *)&vd);
+ *dp = *((double *) &vd);
return (TRUE);
#endif
diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c
index 558d36922..b05f2b6f3 100644
--- a/libc/inet/rpc/xdr_mem.c
+++ b/libc/inet/rpc/xdr_mem.c
@@ -47,16 +47,16 @@ static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/xdr.h>
#include <netinet/in.h>
-static bool_t xdrmem_getlong();
-static bool_t xdrmem_putlong();
-static bool_t xdrmem_getbytes();
-static bool_t xdrmem_putbytes();
-static u_int xdrmem_getpos();
-static bool_t xdrmem_setpos();
-static long * xdrmem_inline();
-static void xdrmem_destroy();
-
-static struct xdr_ops xdrmem_ops = {
+static bool_t xdrmem_getlong();
+static bool_t xdrmem_putlong();
+static bool_t xdrmem_getbytes();
+static bool_t xdrmem_putbytes();
+static u_int xdrmem_getpos();
+static bool_t xdrmem_setpos();
+static long *xdrmem_inline();
+static void xdrmem_destroy();
+
+static struct xdr_ops xdrmem_ops = {
xdrmem_getlong,
xdrmem_putlong,
xdrmem_getbytes,
@@ -71,12 +71,11 @@ static struct xdr_ops xdrmem_ops = {
* The procedure xdrmem_create initializes a stream descriptor for a
* memory buffer.
*/
-void
-xdrmem_create(xdrs, addr, size, op)
- register XDR *xdrs;
- caddr_t addr;
- u_int size;
- enum xdr_op op;
+void xdrmem_create(xdrs, addr, size, op)
+register XDR *xdrs;
+caddr_t addr;
+u_int size;
+enum xdr_op op;
{
xdrs->x_op = op;
@@ -85,43 +84,43 @@ xdrmem_create(xdrs, addr, size, op)
xdrs->x_handy = size;
}
-static void
-xdrmem_destroy(/*xdrs*/)
- /*XDR *xdrs;*/
+static void xdrmem_destroy( /*xdrs */ )
+ /*XDR *xdrs; */
{
}
-static bool_t
-xdrmem_getlong(xdrs, lp)
- register XDR *xdrs;
- long *lp;
+static bool_t xdrmem_getlong(xdrs, lp)
+register XDR *xdrs;
+long *lp;
{
if ((xdrs->x_handy -= sizeof(long)) < 0)
return (FALSE);
- *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private))));
+
+ *lp = (long) ntohl((u_long) (*((long *) (xdrs->x_private))));
xdrs->x_private += sizeof(long);
+
return (TRUE);
}
-static bool_t
-xdrmem_putlong(xdrs, lp)
- register XDR *xdrs;
- long *lp;
+static bool_t xdrmem_putlong(xdrs, lp)
+register XDR *xdrs;
+long *lp;
{
if ((xdrs->x_handy -= sizeof(long)) < 0)
return (FALSE);
- *(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
+
+ *(long *) xdrs->x_private = (long) htonl((u_long) (*lp));
xdrs->x_private += sizeof(long);
+
return (TRUE);
}
-static bool_t
-xdrmem_getbytes(xdrs, addr, len)
- register XDR *xdrs;
- caddr_t addr;
- register u_int len;
+static bool_t xdrmem_getbytes(xdrs, addr, len)
+register XDR *xdrs;
+caddr_t addr;
+register u_int len;
{
if ((xdrs->x_handy -= len) < 0)
@@ -131,11 +130,10 @@ xdrmem_getbytes(xdrs, addr, len)
return (TRUE);
}
-static bool_t
-xdrmem_putbytes(xdrs, addr, len)
- register XDR *xdrs;
- caddr_t addr;
- register u_int len;
+static bool_t xdrmem_putbytes(xdrs, addr, len)
+register XDR *xdrs;
+caddr_t addr;
+register u_int len;
{
if ((xdrs->x_handy -= len) < 0)
@@ -145,33 +143,30 @@ xdrmem_putbytes(xdrs, addr, len)
return (TRUE);
}
-static u_int
-xdrmem_getpos(xdrs)
- register XDR *xdrs;
+static u_int xdrmem_getpos(xdrs)
+register XDR *xdrs;
{
- return ((u_int)xdrs->x_private - (u_int)xdrs->x_base);
+ return ((u_int) xdrs->x_private - (u_int) xdrs->x_base);
}
-static bool_t
-xdrmem_setpos(xdrs, pos)
- register XDR *xdrs;
- u_int pos;
+static bool_t xdrmem_setpos(xdrs, pos)
+register XDR *xdrs;
+u_int pos;
{
register caddr_t newaddr = xdrs->x_base + pos;
register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
- if ((long)newaddr > (long)lastaddr)
+ if ((long) newaddr > (long) lastaddr)
return (FALSE);
xdrs->x_private = newaddr;
- xdrs->x_handy = (int)lastaddr - (int)newaddr;
+ xdrs->x_handy = (int) lastaddr - (int) newaddr;
return (TRUE);
}
-static long *
-xdrmem_inline(xdrs, len)
- register XDR *xdrs;
- int len;
+static long *xdrmem_inline(xdrs, len)
+register XDR *xdrs;
+int len;
{
long *buf = 0;
diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c
index 4d0d4ecfb..94fcc3809 100644
--- a/libc/inet/rpc/xdr_rec.c
+++ b/libc/inet/rpc/xdr_rec.c
@@ -53,20 +53,20 @@ static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/xdr.h>
#include <netinet/in.h>
-extern long lseek();
+extern long lseek();
-static u_int fix_buf_size();
+static u_int fix_buf_size();
-static bool_t xdrrec_getlong();
-static bool_t xdrrec_putlong();
-static bool_t xdrrec_getbytes();
-static bool_t xdrrec_putbytes();
-static u_int xdrrec_getpos();
-static bool_t xdrrec_setpos();
-static long * xdrrec_inline();
-static void xdrrec_destroy();
+static bool_t xdrrec_getlong();
+static bool_t xdrrec_putlong();
+static bool_t xdrrec_getbytes();
+static bool_t xdrrec_putbytes();
+static u_int xdrrec_getpos();
+static bool_t xdrrec_setpos();
+static long *xdrrec_inline();
+static void xdrrec_destroy();
-static struct xdr_ops xdrrec_ops = {
+static struct xdr_ops xdrrec_ops = {
xdrrec_getlong,
xdrrec_putlong,
xdrrec_getbytes,
@@ -98,21 +98,21 @@ typedef struct rec_strm {
/*
* out-goung bits
*/
- int (*writeit)();
- caddr_t out_base; /* output buffer (points to frag header) */
- caddr_t out_finger; /* next output position */
- caddr_t out_boundry; /* data cannot up to this address */
- u_long *frag_header; /* beginning of curren fragment */
- bool_t frag_sent; /* true if buffer sent in middle of record */
+ int (*writeit) ();
+ caddr_t out_base; /* output buffer (points to frag header) */
+ caddr_t out_finger; /* next output position */
+ caddr_t out_boundry; /* data cannot up to this address */
+ u_long *frag_header; /* beginning of curren fragment */
+ bool_t frag_sent; /* true if buffer sent in middle of record */
/*
* in-coming bits
*/
- int (*readit)();
- u_long in_size; /* fixed size of the input buffer */
+ int (*readit) ();
+ u_long in_size; /* fixed size of the input buffer */
caddr_t in_base;
- caddr_t in_finger; /* location of next byte to be had */
- caddr_t in_boundry; /* can read up to this location */
- long fbtbc; /* fragment bytes to be consumed */
+ caddr_t in_finger; /* location of next byte to be had */
+ caddr_t in_boundry; /* can read up to this location */
+ long fbtbc; /* fragment bytes to be consumed */
bool_t last_frag;
u_int sendsize;
u_int recvsize;
@@ -128,20 +128,18 @@ typedef struct rec_strm {
* write respectively. They are like the system
* calls expect that they take an opaque handle rather than an fd.
*/
-void
-xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
- register XDR *xdrs;
- register u_int sendsize;
- register u_int recvsize;
- caddr_t tcp_handle;
- int (*readit)(); /* like read, but pass it a tcp_handle, not sock */
- int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */
+void xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
+register XDR *xdrs;
+register u_int sendsize;
+register u_int recvsize;
+caddr_t tcp_handle;
+int (*readit) (); /* like read, but pass it a tcp_handle, not sock */
+int (*writeit) (); /* like write, but pass it a tcp_handle, not sock */
{
- register RECSTREAM *rstrm =
- (RECSTREAM *)mem_alloc(sizeof(RECSTREAM));
+ register RECSTREAM *rstrm = (RECSTREAM *) mem_alloc(sizeof(RECSTREAM));
if (rstrm == NULL) {
- (void)fprintf(stderr, "xdrrec_create: out of memory\n");
+ (void) fprintf(stderr, "xdrrec_create: out of memory\n");
/*
* This is bad. Should rework xdrrec_create to
* return a handle, and in this case return NULL
@@ -153,25 +151,26 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
*/
rstrm->sendsize = sendsize = fix_buf_size(sendsize);
rstrm->recvsize = recvsize = fix_buf_size(recvsize);
- rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT);
+ rstrm->the_buffer =
+ mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT);
if (rstrm->the_buffer == NULL) {
- (void)fprintf(stderr, "xdrrec_create: out of memory\n");
+ (void) fprintf(stderr, "xdrrec_create: out of memory\n");
return;
}
for (rstrm->out_base = rstrm->the_buffer;
- (u_int)rstrm->out_base % BYTES_PER_XDR_UNIT != 0;
- rstrm->out_base++);
+ (u_int) rstrm->out_base % BYTES_PER_XDR_UNIT != 0;
+ rstrm->out_base++);
rstrm->in_base = rstrm->out_base + sendsize;
/*
* now the rest ...
*/
xdrs->x_ops = &xdrrec_ops;
- xdrs->x_private = (caddr_t)rstrm;
+ xdrs->x_private = (caddr_t) rstrm;
rstrm->tcp_handle = tcp_handle;
rstrm->readit = readit;
rstrm->writeit = writeit;
rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
- rstrm->frag_header = (u_long *)rstrm->out_base;
+ rstrm->frag_header = (u_long *) rstrm->out_base;
rstrm->out_finger += sizeof(u_long);
rstrm->out_boundry += sendsize;
rstrm->frag_sent = FALSE;
@@ -188,36 +187,35 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
* xdr handle filled in by xdrrec_create.
*/
-static bool_t
-xdrrec_getlong(xdrs, lp)
- XDR *xdrs;
- long *lp;
+static bool_t xdrrec_getlong(xdrs, lp)
+XDR *xdrs;
+long *lp;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register long *buflp = (long *)(rstrm->in_finger);
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
+ register long *buflp = (long *) (rstrm->in_finger);
long mylong;
/* first try the inline, fast case */
if ((rstrm->fbtbc >= sizeof(long)) &&
- (((int)rstrm->in_boundry - (int)buflp) >= sizeof(long))) {
- *lp = (long)ntohl((u_long)(*buflp));
+ (((int) rstrm->in_boundry - (int) buflp) >= sizeof(long))) {
+ *lp = (long) ntohl((u_long) (*buflp));
rstrm->fbtbc -= sizeof(long);
rstrm->in_finger += sizeof(long);
} else {
- if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(long)))
+ if (!xdrrec_getbytes(xdrs, (caddr_t) & mylong, sizeof(long)))
return (FALSE);
- *lp = (long)ntohl((u_long)mylong);
+
+ *lp = (long) ntohl((u_long) mylong);
}
return (TRUE);
}
-static bool_t
-xdrrec_putlong(xdrs, lp)
- XDR *xdrs;
- long *lp;
+static bool_t xdrrec_putlong(xdrs, lp)
+XDR *xdrs;
+long *lp;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register long *dest_lp = ((long *)(rstrm->out_finger));
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
+ register long *dest_lp = ((long *) (rstrm->out_finger));
if ((rstrm->out_finger += sizeof(long)) > rstrm->out_boundry) {
/*
@@ -225,23 +223,25 @@ xdrrec_putlong(xdrs, lp)
* inefficient
*/
rstrm->out_finger -= sizeof(long);
+
rstrm->frag_sent = TRUE;
- if (! flush_out(rstrm, FALSE))
+ if (!flush_out(rstrm, FALSE))
return (FALSE);
- dest_lp = ((long *)(rstrm->out_finger));
+ dest_lp = ((long *) (rstrm->out_finger));
rstrm->out_finger += sizeof(long);
}
- *dest_lp = (long)htonl((u_long)(*lp));
+ *dest_lp = (long) htonl((u_long) (*lp));
return (TRUE);
}
-static bool_t /* must manage buffers, fragments, and records */
+static bool_t
+/* must manage buffers, fragments, and records */
xdrrec_getbytes(xdrs, addr, len)
- XDR *xdrs;
- register caddr_t addr;
- register u_int len;
+XDR *xdrs;
+register caddr_t addr;
+register u_int len;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
register int current;
while (len > 0) {
@@ -249,31 +249,30 @@ xdrrec_getbytes(xdrs, addr, len)
if (current == 0) {
if (rstrm->last_frag)
return (FALSE);
- if (! set_input_fragment(rstrm))
+ if (!set_input_fragment(rstrm))
return (FALSE);
continue;
}
current = (len < current) ? len : current;
- if (! get_input_bytes(rstrm, addr, current))
+ if (!get_input_bytes(rstrm, addr, current))
return (FALSE);
- addr += current;
+ addr += current;
rstrm->fbtbc -= current;
len -= current;
}
return (TRUE);
}
-static bool_t
-xdrrec_putbytes(xdrs, addr, len)
- XDR *xdrs;
- register caddr_t addr;
- register u_int len;
+static bool_t xdrrec_putbytes(xdrs, addr, len)
+XDR *xdrs;
+register caddr_t addr;
+register u_int len;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
register int current;
while (len > 0) {
- current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger;
+ current = (u_int) rstrm->out_boundry - (u_int) rstrm->out_finger;
current = (len < current) ? len : current;
bcopy(addr, rstrm->out_finger, current);
rstrm->out_finger += current;
@@ -281,21 +280,20 @@ xdrrec_putbytes(xdrs, addr, len)
len -= current;
if (rstrm->out_finger == rstrm->out_boundry) {
rstrm->frag_sent = TRUE;
- if (! flush_out(rstrm, FALSE))
+ if (!flush_out(rstrm, FALSE))
return (FALSE);
}
}
return (TRUE);
}
-static u_int
-xdrrec_getpos(xdrs)
- register XDR *xdrs;
+static u_int xdrrec_getpos(xdrs)
+register XDR *xdrs;
{
- register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
+ register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
register long pos;
- pos = lseek((int)rstrm->tcp_handle, (long) 0, 1);
+ pos = lseek((int) rstrm->tcp_handle, (long) 0, 1);
if (pos != -1)
switch (xdrs->x_op) {
@@ -308,28 +306,27 @@ xdrrec_getpos(xdrs)
break;
default:
- pos = (u_int) -1;
+ pos = (u_int) - 1;
break;
}
return ((u_int) pos);
}
-static bool_t
-xdrrec_setpos(xdrs, pos)
- register XDR *xdrs;
- u_int pos;
+static bool_t xdrrec_setpos(xdrs, pos)
+register XDR *xdrs;
+u_int pos;
{
- register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
+ register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
u_int currpos = xdrrec_getpos(xdrs);
int delta = currpos - pos;
caddr_t newpos;
- if ((int)currpos != -1)
+ if ((int) currpos != -1)
switch (xdrs->x_op) {
case XDR_ENCODE:
newpos = rstrm->out_finger - delta;
- if ((newpos > (caddr_t)(rstrm->frag_header)) &&
+ if ((newpos > (caddr_t) (rstrm->frag_header)) &&
(newpos < rstrm->out_boundry)) {
rstrm->out_finger = newpos;
return (TRUE);
@@ -338,7 +335,7 @@ xdrrec_setpos(xdrs, pos)
case XDR_DECODE:
newpos = rstrm->in_finger - delta;
- if ((delta < (int)(rstrm->fbtbc)) &&
+ if ((delta < (int) (rstrm->fbtbc)) &&
(newpos <= rstrm->in_boundry) &&
(newpos >= rstrm->in_base)) {
rstrm->in_finger = newpos;
@@ -350,13 +347,12 @@ xdrrec_setpos(xdrs, pos)
return (FALSE);
}
-static long *
-xdrrec_inline(xdrs, len)
- register XDR *xdrs;
- int len;
+static long *xdrrec_inline(xdrs, len)
+register XDR *xdrs;
+int len;
{
- register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
- long * buf = NULL;
+ register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
+ long *buf = NULL;
switch (xdrs->x_op) {
@@ -379,15 +375,14 @@ xdrrec_inline(xdrs, len)
return (buf);
}
-static void
-xdrrec_destroy(xdrs)
- register XDR *xdrs;
+static void xdrrec_destroy(xdrs)
+register XDR *xdrs;
{
- register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
+ register RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
mem_free(rstrm->the_buffer,
- rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT);
- mem_free((caddr_t)rstrm, sizeof(RECSTREAM));
+ rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT);
+ mem_free((caddr_t) rstrm, sizeof(RECSTREAM));
}
@@ -399,17 +394,16 @@ xdrrec_destroy(xdrs)
* Before reading (deserializing from the stream, one should always call
* this procedure to guarantee proper record alignment.
*/
-bool_t
-xdrrec_skiprecord(xdrs)
- XDR *xdrs;
+bool_t xdrrec_skiprecord(xdrs)
+XDR *xdrs;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
- while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
- if (! skip_input_bytes(rstrm, rstrm->fbtbc))
+ while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) {
+ if (!skip_input_bytes(rstrm, rstrm->fbtbc))
return (FALSE);
rstrm->fbtbc = 0;
- if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
+ if ((!rstrm->last_frag) && (!set_input_fragment(rstrm)))
return (FALSE);
}
rstrm->last_frag = FALSE;
@@ -421,17 +415,16 @@ xdrrec_skiprecord(xdrs)
* Returns TRUE iff there is no more input in the buffer
* after consuming the rest of the current record.
*/
-bool_t
-xdrrec_eof(xdrs)
- XDR *xdrs;
+bool_t xdrrec_eof(xdrs)
+XDR *xdrs;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
- while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
- if (! skip_input_bytes(rstrm, rstrm->fbtbc))
+ while (rstrm->fbtbc > 0 || (!rstrm->last_frag)) {
+ if (!skip_input_bytes(rstrm, rstrm->fbtbc))
return (TRUE);
rstrm->fbtbc = 0;
- if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
+ if ((!rstrm->last_frag) && (!set_input_fragment(rstrm)))
return (TRUE);
}
if (rstrm->in_finger == rstrm->in_boundry)
@@ -445,24 +438,23 @@ xdrrec_eof(xdrs)
* (output) tcp stream. (This let's the package support batched or
* pipelined procedure calls.) TRUE => immmediate flush to tcp connection.
*/
-bool_t
-xdrrec_endofrecord(xdrs, sendnow)
- XDR *xdrs;
- bool_t sendnow;
+bool_t xdrrec_endofrecord(xdrs, sendnow)
+XDR *xdrs;
+bool_t sendnow;
{
- register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
- register u_long len; /* fragment length */
+ register RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
+ register u_long len; /* fragment length */
if (sendnow || rstrm->frag_sent ||
- ((u_long)rstrm->out_finger + sizeof(u_long) >=
- (u_long)rstrm->out_boundry)) {
+ ((u_long) rstrm->out_finger + sizeof(u_long) >=
+ (u_long) rstrm->out_boundry)) {
rstrm->frag_sent = FALSE;
return (flush_out(rstrm, TRUE));
}
- len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) -
- sizeof(u_long);
- *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG);
- rstrm->frag_header = (u_long *)rstrm->out_finger;
+ len = (u_long) (rstrm->out_finger) - (u_long) (rstrm->frag_header) -
+ sizeof(u_long);
+ *(rstrm->frag_header) = htonl((u_long) len | LAST_FRAG);
+ rstrm->frag_header = (u_long *) rstrm->out_finger;
rstrm->out_finger += sizeof(u_long);
return (TRUE);
}
@@ -471,38 +463,38 @@ xdrrec_endofrecord(xdrs, sendnow)
/*
* Internal useful routines
*/
-static bool_t
-flush_out(rstrm, eor)
- register RECSTREAM *rstrm;
- bool_t eor;
+static bool_t flush_out(rstrm, eor)
+register RECSTREAM *rstrm;
+bool_t eor;
{
register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0;
- register u_long len = (u_long)(rstrm->out_finger) -
- (u_long)(rstrm->frag_header) - sizeof(u_long);
+ register u_long len = (u_long) (rstrm->out_finger) -
+ (u_long) (rstrm->frag_header) - sizeof(u_long);
*(rstrm->frag_header) = htonl(len | eormask);
- len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base);
- if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len)
- != (int)len)
+ len = (u_long) (rstrm->out_finger) - (u_long) (rstrm->out_base);
+ if ((*(rstrm->writeit)) (rstrm->tcp_handle, rstrm->out_base, (int) len)
+ != (int) len)
return (FALSE);
- rstrm->frag_header = (u_long *)rstrm->out_base;
- rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_long);
+ rstrm->frag_header = (u_long *) rstrm->out_base;
+ rstrm->out_finger = (caddr_t) rstrm->out_base + sizeof(u_long);
return (TRUE);
}
-static bool_t /* knows nothing about records! Only about input buffers */
+static bool_t
+/* knows nothing about records! Only about input buffers */
fill_input_buf(rstrm)
- register RECSTREAM *rstrm;
+register RECSTREAM *rstrm;
{
register caddr_t where;
u_int i;
register int len;
where = rstrm->in_base;
- i = (u_int)rstrm->in_boundry % BYTES_PER_XDR_UNIT;
+ i = (u_int) rstrm->in_boundry % BYTES_PER_XDR_UNIT;
where += i;
len = rstrm->in_size - i;
- if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1)
+ if ((len = (*(rstrm->readit)) (rstrm->tcp_handle, where, len)) == -1)
return (FALSE);
rstrm->in_finger = where;
where += len;
@@ -510,18 +502,19 @@ fill_input_buf(rstrm)
return (TRUE);
}
-static bool_t /* knows nothing about records! Only about input buffers */
+static bool_t
+/* knows nothing about records! Only about input buffers */
get_input_bytes(rstrm, addr, len)
- register RECSTREAM *rstrm;
- register caddr_t addr;
- register int len;
+register RECSTREAM *rstrm;
+register caddr_t addr;
+register int len;
{
register int current;
while (len > 0) {
- current = (int)rstrm->in_boundry - (int)rstrm->in_finger;
+ current = (int) rstrm->in_boundry - (int) rstrm->in_finger;
if (current == 0) {
- if (! fill_input_buf(rstrm))
+ if (!fill_input_buf(rstrm))
return (FALSE);
continue;
}
@@ -534,31 +527,33 @@ get_input_bytes(rstrm, addr, len)
return (TRUE);
}
-static bool_t /* next two bytes of the input stream are treated as a header */
+static bool_t
+/* next two bytes of the input stream are treated as a header */
set_input_fragment(rstrm)
- register RECSTREAM *rstrm;
+register RECSTREAM *rstrm;
{
u_long header;
- if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header)))
+ if (!get_input_bytes(rstrm, (caddr_t) & header, sizeof(header)))
return (FALSE);
- header = (long)ntohl(header);
+ header = (long) ntohl(header);
rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
rstrm->fbtbc = header & (~LAST_FRAG);
return (TRUE);
}
-static bool_t /* consumes input bytes; knows nothing about records! */
+static bool_t
+/* consumes input bytes; knows nothing about records! */
skip_input_bytes(rstrm, cnt)
- register RECSTREAM *rstrm;
- long cnt;
+register RECSTREAM *rstrm;
+long cnt;
{
register int current;
while (cnt > 0) {
- current = (int)rstrm->in_boundry - (int)rstrm->in_finger;
+ current = (int) rstrm->in_boundry - (int) rstrm->in_finger;
if (current == 0) {
- if (! fill_input_buf(rstrm))
+ if (!fill_input_buf(rstrm))
return (FALSE);
continue;
}
@@ -569,9 +564,8 @@ skip_input_bytes(rstrm, cnt)
return (TRUE);
}
-static u_int
-fix_buf_size(s)
- register u_int s;
+static u_int fix_buf_size(s)
+register u_int s;
{
if (s < 100)
diff --git a/libc/inet/rpc/xdr_reference.c b/libc/inet/rpc/xdr_reference.c
index 32d91d999..61050b6e7 100644
--- a/libc/inet/rpc/xdr_reference.c
+++ b/libc/inet/rpc/xdr_reference.c
@@ -55,12 +55,11 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
* size is the sizeof the referneced structure.
* proc is the routine to handle the referenced structure.
*/
-bool_t
-xdr_reference(xdrs, pp, size, proc)
- register XDR *xdrs;
- caddr_t *pp; /* the pointer to work on */
- u_int size; /* size of the object pointed to */
- xdrproc_t proc; /* xdr routine to handle the object */
+bool_t xdr_reference(xdrs, pp, size, proc)
+register XDR *xdrs;
+caddr_t *pp; /* the pointer to work on */
+u_int size; /* size of the object pointed to */
+xdrproc_t proc; /* xdr routine to handle the object */
{
register caddr_t loc = *pp;
register bool_t stat;
@@ -73,15 +72,14 @@ xdr_reference(xdrs, pp, size, proc)
case XDR_DECODE:
*pp = loc = (caddr_t) mem_alloc(size);
if (loc == NULL) {
- (void) fprintf(stderr,
- "xdr_reference: out of memory\n");
+ (void) fprintf(stderr, "xdr_reference: out of memory\n");
return (FALSE);
}
- bzero(loc, (int)size);
+ bzero(loc, (int) size);
break;
- }
+ }
- stat = (*proc)(xdrs, loc, LASTUNSIGNED);
+ stat = (*proc) (xdrs, loc, LASTUNSIGNED);
if (xdrs->x_op == XDR_FREE) {
mem_free(loc, size);
@@ -110,23 +108,22 @@ xdr_reference(xdrs, pp, size, proc)
* > xdr_obj: routine to XDR an object.
*
*/
-bool_t
-xdr_pointer(xdrs,objpp,obj_size,xdr_obj)
- register XDR *xdrs;
- char **objpp;
- u_int obj_size;
- xdrproc_t xdr_obj;
+bool_t xdr_pointer(xdrs, objpp, obj_size, xdr_obj)
+register XDR *xdrs;
+char **objpp;
+u_int obj_size;
+xdrproc_t xdr_obj;
{
bool_t more_data;
more_data = (*objpp != NULL);
- if (! xdr_bool(xdrs,&more_data)) {
+ if (!xdr_bool(xdrs, &more_data)) {
return (FALSE);
}
- if (! more_data) {
+ if (!more_data) {
*objpp = NULL;
return (TRUE);
}
- return (xdr_reference(xdrs,objpp,obj_size,xdr_obj));
+ return (xdr_reference(xdrs, objpp, obj_size, xdr_obj));
}
diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c
index 694774f6f..7ae5fbdab 100644
--- a/libc/inet/rpc/xdr_stdio.c
+++ b/libc/inet/rpc/xdr_stdio.c
@@ -28,7 +28,9 @@
* Mountain View, California 94043
*/
#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
+static char sccsid[] =
+
+ "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
#endif
/*
@@ -45,27 +47,27 @@ static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
#include <stdio.h>
#include <rpc/xdr.h>
-static bool_t xdrstdio_getlong();
-static bool_t xdrstdio_putlong();
-static bool_t xdrstdio_getbytes();
-static bool_t xdrstdio_putbytes();
-static u_int xdrstdio_getpos();
-static bool_t xdrstdio_setpos();
-static long * xdrstdio_inline();
-static void xdrstdio_destroy();
+static bool_t xdrstdio_getlong();
+static bool_t xdrstdio_putlong();
+static bool_t xdrstdio_getbytes();
+static bool_t xdrstdio_putbytes();
+static u_int xdrstdio_getpos();
+static bool_t xdrstdio_setpos();
+static long *xdrstdio_inline();
+static void xdrstdio_destroy();
/*
* Ops vector for stdio type XDR
*/
-static struct xdr_ops xdrstdio_ops = {
- xdrstdio_getlong, /* deseraialize a long int */
- xdrstdio_putlong, /* seraialize a long int */
- xdrstdio_getbytes, /* deserialize counted bytes */
- xdrstdio_putbytes, /* serialize counted bytes */
- xdrstdio_getpos, /* get offset in the stream */
- xdrstdio_setpos, /* set offset in the stream */
- xdrstdio_inline, /* prime stream for inline macros */
- xdrstdio_destroy /* destroy stream */
+static struct xdr_ops xdrstdio_ops = {
+ xdrstdio_getlong, /* deseraialize a long int */
+ xdrstdio_putlong, /* seraialize a long int */
+ xdrstdio_getbytes, /* deserialize counted bytes */
+ xdrstdio_putbytes, /* serialize counted bytes */
+ xdrstdio_getpos, /* get offset in the stream */
+ xdrstdio_setpos, /* set offset in the stream */
+ xdrstdio_inline, /* prime stream for inline macros */
+ xdrstdio_destroy /* destroy stream */
};
/*
@@ -73,16 +75,15 @@ static struct xdr_ops xdrstdio_ops = {
* Sets the xdr stream handle xdrs for use on the stream file.
* Operation flag is set to op.
*/
-void
-xdrstdio_create(xdrs, file, op)
- register XDR *xdrs;
- FILE *file;
- enum xdr_op op;
+void xdrstdio_create(xdrs, file, op)
+register XDR *xdrs;
+FILE *file;
+enum xdr_op op;
{
xdrs->x_op = op;
xdrs->x_ops = &xdrstdio_ops;
- xdrs->x_private = (caddr_t)file;
+ xdrs->x_private = (caddr_t) file;
xdrs->x_handy = 0;
xdrs->x_base = 0;
}
@@ -91,89 +92,86 @@ xdrstdio_create(xdrs, file, op)
* Destroy a stdio xdr stream.
* Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
*/
-static void
-xdrstdio_destroy(xdrs)
- register XDR *xdrs;
+static void xdrstdio_destroy(xdrs)
+register XDR *xdrs;
{
- (void)fflush((FILE *)xdrs->x_private);
+ (void) fflush((FILE *) xdrs->x_private);
/* xx should we close the file ?? */
};
-static bool_t
-xdrstdio_getlong(xdrs, lp)
- XDR *xdrs;
- register long *lp;
+static bool_t xdrstdio_getlong(xdrs, lp)
+XDR *xdrs;
+register long *lp;
{
- if (fread((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1)
- return (FALSE);
+ if (fread((caddr_t) lp, sizeof(long), 1, (FILE *) xdrs->x_private) !=
+ 1) return (FALSE);
+
#ifndef mc68000
*lp = ntohl(*lp);
#endif
return (TRUE);
}
-static bool_t
-xdrstdio_putlong(xdrs, lp)
- XDR *xdrs;
- long *lp;
+static bool_t xdrstdio_putlong(xdrs, lp)
+XDR *xdrs;
+long *lp;
{
#ifndef mc68000
long mycopy = htonl(*lp);
+
lp = &mycopy;
#endif
- if (fwrite((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1)
- return (FALSE);
+ if (fwrite((caddr_t) lp, sizeof(long), 1, (FILE *) xdrs->x_private) !=
+ 1) return (FALSE);
+
return (TRUE);
}
-static bool_t
-xdrstdio_getbytes(xdrs, addr, len)
- XDR *xdrs;
- caddr_t addr;
- u_int len;
+static bool_t xdrstdio_getbytes(xdrs, addr, len)
+XDR *xdrs;
+caddr_t addr;
+u_int len;
{
- if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
+ if ((len != 0)
+ && (fread(addr, (int) len, 1, (FILE *) xdrs->x_private) != 1))
return (FALSE);
return (TRUE);
}
-static bool_t
-xdrstdio_putbytes(xdrs, addr, len)
- XDR *xdrs;
- caddr_t addr;
- u_int len;
+static bool_t xdrstdio_putbytes(xdrs, addr, len)
+XDR *xdrs;
+caddr_t addr;
+u_int len;
{
- if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1))
+ if ((len != 0)
+ && (fwrite(addr, (int) len, 1, (FILE *) xdrs->x_private) != 1))
return (FALSE);
return (TRUE);
}
-static u_int
-xdrstdio_getpos(xdrs)
- XDR *xdrs;
+static u_int xdrstdio_getpos(xdrs)
+XDR *xdrs;
{
- return ((u_int) ftell((FILE *)xdrs->x_private));
+ return ((u_int) ftell((FILE *) xdrs->x_private));
}
-static bool_t
-xdrstdio_setpos(xdrs, pos)
- XDR *xdrs;
- u_int pos;
-{
+static bool_t xdrstdio_setpos(xdrs, pos)
+XDR *xdrs;
+u_int pos;
+{
- return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
- FALSE : TRUE);
+ return ((fseek((FILE *) xdrs->x_private, (long) pos, 0) < 0) ?
+ FALSE : TRUE);
}
-static long *
-xdrstdio_inline(xdrs, len)
- XDR *xdrs;
- u_int len;
+static long *xdrstdio_inline(xdrs, len)
+XDR *xdrs;
+u_int len;
{
/*