0
|
1 /*
|
|
2 * $Id: mkdir.c,v 1.3 2005/04/10 15:26:37 aonoto Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2002
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
16 *
|
|
17 * This library is free software; you can redistribute it and/or
|
|
18 * modify it under the terms of the GNU Lesser General Public
|
|
19 * License as published by the Free Software Foundation; either
|
|
20 * version 2 of the License, or (at your option) any later version.
|
|
21 *
|
|
22 * This library is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 * Lesser General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU Lesser General Public
|
|
28 * License along with this library; if not, write to the
|
|
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
30 * Boston, MA 02111-1307, USA.
|
|
31 */
|
|
32
|
|
33 #ifdef HAVE_CONFIG_H
|
|
34 # include <config.h>
|
|
35 #endif
|
|
36
|
|
37 #if !defined(HAVE_MKDIR)
|
|
38
|
|
39 #if STDC_HEADERS
|
|
40 # include <stdlib.h>
|
|
41 #endif
|
|
42
|
|
43 #include <sys/types.h>
|
|
44 #include <sys/wait.h>
|
|
45
|
|
46 #if !defined(WIFEXITED)
|
|
47 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
|
|
48 #endif /* !WIFEXITED */
|
|
49 #if !defined(WIFSIGNALED)
|
|
50 #define WTERMSIG(status) ((status) & 0x7f)
|
|
51 #endif /* !WIFSIGNALED */
|
|
52 #if !defined(WIFSTOPPED)
|
|
53 #define WSTOPSIG(status) WEXITSTATUS(status)
|
|
54 #endif /* !WIFSTOPPED */
|
|
55 #if !defined(WIFEXITED)
|
|
56 #define WIFEXITED(status) (__WTERMSIG(status) == 0)
|
|
57 #endif /* !WIFEXITED */
|
|
58
|
|
59 int
|
|
60 mkdir (path, mode)
|
|
61 const char *path;
|
|
62 mode_t mode;
|
|
63 {
|
|
64 const char *args[3];
|
|
65 int status;
|
|
66
|
|
67 if (!path)
|
|
68 return -1;
|
|
69
|
|
70 args[0] = "/bin/mkdir";
|
|
71 args[1] = path;
|
|
72 args[2] = NULL;
|
|
73
|
|
74 if (!fork ())
|
|
75 execv (args[0], args);
|
|
76 else
|
|
77 wait (&status);
|
|
78
|
|
79 return !(WIFEXITED (status));
|
|
80 }
|
|
81 #endif
|