4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 putprojent(const struct project
*proj
, FILE *fp
)
43 if (fprintf(fp
, "%s:%ld:%s:",
44 proj
->pj_name
!= NULL
? proj
->pj_name
: "",
46 proj
->pj_comment
!= NULL
? proj
->pj_comment
: "") == EOF
)
48 names
= proj
->pj_users
;
51 if (fputs(*names
++, fp
) == EOF
)
53 while (*names
!= NULL
)
54 if (fprintf(fp
, ",%s", *names
++) == EOF
)
57 if (putc(':', fp
) == EOF
)
59 names
= proj
->pj_groups
;
62 if (fputs(*names
++, fp
) == EOF
)
64 while (*names
!= NULL
)
65 if (fprintf(fp
, ",%s", *names
++) == EOF
)
68 if (putc(':', fp
) == EOF
)
70 if (fprintf(fp
, "%s\n",
71 proj
->pj_attr
!= NULL
? proj
->pj_attr
: "") == EOF
)
77 dogetproject(const char **list
)
80 struct project
*pproj
;
82 void *buf
[PROJECT_BUFSZ
];
86 if (list
== NULL
|| *list
== NULL
) {
88 while ((pproj
= getprojent(&proj
, buf
, PROJECT_BUFSZ
)) != NULL
)
89 (void) putprojent(pproj
, stdout
);
92 for (; *list
!= NULL
; list
++) {
93 projid
= strtol(*list
, &ptr
, 10);
95 pproj
= getprojbyname(*list
, &proj
,
98 pproj
= getprojbyid(projid
, &proj
,
101 rc
= EXC_NAME_NOT_FOUND
;
103 (void) putprojent(pproj
, stdout
);