getrpcent_r.c 479 B

12345678910111213141516171819202122232425
  1. #include <netdb.h>
  2. #include <stdio.h>
  3. #include <errno.h>
  4. #include <string.h>
  5. int main(int argc, char *argv[])
  6. {
  7. int ret;
  8. char rpcdata[1024];
  9. struct rpcent rpcbuf, *ent;
  10. while ((ret = getrpcent_r(&rpcbuf, rpcdata, sizeof(rpcdata), &ent)) == 0) {
  11. printf("%s: %i", ent->r_name, ent->r_number);
  12. while (ent->r_aliases[0])
  13. printf(" %s", *ent->r_aliases++);
  14. printf("\n");
  15. }
  16. if (ret != ENOENT)
  17. printf("Test failed: %s\n", strerror(ret));
  18. endrpcent();
  19. return 0;
  20. }