]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/intrinsics/system.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / intrinsics / system.c
CommitLineData
5b1374e9 1/* Implementation of the SYSTEM intrinsic.
a945c346 2 Copyright (C) 2004-2024 Free Software Foundation, Inc.
5b1374e9
TS
3 Contributed by Tobias Schlüter.
4
74544378 5This file is part of the GNU Fortran runtime library (libgfortran).
5b1374e9 6
57dea9f6 7Libgfortran is free software; you can redistribute it and/or modify it under
5b1374e9 8the terms of the GNU General Public License as published by the Free
748086b7 9Software Foundation; either version 3, or (at your option) any later
5b1374e9
TS
10version.
11
57dea9f6
TM
12Libgfortran is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5b1374e9
TS
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
5b1374e9 25
36ae8a61 26#include "libgfortran.h"
5b1374e9 27
7d7b8bfe
RH
28extern void system_sub (const char *fcmd, GFC_INTEGER_4 * status,
29 gfc_charlen_type cmd_len);
30iexport_proto(system_sub);
31
5b1374e9 32void
7d7b8bfe 33system_sub (const char *fcmd, GFC_INTEGER_4 *status, gfc_charlen_type cmd_len)
5b1374e9 34{
581d2326 35 char *cmd = fc_strdup (fcmd, cmd_len);
5b1374e9
TS
36 int stat;
37
25a5e756
FXC
38 /* Flush all I/O units before executing the command. */
39 flush_all_units();
40
5b1374e9 41 stat = system (cmd);
581d2326 42 free (cmd);
5b1374e9
TS
43 if (status)
44 *status = stat;
45}
7d7b8bfe
RH
46iexport(system_sub);
47
48extern GFC_INTEGER_4 PREFIX(system) (const char *, gfc_charlen_type);
49export_proto_np(PREFIX(system));
5b1374e9
TS
50
51GFC_INTEGER_4
7d7b8bfe 52PREFIX(system) (const char *fcmd, gfc_charlen_type cmd_len)
5b1374e9
TS
53{
54 GFC_INTEGER_4 stat;
7d7b8bfe 55 system_sub (fcmd, &stat, cmd_len);
5b1374e9
TS
56 return stat;
57}