X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fconflict.c;h=2324c650a4eabab9672695835eb29b491a1dfc4c;hb=7946a8c713bd43a52229345ad0289aaa461acfb3;hp=c0ba63ba984af3a8281b34d774611945794eb2fd;hpb=8f4c5da8971926f7eccc912f7998c343aef3c33b;p=mmh diff --git a/uip/conflict.c b/uip/conflict.c index c0ba63b..2324c65 100644 --- a/uip/conflict.c +++ b/uip/conflict.c @@ -2,13 +2,16 @@ /* * conflict.c -- check for conflicts in mail system * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include #include #include -#include +#include +#include #include #include @@ -89,10 +92,10 @@ main (int argc, char **argv) snprintf (buf, sizeof(buf), "%s [switches] [aliasfiles ...]", invo_name); print_help (buf, switches, 0); - done (1); + done (0); case VERSIONSW: print_version(invo_name); - done (1); + done (0); case MAILSW: if (!(cp = *argp++) || *cp == '-') @@ -128,13 +131,10 @@ main (int argc, char **argv) grp_names (); grp_members (); grp_ids (); -#ifdef UCI - ldr_names (); - ldr_ship (); -#endif /* UCI */ maildrops (); - return done (0); + done (0); + return 1; } @@ -185,8 +185,7 @@ grp_names (void) /* allocate space NGRPS at a time */ numgroups = 0; maxgroups = NGRPS; - if (!(grps = (char **) malloc((size_t) (maxgroups * sizeof(*grps))))) - adios (NULL, "unable to allocate group name storage"); + grps = (char **) mh_xmalloc((size_t) (maxgroups * sizeof(*grps))); setgrent (); while ((gr = getgrent ())) { @@ -201,9 +200,8 @@ grp_names (void) if (i >= numgroups) { if (numgroups >= maxgroups) { maxgroups += NGRPS; - if (!(grps = (char **) realloc(grps, - (size_t) (maxgroups * sizeof(*grps))))) - adios (NULL, "unable to reallocate group name storage"); + grps = (char **) mh_xrealloc(grps, + (size_t) (maxgroups * sizeof(*grps))); } grps[numgroups++] = getcpy (gr->gr_name); } @@ -377,169 +375,3 @@ setup (void) } } } - -#ifdef UCI -/* - * UCI specific stuff for conflict - */ - -/* taken from */ - -#define GLDRS "/admin/etc/GroupLeaders" - -struct grpldr { - char *gl_name; - char **gl_ldr; -}; - -int setglent (), endglent (); -struct grpldr *getglent (), *getglnam (); - - -/* taken from the getglent() routines */ - -#define MAXGLS 100 - -static FILE *glp = NULL; -static char line[BUFSIZ+1]; -static struct grpldr grpldr; -static char *gl_ldr[MAXGLS + 1]; - - -setglent() { - if (glp == NULL) - glp = fopen (GLDRS, "r"); - else - rewind (glp); - - return (glp != NULL); -} - - -endglent() { - if (glp != NULL) { - fclose (glp); - glp = NULL; - } - - return 1; -} - -struct grpldr *getglent () { - register char *cp, - **q; - - if (glp == NULL && !setglent ()) - return NULL; - if ((cp = fgets (line, BUFSIZ, glp)) == NULL) - return NULL; - - grpldr.gl_name = cp; - grpldr.gl_ldr = q = gl_ldr; - - while (*cp) { - while (*cp && !isspace (*cp)) - cp++; - while (*cp && isspace (*cp)) - *cp++ = '\0'; - if (*cp == '\0') - break; - if (q < gl_ldr + MAXGLS) - *q++ = cp; - else - break; - } - *q = NULL; - - return (&grpldr); -} - -struct grpldr *getglnam (name) -char *name; -{ - register struct grpldr *gl = NULL; - - setglent (); - while (gl = getglent ()) - if (strcmp (name, gl->gl_name) == 0) - break; - endglent (); - - return gl; -} - -ldr_names () { - register int gp, - hit = 0; - char *gldrs[NGRPS]; - register struct grpldr *gl; - - gldrs[0] = NULL; - setglent (); - while (gl = getglent ()) { - if (getgrnam (gl->gl_name) == NULL) { - setup (); - fprintf (out, "unknown group %s in group leaders file\n", - gl->gl_name); - hit++; - } - for (gp = 0; gldrs[gp]; gp++) - if (strcmp (gldrs[gp], gl->gl_name) == 0) { - setup (); - fprintf (out, "duplicate group %s in group leaders file\n", - gl->gl_name); - hit++; - break; - } - if (gldrs[gp] == NULL) - if (gp < NGRPS) { - gldrs[gp++] = getcpy (gl->gl_name); - gldrs[gp] = NULL; - } - else { - setup (); - fprintf (out, "more than %d groups in group leaders file%s\n", - " (time to recompile)", NGRPS - 1); - hit++; - } - } - endglent (); - - for (gp = 0; gldrs[gp]; gp++) - free (gldrs[gp]); - - if (!hit && out && !mail) - fprintf (out, "all groups in group leaders file accounted for\n"); -} - - -ldr_ship () { - register int hit = 0; - register char **cp, - **dp; - register struct grpldr *gl; - - setglent (); - while (gl = getglent ()) - for (cp = gl->gl_ldr; *cp; cp++) { - if (!check (*cp)) { - setup (); - fprintf (out, "group %s has unknown leader %s\n", - gl->gl_name, *cp); - hit++; - } - - for (dp = cp + 1; *dp; dp++) - if (strcmp (*cp, *dp) == 0) { - setup (); - fprintf (out, "group %s had duplicate leader %s\n", - gl->gl_name, *cp); - hit++; - } - } - endglent (); - - if (!hit && out && !mail) - fprintf (out, "all group leaders accounted for\n"); -} -#endif /* UCI */