summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/irs/irpmarshall.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libresolv2/common/irs/irpmarshall.c')
-rw-r--r--usr/src/lib/libresolv2/common/irs/irpmarshall.c344
1 files changed, 147 insertions, 197 deletions
diff --git a/usr/src/lib/libresolv2/common/irs/irpmarshall.c b/usr/src/lib/libresolv2/common/irs/irpmarshall.c
index dfeb984262..85ffff1866 100644
--- a/usr/src/lib/libresolv2/common/irs/irpmarshall.c
+++ b/usr/src/lib/libresolv2/common/irs/irpmarshall.c
@@ -1,9 +1,4 @@
/*
- * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
* Copyright(c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
@@ -37,26 +32,24 @@
*/
/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: irpmarshall.c,v 8.7 2001/05/29 05:49:01 marka Exp $";
+static const char rcsid[] = "$Id: irpmarshall.c,v 1.7 2006/03/09 23:57:56 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#if 0
@@ -125,15 +118,14 @@ static const char *COLONSTR = ":";
#ifdef WANT_IRS_PW
/* +++++++++++++++++++++++++ struct passwd +++++++++++++++++++++++++ */
-
-/*
+/*%
* int irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
- * See above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on sucess, -1 on failure.
*
@@ -141,7 +133,7 @@ static const char *COLONSTR = ":";
int
irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len) {
- size_t need = 1 ; /* for null byte */
+ size_t need = 1 ; /*%< for null byte */
char pwUid[24];
char pwGid[24];
char pwChange[24];
@@ -177,7 +169,7 @@ irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len) {
pwClass = "";
#endif
- need += strlen(pw->pw_name) + 1; /* one for fieldsep */
+ need += strlen(pw->pw_name) + 1; /*%< one for fieldsep */
need += strlen(pw->pw_passwd) + 1;
need += strlen(pwUid) + 1;
need += strlen(pwGid) + 1;
@@ -199,7 +191,7 @@ irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -223,18 +215,14 @@ irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len) {
return (0);
}
-
-
-
-
-/*
+/*%
* int irp_unmarshall_pw(struct passwd *pw, char *buffer)
*
- * notes:
+ * notes: \li
*
- * see above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure
*
@@ -265,7 +253,7 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
/* pw_passwd field */
pass = NULL;
- if (getfield(&pass, 0, &p, fieldsep) == NULL) { /* field can be empty */
+ if (getfield(&pass, 0, &p, fieldsep) == NULL) { /*%< field can be empty */
goto error;
}
@@ -278,10 +266,10 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
pwuid = (uid_t)t;
- if ((long) pwuid != t) { /* value must have been too big. */
+ if ((long) pwuid != t) { /*%< value must have been too big. */
goto error;
}
@@ -295,10 +283,10 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
pwgid = (gid_t)t;
- if ((long)pwgid != t) { /* value must have been too big. */
+ if ((long)pwgid != t) { /*%< value must have been too big. */
goto error;
}
@@ -320,10 +308,10 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
pwchange = (time_t)t;
- if ((long)pwchange != t) { /* value must have been too big. */
+ if ((long)pwchange != t) { /*%< value must have been too big. */
goto error;
}
@@ -337,10 +325,10 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
pwexpire = (time_t)t;
- if ((long) pwexpire != t) { /* value must have been too big. */
+ if ((long) pwexpire != t) { /*%< value must have been too big. */
goto error;
}
@@ -404,28 +392,23 @@ irp_unmarshall_pw(struct passwd *pw, char *buffer) {
/* ------------------------- struct passwd ------------------------- */
#endif /* WANT_IRS_PW */
-
-
-
/* +++++++++++++++++++++++++ struct group +++++++++++++++++++++++++ */
-
-
-/*
+/*%
* int irp_marshall_gr(const struct group *gr, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
- * see above.
+ * See irpmarshall.h.
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure
*/
int
irp_marshall_gr(const struct group *gr, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char grGid[24];
const char *fieldsep = COLONSTR;
@@ -456,7 +439,7 @@ irp_marshall_gr(const struct group *gr, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -477,17 +460,14 @@ irp_marshall_gr(const struct group *gr, char **buffer, size_t *len) {
return (0);
}
-
-
-
-/*
+/*%
* int irp_unmarshall_gr(struct group *gr, char *buffer)
*
- * notes:
+ * notes: \li
*
- * see above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -515,7 +495,7 @@ irp_unmarshall_gr(struct group *gr, char *buffer) {
/* gr_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -530,15 +510,15 @@ irp_unmarshall_gr(struct group *gr, char *buffer) {
/* gr_gid field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
grgid = (gid_t)t;
- if ((long) grgid != t) { /* value must have been too big. */
+ if ((long) grgid != t) { /*%< value must have been too big. */
goto error;
}
@@ -582,16 +562,14 @@ irp_unmarshall_gr(struct group *gr, char *buffer) {
/* +++++++++++++++++++++++++ struct servent +++++++++++++++++++++++++ */
-
-
-/*
+/*%
* int irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
- * see above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure.
*
@@ -599,7 +577,7 @@ irp_unmarshall_gr(struct group *gr, char *buffer) {
int
irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char svPort[24];
const char *fieldsep = COLONSTR;
short realport;
@@ -630,7 +608,7 @@ irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -648,18 +626,14 @@ irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len) {
return (0);
}
-
-
-
-
-/*
+/*%
* int irp_unmarshall_sv(struct servent *sv, char *buffer)
*
- * notes:
+ * notes: \li
*
- * see above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure.
*
@@ -686,7 +660,7 @@ irp_unmarshall_sv(struct servent *sv, char *buffer) {
/* s_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -707,15 +681,15 @@ irp_unmarshall_sv(struct servent *sv, char *buffer) {
/* s_port field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
svport = (short)t;
- if ((long) svport != t) { /* value must have been too big. */
+ if ((long) svport != t) { /*%< value must have been too big. */
goto error;
}
svport = htons(svport);
@@ -748,16 +722,14 @@ irp_unmarshall_sv(struct servent *sv, char *buffer) {
/* +++++++++++++++++++++++++ struct protoent +++++++++++++++++++++++++ */
-
-
-/*
+/*%
* int irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
- * see above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -765,7 +737,7 @@ irp_unmarshall_sv(struct servent *sv, char *buffer) {
int
irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char prProto[24];
const char *fieldsep = COLONSTR;
@@ -791,7 +763,7 @@ irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -809,16 +781,14 @@ irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len) {
}
-
-
-/*
+/*%
* int irp_unmarshall_pr(struct protoent *pr, char *buffer)
*
- * notes:
+ * notes: \li
*
- * See above
+ * See irpmarshall.h
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure
*
@@ -844,7 +814,7 @@ int irp_unmarshall_pr(struct protoent *pr, char *buffer) {
/* p_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -865,15 +835,15 @@ int irp_unmarshall_pr(struct protoent *pr, char *buffer) {
/* p_proto field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
prproto = (int)t;
- if ((long) prproto != t) { /* value must have been too big. */
+ if ((long) prproto != t) { /*%< value must have been too big. */
goto error;
}
@@ -898,15 +868,14 @@ int irp_unmarshall_pr(struct protoent *pr, char *buffer) {
/* +++++++++++++++++++++++++ struct hostent +++++++++++++++++++++++++ */
-
-/*
+/*%
* int irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
- * see above.
+ * See irpmarshall.h.
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure.
*
@@ -914,7 +883,7 @@ int irp_unmarshall_pr(struct protoent *pr, char *buffer) {
int
irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char hoaddrtype[24];
char holength[24];
char **av;
@@ -952,7 +921,7 @@ irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len) {
/* we determine an upper bound on the string length needed, not an
exact length. */
- addrlen = (ho->h_addrtype == AF_INET ? 16 : 46) ; /* XX other AF's?? */
+ addrlen = (ho->h_addrtype == AF_INET ? 16 : 46) ; /*%< XX other AF's?? */
for (av = ho->h_addr_list; av != NULL && *av != NULL ; av++)
need += addrlen;
@@ -967,7 +936,7 @@ irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -1006,16 +975,14 @@ irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len) {
return (-1);
}
-
-
-/*
+/*%
* int irp_unmarshall_ho(struct hostent *ho, char *buffer)
*
- * notes:
+ * notes: \li
*
- * See above.
+ * See irpmarshall.h.
*
- * return:
+ * return: \li
*
* 0 on success, -1 on failure.
*
@@ -1027,7 +994,7 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
int hoaddrtype;
int holength;
long t;
- char *name = NULL;
+ char *name;
char **aliases = NULL;
char **hohaddrlist = NULL;
size_t hoaddrsize;
@@ -1047,7 +1014,7 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
/* h_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -1068,7 +1035,7 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
/* h_addrtype field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
if (strcmp(tmpbuf, "AF_INET") == 0)
@@ -1082,15 +1049,15 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
/* h_length field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
t = strtol(tmpbuf, &tb, 10);
if (*tb) {
- goto error; /* junk in value */
+ goto error; /*%< junk in value */
}
holength = (int)t;
- if ((long) holength != t) { /* value must have been too big. */
+ if ((long) holength != t) { /*%< value must have been too big. */
goto error;
}
@@ -1150,6 +1117,7 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
errno = myerrno;
if (name != NULL) free(name);
+ free_array(hohaddrlist, 0);
free_array(aliases, 0);
return (-1);
@@ -1161,16 +1129,15 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
/* +++++++++++++++++++++++++ struct netgrp +++++++++++++++++++++++++ */
-
-/*
+/*%
* int irp_marshall_ng(const char *host, const char *user,
* const char *domain, char *buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
* See note for irp_marshall_ng_start
*
- * return:
+ * return: \li
*
* 0 on success, 0 on failure.
*
@@ -1179,7 +1146,7 @@ irp_unmarshall_ho(struct hostent *ho, char *buffer) {
int
irp_marshall_ng(const char *host, const char *user, const char *domain,
char **buffer, size_t *len) {
- size_t need = 1; /* for nul byte */
+ size_t need = 1; /*%< for nul byte */
const char *fieldsep = ",";
if (len == NULL) {
@@ -1187,7 +1154,7 @@ irp_marshall_ng(const char *host, const char *user, const char *domain,
return (-1);
}
- need += 4; /* two parens and two commas */
+ need += 4; /*%< two parens and two commas */
need += (host == NULL ? 0 : strlen(host));
need += (user == NULL ? 0 : strlen(user));
need += (domain == NULL ? 0 : strlen(domain));
@@ -1201,7 +1168,7 @@ irp_marshall_ng(const char *host, const char *user, const char *domain,
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -1233,18 +1200,17 @@ irp_marshall_ng(const char *host, const char *user, const char *domain,
/* ---------- */
-
-/*
+/*%
* int irp_unmarshall_ng(const char **host, const char **user,
* const char **domain, char *buffer)
*
- * notes:
+ * notes: \li
*
* Unpacks the BUFFER into 3 character arrays it allocates and assigns
* to *HOST, *USER and *DOMAIN. If any field of the value is empty,
* then the corresponding paramater value will be set to NULL.
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*/
@@ -1320,7 +1286,6 @@ irp_unmarshall_ng(const char **hostp, const char **userp, const char **domainp,
if (host != NULL) free(host);
if (user != NULL) free(user);
- if (domain != NULL) free(domain);
return (-1);
}
@@ -1332,15 +1297,14 @@ irp_unmarshall_ng(const char **hostp, const char **userp, const char **domainp,
/* +++++++++++++++++++++++++ struct nwent +++++++++++++++++++++++++ */
-
-/*
+/*%
* int irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
* See at top.
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -1348,7 +1312,7 @@ irp_unmarshall_ng(const char **hostp, const char **userp, const char **domainp,
int
irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char nAddrType[24];
char nNet[MAXPADDRSIZE];
const char *fieldsep = COLONSTR;
@@ -1381,7 +1345,7 @@ irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -1399,16 +1363,14 @@ irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len) {
return (0);
}
-
-
-/*
+/*%
* int irp_unmarshall_nw(struct nwent *ne, char *buffer)
*
- * notes:
+ * notes: \li
*
* See note up top.
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -1435,7 +1397,7 @@ irp_unmarshall_nw(struct nwent *ne, char *buffer) {
/* n_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -1456,7 +1418,7 @@ irp_unmarshall_nw(struct nwent *ne, char *buffer) {
/* h_addrtype field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
if (strcmp(tmpbuf, "AF_INET") == 0)
@@ -1470,7 +1432,7 @@ irp_unmarshall_nw(struct nwent *ne, char *buffer) {
/* n_net field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
nnet = 0;
@@ -1509,15 +1471,14 @@ irp_unmarshall_nw(struct nwent *ne, char *buffer) {
/* +++++++++++++++++++++++++ struct netent +++++++++++++++++++++++++ */
-
-/*
+/*%
* int irp_marshall_ne(struct netent *ne, char **buffer, size_t *len)
*
- * notes:
+ * notes: \li
*
* See at top.
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -1525,7 +1486,7 @@ irp_unmarshall_nw(struct nwent *ne, char *buffer) {
int
irp_marshall_ne(struct netent *ne, char **buffer, size_t *len) {
- size_t need = 1; /* for null byte */
+ size_t need = 1; /*%< for null byte */
char nAddrType[24];
char nNet[MAXPADDRSIZE];
const char *fieldsep = COLONSTR;
@@ -1558,7 +1519,7 @@ irp_marshall_ne(struct netent *ne, char **buffer, size_t *len) {
}
if (*buffer == NULL) {
- need += 2; /* for CRLF */
+ need += 2; /*%< for CRLF */
*buffer = memget(need);
if (*buffer == NULL) {
errno = ENOMEM;
@@ -1576,16 +1537,14 @@ irp_marshall_ne(struct netent *ne, char **buffer, size_t *len) {
return (0);
}
-
-
-/*
+/*%
* int irp_unmarshall_ne(struct netent *ne, char *buffer)
*
- * notes:
+ * notes: \li
*
* See note up top.
*
- * return:
+ * return: \li
*
* 0 on success and -1 on failure.
*
@@ -1612,7 +1571,7 @@ irp_unmarshall_ne(struct netent *ne, char *buffer) {
/* n_name field */
name = NULL;
- if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0) {
+ if (getfield(&name, 0, &p, fieldsep) == NULL || strlen(name) == 0U) {
goto error;
}
@@ -1633,7 +1592,7 @@ irp_unmarshall_ne(struct netent *ne, char *buffer) {
/* h_addrtype field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
if (strcmp(tmpbuf, "AF_INET") == 0)
@@ -1647,7 +1606,7 @@ irp_unmarshall_ne(struct netent *ne, char *buffer) {
/* n_net field */
tb = tmpbuf;
if (getfield(&tb, sizeof tmpbuf, &p, fieldsep) == NULL ||
- strlen(tb) == 0) {
+ strlen(tb) == 0U) {
goto error;
}
bits = inet_net_pton(naddrtype, tmpbuf, &nnet, sizeof nnet);
@@ -1678,11 +1637,10 @@ irp_unmarshall_ne(struct netent *ne, char *buffer) {
/* =========================================================================== */
-
-/*
+/*%
* static char ** splitarray(const char *buffer, const char *buffend, char delim)
*
- * notes:
+ * notes: \li
*
* Split a delim separated astring. Not allowed
* to have two delims next to each other. BUFFER points to begining of
@@ -1690,7 +1648,7 @@ irp_unmarshall_ne(struct netent *ne, char *buffer) {
* (i.e. points at where the null byte would be if null
* terminated).
*
- * return:
+ * return: \li
*
* Returns a malloced array of pointers, each pointer pointing to a
* malloced string. If BUFEER is an empty string, then return values is
@@ -1726,7 +1684,7 @@ splitarray(const char *buffer, const char *buffend, char delim) {
}
if (count > 0) {
- count++ ; /* for NULL at end */
+ count++ ; /*%< for NULL at end */
aptr = arr = malloc(count * sizeof (char *));
if (aptr == NULL) {
errno = ENOMEM;
@@ -1756,13 +1714,10 @@ splitarray(const char *buffer, const char *buffend, char delim) {
return (arr);
}
-
-
-
-/*
+/*%
* static size_t joinlength(char * const *argv)
*
- * return:
+ * return: \li
*
* the number of bytes in all the arrays pointed at
* by argv, including their null bytes(which will usually be turned
@@ -1783,18 +1738,16 @@ joinlength(char * const *argv) {
return (len);
}
-
-
-/*
+/*%
* int joinarray(char * const *argv, char *buffer, char delim)
*
- * notes:
+ * notes: \li
*
* Copy all the ARGV strings into the end of BUFFER
* separating them with DELIM. BUFFER is assumed to have
* enough space to hold everything and to be already null-terminated.
*
- * return:
+ * return: \li
*
* 0 unless argv or buffer is NULL.
*
@@ -1824,11 +1777,10 @@ joinarray(char * const *argv, char *buffer, char delim) {
return (0);
}
-
-/*
+/*%
* static char * getfield(char **res, size_t reslen, char **ptr, char delim)
*
- * notes:
+ * notes: \li
*
* Stores in *RES, which is a buffer of length RESLEN, a
* copy of the bytes from *PTR up to and including the first
@@ -1836,7 +1788,7 @@ joinarray(char * const *argv, char *buffer, char delim) {
* assigned a malloced buffer to hold the copy. *PTR is
* modified to point at the found delimiter.
*
- * return:
+ * return: \li
*
* If there was no delimiter, then NULL is returned,
* otherewise *RES is returned.
@@ -1861,7 +1813,7 @@ getfield(char **res, size_t reslen, char **ptr, char delim) {
if (*res == NULL) {
*res = strndup(*ptr, q - *ptr);
} else {
- if ((size_t)(q - *ptr + 1) > reslen) { /* to big for res */
+ if ((size_t)(q - *ptr + 1) > reslen) { /*%< to big for res */
errno = EINVAL;
return (NULL);
} else {
@@ -1879,16 +1831,16 @@ getfield(char **res, size_t reslen, char **ptr, char delim) {
-
+#ifndef HAVE_STRNDUP
/*
* static char * strndup(const char *str, size_t len)
*
- * notes:
+ * notes: \li
*
* like strdup, except do len bytes instead of the whole string. Always
* null-terminates.
*
- * return:
+ * return: \li
*
* The newly malloced string.
*
@@ -1904,18 +1856,18 @@ strndup(const char *str, size_t len) {
p[len] = 0x0;
return (p);
}
-
+#endif
#if WANT_MAIN
-/*
+/*%
* static int strcmp_nws(const char *a, const char *b)
*
- * notes:
+ * notes: \li
*
* do a strcmp, except uneven lengths of whitespace compare the same
*
- * return:
+ * return: \li
*
*/
@@ -1949,14 +1901,10 @@ strcmp_nws(const char *a, const char *b) {
#endif
-
-
-
-
-/*
+/*%
* static void free_array(char **argv, size_t entries)
*
- * notes:
+ * notes: \li
*
* Free argv and each of the pointers inside it. The end of
* the array is when a NULL pointer is found inside. If
@@ -1968,12 +1916,12 @@ strcmp_nws(const char *a, const char *b) {
static void
free_array(char **argv, size_t entries) {
char **p = argv;
- int useEntries = (entries > 0);
+ int useEntries = (entries > 0U);
if (argv == NULL)
return;
- while ((useEntries && entries > 0) || *p) {
+ while ((useEntries && entries > 0U) || *p) {
if (*p)
free(*p);
p++;
@@ -1991,7 +1939,7 @@ free_array(char **argv, size_t entries) {
#if WANT_MAIN
-/* takes an option to indicate what sort of marshalling(read the code) and
+/*% takes an option to indicate what sort of marshalling(read the code) and
an argument. If the argument looks like a marshalled buffer(has a ':'
embedded) then it's unmarshalled and the remarshalled and the new string
is compared to the old one.
@@ -2349,3 +2297,5 @@ main(int argc, char **argv) {
}
#endif
+
+/*! \file */