/* $Id: group.mc,v 8.4 2012/09/12 19:03:16 ksb Exp $ * C support for group data type in mkcmd -- ksb */ /* look up the group entry, figure a size and copy the whole thing (ksb) * into a single malloc'd block. It is worth it to keep the callers * interface a simple as possible. Really. Then one can just free * the returned pointer, or not. */ struct group * %%K1v(pcName, pcParam) char *pcName, *pcParam; { register struct group *pGEFound; register char *pcScan; for (pcScan = pcName; '\000' != *pcScan; ++pcScan) { if (!isdigit(*pcScan)) { break; } } %@if group_help /* check a key for help token XXX -- ksb */ %@endif if ('\000' != *pcScan) { pGEFound = getgrnam(pcName); } else { pGEFound = getgrgid((gid_t)atoi(pcName)); } if ((struct group *)0 == pGEFound) { % fprintf(stderr, "%%s: %%s: getgrent: %%s: %%s\n", %b, pcParam, pcName, %E)%; return (struct group *)0; } % return %K1v(pGEFound)%; }