xref: /illumos-gate/usr/src/cmd/oamuser/lib/putprojent.c (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #include <stdio.h>
28 #include <project.h>
29 #include <unistd.h>
30 
31 /*
32  * putprojent()	function to write a project structure to a file
33  */
34 void
35 putprojent(struct project *projstr, FILE *to)
36 {
37 	char **memptr;		/* member vector pointer */
38 
39 	(void) fprintf(to, "%s:%d:%s:", projstr->pj_name,
40 	    projstr->pj_projid, projstr->pj_comment);
41 
42 	/*
43 	 * do user names first
44 	 */
45 	memptr = projstr->pj_users;
46 
47 	while (*memptr != NULL) {
48 		(void) fprintf(to, "%s", *memptr);
49 		memptr++;
50 		if (*memptr != NULL)
51 			(void) fprintf(to, ",");
52 	}
53 
54 	(void) fprintf(to, ":");
55 
56 	/*
57 	 * now do groups
58 	 */
59 	memptr = projstr->pj_groups;
60 
61 	while (*memptr != NULL) {
62 		(void) fprintf(to, "%s", *memptr);
63 		memptr++;
64 		if (*memptr != NULL)
65 			(void) fprintf(to, ",");
66 	}
67 
68 	(void) fprintf(to, ":%s\n", projstr->pj_attr);
69 }
70