home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <memory.h>
- #include <grp.h>
- #include "grinf.h"
-
- static char *RCSid="$Header: grinf.c,v 1.4 92/01/23 15:05:34 dtb Exp $";
-
- int grinf_info_fpr (fp)
- FILE * fp;
- {
- int nout = 0;
- nout += fprintf (fp, "%s %s\n", __FILE__, GRINF_RCSid);
- return (nout);
- }
-
- /*
- grinfrq_set_dflt
- Puts default values in grinfrq structure.
- A pointer to the structure is passed as an argument.
- If a NULL pointer is used as an argument, then memory will
- be allocated and a pointer to the new structure returned.
- If a NULL pointer is returned, memory could not be allocated.
- */
- struct grinfrq * grinfrq_set_dflt ( p)
- struct grinfrq * p;
- {
- if (p == NULL)
- p = (struct grinfrq *) malloc ( sizeof (struct grinfrq) ) ;
- if (p != NULL) {
- (void) memset (p, 0, sizeof (struct grinfrq) );
- p->dlm = GRINFRQ_DLM_DFLT ;
- p->mdl = GRINFRQ_MDL_DFLT ;
- }
- return (p);
- }
-
- int grinf_fpr ( fp, grp, grinf)
- FILE * fp;
- struct group * grp;
- struct grinfrq * grinf;
- {
- int nout = 0; /* Number of bytes output */
- int dreq = 0; /* Is delimiter required */
-
- if (grinf->nam) {
- if (grinf->vbs)
- nout += fprintf (fp, "gname=");
- nout += fprintf (fp, "%s", grp->gr_name);
- dreq = 1;
- }
- if (grinf->epw) {
- if (dreq)
- nout += fprintf (fp, "%c", grinf->dlm);
- if (grinf->vbs)
- nout += fprintf (fp, "pass=");
- nout += fprintf (fp, "%s", grp->gr_passwd);
- }
- if (grinf->gid) {
- if (dreq)
- nout += fprintf (fp, "%c", grinf->dlm);
- if (grinf->vbs)
- nout += fprintf (fp, "gid=");
- nout += fprintf (fp, "%d", grp->gr_gid);
- }
- if (grinf->mem) {
- int mdreq = 0;
- int mno = 0;
- char **vmem = grp->gr_mem;
-
- if (dreq)
- nout += fprintf (fp, "%c", grinf->dlm);
- if (grinf->vbs)
- nout += fprintf (fp, "members=");
- for (; *vmem != NULL; vmem++) {
- if (mdreq) {
- nout += fprintf (fp, "%c", grinf->mdl);
- }
- nout += fprintf (fp, "%s", *vmem);
- mdreq = 1;
- }
- }
- if ( grinf->nam | grinf->epw | grinf->gid | grinf->mem )
- nout += fprintf (fp, "\n");
- return (nout);
- }
-
-
-