1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 #include <stdio.h>
  17 #include <stdlib.h>
  18 #include <errno.h>
  19 #include <netdb.h>
  20 #include "getent.h"
  21 
  22 int
  23 dogetnetgr(const char **list)
  24 {
  25         char *host;
  26         char *user;
  27         char *dom;
  28         int rc = EXC_SUCCESS;
  29 
  30         if (list == NULL || *list == NULL)
  31                 return (EXC_ENUM_NOT_SUPPORTED);
  32 
  33         for (; *list != NULL; list++) {
  34                 printf("\n%s", *list);
  35                 setnetgrent(*list);
  36                 for (;;) {
  37                         rc = getnetgrent(&host, &user, &dom);
  38                         if (!rc)
  39                                 break;
  40                         printf(" \\\n\t(%s,%s,%s)",
  41                             (host) ? host : "",
  42                             (user) ? user : "",
  43                             (dom)  ? dom  : "");
  44                 }
  45                 printf("\n");
  46         }
  47 
  48         return (rc);
  49 }