Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/tests/nss/getproto_test.c
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | compare_protoent(struct protoent *pe1, struct protoent *pe2, void *mdata) | ||||
if ((pe1->p_aliases == NULL) || (pe2->p_aliases == NULL)) | if ((pe1->p_aliases == NULL) || (pe2->p_aliases == NULL)) | ||||
goto errfin; | goto errfin; | ||||
for (;*c1 && *c2; ++c1, ++c2) | for (;*c1 && *c2; ++c1, ++c2) | ||||
if (strcmp(*c1, *c2) != 0) | if (strcmp(*c1, *c2) != 0) | ||||
goto errfin; | goto errfin; | ||||
if ((*c1 != '\0') || (*c2 != '\0')) | if ((*c1 != NULL) || (*c2 != NULL)) | ||||
goto errfin; | goto errfin; | ||||
return 0; | return 0; | ||||
errfin: | errfin: | ||||
if (mdata == NULL) { | if (mdata == NULL) { | ||||
printf("following structures are not equal:\n"); | printf("following structures are not equal:\n"); | ||||
dump_protoent(pe1); | dump_protoent(pe1); | ||||
Show All 12 Lines | sdump_protoent(struct protoent *pe, char *buffer, size_t buflen) | ||||
written = snprintf(buffer, buflen, "%s %d", | written = snprintf(buffer, buflen, "%s %d", | ||||
pe->p_name, pe->p_proto); | pe->p_name, pe->p_proto); | ||||
buffer += written; | buffer += written; | ||||
if (written > (int)buflen) | if (written > (int)buflen) | ||||
return; | return; | ||||
buflen -= written; | buflen -= written; | ||||
if (pe->p_aliases != NULL) { | if (pe->p_aliases != NULL) { | ||||
if (*(pe->p_aliases) != '\0') { | if (*(pe->p_aliases) != NULL) { | ||||
for (cp = pe->p_aliases; *cp; ++cp) { | for (cp = pe->p_aliases; *cp; ++cp) { | ||||
written = snprintf(buffer, buflen, " %s", *cp); | written = snprintf(buffer, buflen, " %s", *cp); | ||||
buffer += written; | buffer += written; | ||||
if (written > (int)buflen) | if (written > (int)buflen) | ||||
return; | return; | ||||
buflen -= written; | buflen -= written; | ||||
if (buflen == 0) | if (buflen == 0) | ||||
▲ Show 20 Lines • Show All 368 Lines • Show Last 20 Lines |