Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / RCS / m_sync.c,v
1 head    1.8;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.8
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.7;
12
13 1.7
14 date    92.01.31.21.56.12;      author jromine; state Exp;
15 branches;
16 next    1.6;
17
18 1.6
19 date    90.11.05.11.46.34;      author mh;      state Exp;
20 branches;
21 next    1.5;
22
23 1.5
24 date    90.04.05.15.31.00;      author sources; state Exp;
25 branches;
26 next    1.4;
27
28 1.4
29 date    90.04.05.14.45.03;      author sources; state Exp;
30 branches;
31 next    1.3;
32
33 1.3
34 date    90.02.05.14.22.42;      author sources; state Exp;
35 branches;
36 next    1.2;
37
38 1.2
39 date    90.02.01.14.06.58;      author sources; state Exp;
40 branches;
41 next    1.1;
42
43 1.1
44 date    90.02.01.14.04.25;      author sources; state Exp;
45 branches;
46 next    ;
47
48
49 desc
50 @@
51
52
53 1.8
54 log
55 @endif sugar
56 @
57 text
58 @/* m_sync.c - synchronize message sequences */
59 #ifndef lint
60 static char ident[] = "@@(#)$Id: m_sync.c,v 1.7 1992/01/31 21:56:12 jromine Exp jromine $";
61 #endif  /* lint */
62
63 #include "../h/mh.h"
64 #include <stdio.h>
65 #include <signal.h>
66 #ifndef sigmask
67 #define sigmask(s)      (1 << ((s) - 1))
68 #endif  /* not sigmask */
69
70
71 /* decision logic
72     1.  public and folder readonly: make it private
73     2a. public: add it to the sequences file
74     2b. private: add it to the profile
75  */
76
77
78 void m_sync (mp)
79 register struct msgs *mp;
80 {
81     int     bits;
82     register int    i;
83     register char  *cp;
84     char    flags,
85             attr[BUFSIZ],
86             seq[BUFSIZ * 2];
87     register FILE  *fp;
88 #ifndef BSD42
89     TYPESIG (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
90 #else   /* BSD42 */
91     int     smask;
92 #endif  /* BSD42 */
93
94     if (!(mp -> msgflags & SEQMOD))
95         return;
96     mp -> msgflags &= ~SEQMOD;
97
98     m_getdefs ();
99     (void) sprintf (seq, "%s/%s", mp -> foldpath, mh_seq);
100     bits = FFATTRSLOT;
101     fp = NULL;
102
103     flags = mp -> msgflags;
104     if (mh_seq == NULL || *mh_seq == 0)
105         mp -> msgflags |= READONLY;
106
107     for (i = 0; mp -> msgattrs[i]; i++) {
108         (void) sprintf (attr, "atr-%s-%s", mp -> msgattrs[i], mp -> foldpath);
109         if (mp -> msgflags & READONLY
110                 || mp -> attrstats & (1 << (bits + i))) {
111     priv: ;
112             if (cp = m_seq (mp, mp -> msgattrs[i]))
113                 m_replace (attr, cp);
114             else
115                 (void) m_delete (attr);
116         }
117         else {
118             (void) m_delete (attr);
119             if ((cp = m_seq (mp, mp -> msgattrs[i])) == NULL)
120                 continue;
121             if (fp == NULL) {
122                 if ((fp = fopen (seq, "w")) == NULL
123                         && (unlink (seq) == NOTOK ||
124                             (fp = fopen (seq, "w")) == NULL)) {
125                     admonish (attr, "unable to write");
126                     goto priv;
127                 }
128 #ifndef BSD42
129                 hstat = signal (SIGHUP, SIG_IGN);
130                 istat = signal (SIGINT, SIG_IGN);
131                 qstat = signal (SIGQUIT, SIG_IGN);
132                 tstat = signal (SIGTERM, SIG_IGN);
133 #else   /* BSD42 */
134                 smask = sigblock (sigmask (SIGHUP) | sigmask (SIGINT)
135                                     | sigmask (SIGQUIT) | sigmask (SIGTERM));
136 #endif  /* BSD42 */
137             }
138             fprintf (fp, "%s: %s\n", mp -> msgattrs[i], cp);
139         }
140     }
141
142     if (fp) {
143         (void) fclose (fp);
144 #ifndef BSD42
145         (void) signal (SIGHUP, hstat);
146         (void) signal (SIGINT, istat);
147         (void) signal (SIGQUIT, qstat);
148         (void) signal (SIGTERM, tstat);
149 #else   /* BSD42 */
150         (void) sigsetmask (smask);
151 #endif  /* BSD42 */
152     }
153     else
154         if (!(mp -> msgflags & READONLY))
155             (void) unlink (seq);
156
157     mp -> msgflags = flags;
158 }
159 @
160
161
162 1.7
163 log
164 @kerberos
165 @
166 text
167 @d3 2
168 a4 2
169 static char ident[] = "@@(#)$Id: m_sync.c,v 1.6 1990/11/05 11:46:34 mh Exp jromine $";
170 #endif  lint
171 d11 1
172 a11 1
173 #endif  not sigmask
174 d33 1
175 a33 1
176 #else   BSD42
177 d35 1
178 a35 1
179 #endif  BSD42
180 d76 1
181 a76 1
182 #else   BSD42
183 d79 1
184 a79 1
185 #endif  BSD42
186 d92 1
187 a92 1
188 #else   BSD42
189 d94 1
190 a94 1
191 #endif  BSD42
192 @
193
194
195 1.6
196 log
197 @correctly detect inability to alter the public sequence
198 file.  the original test only worked if the unlink succeeded.
199 JLR
200 @
201 text
202 @d3 1
203 a3 1
204 static char ident[] = "@@(#)$Id: m_sync.c,v 1.5 90/04/05 15:31:00 sources Exp Locker: mh $";
205 d47 1
206 a47 1
207     if (mh_seq == NULL || *mh_seq == NULL)
208 @
209
210
211 1.5
212 log
213 @add ID
214 @
215 text
216 @d3 1
217 a3 1
218 static char ident[] = "@@(#)$Id:$";
219 d66 2
220 a67 2
221                         && unlink (seq) != NOTOK 
222                         && (fp = fopen (seq, "w")) == NULL) {
223 @
224
225
226 1.4
227 log
228 @add ID
229 @
230 text
231 @d3 1
232 a3 1
233 static char ident[] = "$Id:";
234 @
235
236
237 1.3
238 log
239 @TYPESIG
240 @
241 text
242 @d2 3
243 @
244
245
246 1.2
247 log
248 @increase message sequence buffer size by factor of 2.  I hope this
249 is worth it, since it'll make things bigger.
250 @
251 text
252 @d29 1
253 a29 1
254     int     (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
255 @
256
257
258 1.1
259 log
260 @Initial revision
261 @
262 text
263 @d26 1
264 a26 1
265             seq[BUFSIZ];
266 @