Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / rmm.c,v
1 head    1.5;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.5
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.4;
12
13 1.4
14 date    92.11.04.01.00.56;      author jromine; state Exp;
15 branches;
16 next    1.3;
17
18 1.3
19 date    92.02.11.21.37.29;      author jromine; state Exp;
20 branches;
21 next    1.2;
22
23 1.2
24 date    92.01.31.22.26.14;      author jromine; state Exp;
25 branches;
26 next    1.1;
27
28 1.1
29 date    92.01.31.22.25.48;      author jromine; state Exp;
30 branches;
31 next    ;
32
33
34 desc
35 @@
36
37
38 1.5
39 log
40 @endif sugar
41 @
42 text
43 @/* rmm.c - remove a message */
44 #ifndef lint
45 static char ident[] = "@@(#)$Id: rmm.c,v 1.4 1992/11/04 01:00:56 jromine Exp jromine $";
46 #endif  /* lint */
47
48 #include "../h/mh.h"
49 #include <stdio.h>
50 #ifdef LOCALE
51 #include        <locale.h>
52 #endif
53
54 /* \f */
55
56 static struct swit switches[] = {
57 #define HELPSW  0
58     "help", 4,
59
60     NULL, 0
61 };
62
63 /* \f */
64
65 /* ARGSUSED */
66
67 main (argc, argv)
68 int     argc;
69 char  **argv;
70 {
71     int     msgp = 0,
72             msgnum,
73             vecp;
74     char   *cp,
75            *dp,
76            *maildir,
77            *folder = NULL,
78             buf[100],
79           **ap,
80           **argp,
81           **vec,
82            *arguments[MAXARGS],
83            *msgs[MAXARGS];
84     struct msgs *mp;
85
86 #ifdef LOCALE
87         setlocale(LC_ALL, "");
88 #endif
89     invo_name = r1bindex (argv[0], '/');
90     if ((cp = m_find (invo_name)) != NULL) {
91         ap = brkstring (cp = getcpy (cp), " ", "\n");
92         ap = copyip (ap, arguments);
93     }
94     else
95         ap = arguments;
96     (void) copyip (argv + 1, ap);
97     argp = arguments;
98
99 /* \f */
100
101     while (cp = *argp++) {
102         if (*cp == '-')
103             switch (smatch (++cp, switches)) {
104                 case AMBIGSW: 
105                     ambigsw (cp, switches);
106                     done (1);
107                 case UNKWNSW: 
108                     adios (NULLCP, "-%s unknown\n", cp);
109                 case HELPSW: 
110                     (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
111                             invo_name);
112                     help (buf, switches);
113                     done (1);
114             }
115         if (*cp == '+' || *cp == '@@') {
116             if (folder)
117                 adios (NULLCP, "only one folder at a time!");
118             else
119                 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
120         }
121         else
122             msgs[msgp++] = cp;
123     }
124
125 /* \f */
126
127     if (!m_find ("path"))
128         free (path ("./", TFOLDER));
129     if (!msgp)
130         msgs[msgp++] = "cur";
131     if (!folder)
132         folder = m_getfolder ();
133     maildir = m_maildir (folder);
134
135     if (chdir (maildir) == NOTOK)
136         adios (maildir, "unable to change directory to");
137     if (!(mp = m_gmsg (folder)))
138         adios (NULLCP, "unable to read folder %s", folder);
139     if (mp -> hghmsg == 0)
140         adios (NULLCP, "no messages in %s", folder);
141
142     for (msgnum = 0; msgnum < msgp; msgnum++)
143         if (!m_convert (mp, msgs[msgnum]))
144             done (1);
145     m_setseq (mp);
146
147     for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
148         if (mp -> msgstats[msgnum] & SELECTED) {
149 #ifdef  notdef
150             mp -> msgstats[msgnum] |= DELETED;
151 #endif  /* notdef */
152             mp -> msgstats[msgnum] &= ~EXISTS;
153         }
154     mp -> msgflags |= SEQMOD;
155
156     m_replace (pfolder, folder);
157     m_sync (mp);
158     m_update ();
159
160     if (rmmproc) {
161         if (mp -> numsel > MAXARGS - 2)
162             adios (NULLCP, "more than %d messages for %s exec", MAXARGS - 2,
163                     rmmproc);
164         vec = (char **) calloc ((unsigned) (mp -> numsel + 2), sizeof *vec);
165         if (vec == NULL)
166             adios (NULLCP, "unable to allocate exec vector");
167         vecp = 1;
168         for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
169             if (mp -> msgstats[msgnum] & SELECTED)
170                 vec[vecp++] = getcpy (m_name (msgnum));
171         vec[vecp] = NULL;
172
173         (void) fflush (stdout);
174         vec[0] = r1bindex (rmmproc, '/');
175         execvp (rmmproc, vec);
176         adios (rmmproc, "unable to exec");
177     }
178
179     for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
180         if (mp -> msgstats[msgnum] & SELECTED) {
181             (void) strcpy (buf, m_backup (dp = m_name (msgnum)));
182             if (rename (dp, buf) == NOTOK)
183                 admonish (buf, "unable to rename %s to", dp);
184         }
185
186     done (0);
187 }
188 @
189
190
191 1.4
192 log
193 @LOCALE
194 @
195 text
196 @d3 2
197 a4 2
198 static char ident[] = "@@(#)$Id: rmm.c,v 1.3 1992/02/11 21:37:29 jromine Exp jromine $";
199 #endif  lint
200 d109 1
201 a109 1
202 #endif  notdef
203 @
204
205
206 1.3
207 log
208 @allow relative folders with "@@".  I hope there isn't a reason
209 this wasn't already done.
210 @
211 text
212 @d3 1
213 a3 1
214 static char ident[] = "@@(#)$Id: rmm.c,v 1.2 1992/01/31 22:26:14 jromine Exp jromine $";
215 d8 3
216 d44 3
217 @
218
219
220 1.2
221 log
222 @kerberos
223 @
224 text
225 @d3 1
226 a3 1
227 static char ident[] = "@@(#)$Id: scan.c,v 1.9 1992/01/23 23:06:45 jromine Exp $";
228 d67 1
229 a67 1
230         if (*cp == '+') {
231 d71 1
232 a71 1
233                 folder = path (cp + 1, TFOLDER);
234 @
235
236
237 1.1
238 log
239 @Initial revision
240 @
241 text
242 @d2 3
243 d15 1
244 a15 1
245     NULL, NULL
246 @