]>
Commit | Line | Data |
---|---|---|
5b1374e9 TS |
1 | /* Implementation of the SYSTEM intrinsic. |
2 | Copyright (C) 2004 Free Software Foundation, Inc. | |
3 | Contributed by Tobias Schlüter. | |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
11 | ||
12 | In addition to the permissions in the GNU General Public License, the | |
13 | Free Software Foundation gives you unlimited permission to link the | |
14 | compiled version of this file into combinations with other programs, | |
15 | and to distribute those combinations without any restriction coming | |
16 | from the use of this file. (The General Public License restrictions | |
17 | do apply in other respects; for example, they cover modification of | |
18 | the file, and distribution when not linked into a combined | |
19 | executable.) | |
20 | ||
21 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
22 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
23 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
24 | for more details. | |
25 | ||
26 | You should have received a copy of the GNU General Public License | |
27 | along with GCC; see the file COPYING. If not, write to the Free | |
28 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
29 | 02111-1307, USA. */ | |
30 | ||
31 | #include "config.h" | |
32 | #include "libgfortran.h" | |
33 | ||
34 | #ifdef HAVE_STRING_H | |
35 | #include <string.h> | |
36 | #endif | |
37 | #ifdef HAVE_STDLIB_H | |
38 | #include <stdlib.h> | |
39 | #endif | |
40 | ||
41 | void | |
42 | prefix(system_sub) (const char * fcmd, GFC_INTEGER_4 * status, | |
43 | gfc_charlen_type cmd_len) | |
44 | { | |
45 | char cmd[cmd_len + 1]; | |
46 | int stat; | |
47 | ||
48 | memcpy (cmd, fcmd, cmd_len); | |
49 | cmd[cmd_len] = '\0'; | |
50 | ||
51 | stat = system (cmd); | |
52 | if (status) | |
53 | *status = stat; | |
54 | } | |
55 | ||
56 | GFC_INTEGER_4 | |
57 | prefix(system) (char * fcmd, gfc_charlen_type cmd_len) | |
58 | { | |
59 | GFC_INTEGER_4 stat; | |
60 | ||
61 | prefix(system_sub) (fcmd, &stat, cmd_len); | |
62 | return stat; | |
63 | } |