Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mail PR/32964: Johan Veenhuizen: implement the unali...



details:   https://anonhg.NetBSD.org/src/rev/01e37d0b0094
branches:  trunk
changeset: 588772:01e37d0b0094
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 03 13:36:27 2006 +0000

description:
PR/32964: Johan Veenhuizen: implement the unalias command

diffstat:

 usr.bin/mail/cmd3.c   |  50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 usr.bin/mail/cmdtab.c |   5 +++--
 usr.bin/mail/extern.h |   5 +++--
 3 files changed, 54 insertions(+), 6 deletions(-)

diffs (130 lines):

diff -r 31fc75dabef0 -r 01e37d0b0094 usr.bin/mail/cmd3.c
--- a/usr.bin/mail/cmd3.c       Fri Mar 03 10:32:01 2006 +0000
+++ b/usr.bin/mail/cmd3.c       Fri Mar 03 13:36:27 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmd3.c,v 1.27 2005/07/19 23:07:10 christos Exp $       */
+/*     $NetBSD: cmd3.c,v 1.28 2006/03/03 13:36:27 christos Exp $       */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cmd3.c     8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: cmd3.c,v 1.27 2005/07/19 23:07:10 christos Exp $");
+__RCSID("$NetBSD: cmd3.c,v 1.28 2006/03/03 13:36:27 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -46,6 +46,7 @@
  *
  * Still more user commands.
  */
+static int delgroup(const char *);
 static int diction(const void *, const void *);
 
 /*
@@ -504,6 +505,51 @@
 }
 
 /*
+ * The unalias command takes a list of alises
+ * and discards the remembered groups of users.
+ */
+int
+unalias(void *v)
+{
+       char **ap;
+
+       for (ap = v; *ap != NULL; ap++)
+               (void)delgroup(*ap);
+       return 0;
+}
+
+/*
+ * Delete the named group alias. Return zero if the group was
+ * successfully deleted, or -1 if there was no such group.
+ */
+static int
+delgroup(const char *name)
+{
+       struct grouphead *gh, *p;
+       struct group *g;
+       int h;
+
+       h = hash(name);
+       for (gh = groups[h], p = NULL; gh != NULL; p = gh, gh = gh->g_link)
+               if (strcmp(gh->g_name, name) == 0) {
+                       if (p == NULL)
+                               groups[h] = gh->g_link;
+                       else
+                               p->g_link = gh->g_link;
+                       while (gh->g_list != NULL) {
+                               g = gh->g_list;
+                               gh->g_list = g->ge_link;
+                               free(g->ge_name);
+                               free(g);
+                       }
+                       free(gh->g_name);
+                       free(gh);
+                       return 0;
+               }
+       return -1;
+}
+
+/*
  * Sort the passed string vecotor into ascending dictionary
  * order.
  */
diff -r 31fc75dabef0 -r 01e37d0b0094 usr.bin/mail/cmdtab.c
--- a/usr.bin/mail/cmdtab.c     Fri Mar 03 10:32:01 2006 +0000
+++ b/usr.bin/mail/cmdtab.c     Fri Mar 03 13:36:27 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmdtab.c,v 1.10 2003/08/07 11:14:36 agc Exp $  */
+/*     $NetBSD: cmdtab.c,v 1.11 2006/03/03 13:36:27 christos Exp $     */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cmdtab.c   8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: cmdtab.c,v 1.10 2003/08/07 11:14:36 agc Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.11 2006/03/03 13:36:27 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,6 +69,7 @@
        { "page",       more,           MSGLIST,        0,      MMNDEL },
        { "More",       More,           MSGLIST,        0,      MMNDEL },
        { "Page",       More,           MSGLIST,        0,      MMNDEL },
+       { "unalias",    unalias,        M|RAWLIST,      1,      1000 },
        { "unread",     unread,         MSGLIST,        0,      MMNDEL },
        { "!",          shell,          I|STRLIST,      0,      0 },
        { "copy",       copycmd,        M|STRLIST,      0,      0 },
diff -r 31fc75dabef0 -r 01e37d0b0094 usr.bin/mail/extern.h
--- a/usr.bin/mail/extern.h     Fri Mar 03 10:32:01 2006 +0000
+++ b/usr.bin/mail/extern.h     Fri Mar 03 13:36:27 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.22 2006/01/05 02:13:41 christos Exp $     */
+/*     $NetBSD: extern.h,v 1.23 2006/03/03 13:36:27 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -29,7 +29,7 @@
  * SUCH DAMAGE.
  *
  *     @(#)extern.h    8.2 (Berkeley) 4/20/95 
- *     $NetBSD: extern.h,v 1.22 2006/01/05 02:13:41 christos Exp $
+ *     $NetBSD: extern.h,v 1.23 2006/03/03 13:36:27 christos Exp $
  */
 
 struct name;
@@ -148,6 +148,7 @@
 void    holdsigs(void);
 int     ifcmd(void *);
 int     igfield(void *);
+int     unalias(void *);
 struct ignoretab;
 int     ignore1(char *[], struct ignoretab *, const char *);
 int     igshow(struct ignoretab *, const char *);



Home | Main Index | Thread Index | Old Index