Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / RCS / makedir.c,v
1 head    1.13;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.13
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.12;
12
13 1.12
14 date    92.11.06.03.27.09;      author jromine; state Exp;
15 branches;
16 next    1.11;
17
18 1.11
19 date    92.11.02.18.57.39;      author jromine; state Exp;
20 branches;
21 next    1.10;
22
23 1.10
24 date    92.02.11.00.37.20;      author jromine; state Exp;
25 branches;
26 next    1.9;
27
28 1.9
29 date    92.02.07.19.19.16;      author jromine; state Exp;
30 branches;
31 next    1.7;
32
33 1.7
34 date    92.01.23.23.12.43;      author jromine; state Exp;
35 branches;
36 next    1.6;
37
38 1.6
39 date    90.04.05.15.31.10;      author sources; state Exp;
40 branches;
41 next    1.5;
42
43 1.5
44 date    90.04.05.14.45.19;      author sources; state Exp;
45 branches;
46 next    1.4;
47
48 1.4
49 date    90.03.12.10.13.12;      author sources; state Exp;
50 branches;
51 next    1.3;
52
53 1.3
54 date    90.02.05.14.31.31;      author sources; state Exp;
55 branches;
56 next    1.2;
57
58 1.2
59 date    90.02.05.13.33.39;      author sources; state Exp;
60 branches;
61 next    1.1;
62
63 1.1
64 date    90.02.05.13.16.47;      author sources; state Exp;
65 branches;
66 next    ;
67
68
69 desc
70 @@
71
72
73 1.13
74 log
75 @endif sugar
76 @
77 text
78 @/* makedir.c - make a directory */
79 #ifndef lint
80 static char ident[] = "@@(#)$Id: makedir.c,v 1.12 1992/11/06 03:27:09 jromine Exp jromine $";
81 #endif  /* lint */
82
83 #if defined (BSD42) || defined (hpux)
84 /* Modified to try recursive create.  Really, this should be broken
85  * out into a subr so that SYS5 systems can do this too.  I don't 
86  * have a SYS5 machine around to test anymore, so someone else will
87  * have to send me the code.
88  */
89 #endif
90
91 #include "../h/mh.h"
92 #include <stdio.h>
93
94 #if defined (BSD42) || defined (hpux) || defined(SVR4) || \
95         defined(ncr) || defined (_AIX) || defined(AUX)
96 #include <errno.h>
97 #include <sys/param.h>
98 #include <sys/file.h>
99 #endif /* BSD42 ... */
100 #ifdef  SYS5DIR
101 #include <sys/types.h>
102 #include <sys/stat.h>
103 #endif  /* SYS5DIR */
104 #if defined(SVR4) || defined(ncr)
105 #include <unistd.h>
106 #endif
107
108 extern int  errno;
109         
110 makedir (dir)
111 register char *dir;
112 {
113     int     pid;
114     register char  *cp;
115 #if defined (BSD42)  || defined (hpux) || defined (SYS5DIR)
116     register char  *c;
117     char path[MAXPATHLEN];
118 #endif  /* BSD42 */
119
120     m_update ();
121     (void) fflush (stdout);
122
123 #if     defined (BSD42) ||  defined (hpux) || defined (SYS5DIR)
124     if (getuid () == geteuid ()) {
125             c = strcpy(path, dir);     
126
127             while ((c = index((c + 1), '/')) != NULL) { 
128                     *c = (char)0;
129                     if (access(path, X_OK)) {
130                             if (errno != ENOENT){
131                                     advise (dir, "unable to create directory");
132                                     return 0;
133                             }                       
134                             if (mkdir(path, 0775)) {
135                                     advise (dir, "unable to create directory");
136                                     return 0;
137                             }
138                     }
139                     *c = '/';
140             }
141  
142             if (mkdir (dir, 0755) == NOTOK) {
143                     advise (dir, "unable to create directory");
144                     return 0;
145             }
146     }
147     else
148 #endif  /* BSD42 or hpux or SYS5DIR */
149     switch (pid = vfork ()) {
150         case NOTOK: 
151             advise ("fork", "unable to");
152             return 0;
153
154         case OK: 
155             (void) setgid (getgid ());
156             (void) setuid (getuid ());
157
158             execl ("/bin/mkdir", "mkdir", dir, NULLCP);
159             execl ("/usr/bin/mkdir", "mkdir", dir, NULLCP);
160             fprintf (stderr, "unable to exec ");
161             perror ("mkdir");
162             _exit (-1);
163
164         default: 
165             if (pidXwait (pid, "mkdir"))
166                 return 0;
167             break;
168     }
169
170     if ((cp = m_find ("folder-protect")) == NULL)
171         cp = foldprot;
172     (void) chmod (dir, atooi (cp));
173     return 1;
174 }
175
176 @
177
178
179 1.12
180 log
181 @AUX fixup
182 @
183 text
184 @d3 2
185 a4 2
186 static char ident[] = "@@(#)$Id: makedir.c,v 1.11 1992/11/02 18:57:39 jromine Exp jromine $";
187 #endif  lint
188 d41 1
189 a41 1
190 #endif BSD42
191 d71 1
192 a71 1
193 #endif  BSD42 or hpux or SYS5DIR
194 @
195
196
197 1.11
198 log
199 @_AIX
200 @
201 text
202 @d3 1
203 a3 1
204 static char ident[] = "@@(#)$Id: makedir.c,v 1.10 1992/02/11 00:37:20 jromine Exp jromine $";
205 d17 2
206 a18 1
207 #if defined (BSD42) || defined (hpux) || defined(SVR4) || defined(ncr) || defined (_AIX)
208 d22 1
209 a22 1
210 #endif BSD42
211 d26 1
212 a26 1
213 #endif  SYS5DIR
214 @
215
216
217 1.10
218 log
219 @ncr changes
220 @
221 text
222 @d3 1
223 a3 1
224 static char ident[] = "@@(#)$Id: makedir.c,v 1.9 1992/02/07 19:19:16 jromine Exp jromine $";
225 d17 1
226 a17 1
227 #if defined (BSD42)  || defined (hpux) || defined(SVR4) || defined(ncr)
228 @
229
230
231 1.9
232 log
233 @SVR4
234 @
235 text
236 @d3 1
237 a3 1
238 static char ident[] = "@@(#)$Id: makedir.c,v 1.8 1992/02/07 19:19:00 jromine Exp jromine $";
239 d17 1
240 a17 1
241 #if defined (BSD42)  || defined (hpux) || defined(SVR4)
242 d26 1
243 a26 1
244 #ifdef SVR4
245 @
246
247
248 1.7
249 log
250 @ifdef bug
251 @
252 text
253 @d3 1
254 a3 1
255 static char ident[] = "@@(#)$Id: makedir.c,v 1.6 1990/04/05 15:31:10 sources Exp jromine $";
256 d17 1
257 a17 1
258 #if defined (BSD42)  || defined (hpux)
259 d21 1
260 a21 1
261 #endif BDS42
262 d26 3
263 @
264
265
266 1.6
267 log
268 @add ID
269 @
270 text
271 @d3 1
272 a3 1
273 static char ident[] = "@@(#)$Id:$";
274 d34 1
275 a34 1
276 #if defined (BSD42)  || defined (hpux)
277 @
278
279
280 1.5
281 log
282 @add ID
283 @
284 text
285 @d3 1
286 a3 1
287 static char ident[] = "$Id:";
288 @
289
290
291 1.4
292 log
293 @replace strchr with index
294 @
295 text
296 @d2 3
297 @
298
299
300 1.3
301 log
302 @SYS5DIR fixes
303 @
304 text
305 @d23 2
306 d33 1
307 a33 1
308     register char path[MAXPATHLEN];
309 d43 1
310 a43 1
311             while ((c = strchr((c + 1), '/')) != NULL) {        
312 @
313
314
315 1.2
316 log
317 @allow recursive create on BSD42
318 @
319 text
320 @d19 4
321 d37 1
322 a37 1
323 #ifdef  BSD42 ||  defined (hpux)
324 d62 1
325 a62 1
326 #endif  BSD42
327 @
328
329
330 1.1
331 log
332 @Initial revision
333 @
334 text
335 @d3 8
336 d14 6
337 a19 1
338
339 d25 4
340 d33 1
341 a33 1
342 #ifdef  BSD42
343 d35 21
344 a55 4
345         if (mkdir (dir, 0755) == NOTOK) {
346             advise (dir, "unable to create directory");
347             return 0;
348         }
349 @