1 //===-- include/flang/Runtime/command.h -------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef FORTRAN_RUNTIME_COMMAND_H_
10 #define FORTRAN_RUNTIME_COMMAND_H_
11 
12 #include "flang/Runtime/entry-names.h"
13 
14 #include <cstdint>
15 
16 namespace Fortran::runtime {
17 class Descriptor;
18 
19 extern "C" {
20 // 16.9.51 COMMAND_ARGUMENT_COUNT
21 //
22 // Lowering may need to cast the result to match the precision of the default
23 // integer kind.
24 std::int32_t RTNAME(ArgumentCount)();
25 
26 // 16.9.82 GET_COMMAND
27 // Try to get the value of the whole command. All of the parameters are
28 // optional.
29 // Return a STATUS as described in the standard.
30 std::int32_t RTNAME(GetCommand)(const Descriptor *command = nullptr,
31     const Descriptor *length = nullptr, const Descriptor *errmsg = nullptr,
32     const char *sourceFile = nullptr, int line = 0);
33 
34 // 16.9.83 GET_COMMAND_ARGUMENT
35 // We're breaking up the interface into several different functions, since most
36 // of the parameters are optional.
37 
38 // Try to get the value of the n'th argument.
39 // Returns a STATUS as described in the standard.
40 std::int32_t RTNAME(ArgumentValue)(
41     std::int32_t n, const Descriptor *value, const Descriptor *errmsg);
42 
43 // Try to get the significant length of the n'th argument.
44 // Returns 0 if it doesn't manage.
45 std::int64_t RTNAME(ArgumentLength)(std::int32_t n);
46 
47 // 16.9.84 GET_ENVIRONMENT_VARIABLE
48 // We're breaking up the interface into several different functions, since most
49 // of the parameters are optional.
50 
51 // Try to get the value of the environment variable specified by NAME.
52 // Returns a STATUS as described in the standard.
53 std::int32_t RTNAME(EnvVariableValue)(const Descriptor &name,
54     const Descriptor *value = nullptr, bool trim_name = true,
55     const Descriptor *errmsg = nullptr, const char *sourceFile = nullptr,
56     int line = 0);
57 
58 // Try to get the significant length of the environment variable specified by
59 // NAME. Returns 0 if it doesn't manage.
60 std::int64_t RTNAME(EnvVariableLength)(const Descriptor &name,
61     bool trim_name = true, const char *sourceFile = nullptr, int line = 0);
62 }
63 } // namespace Fortran::runtime
64 
65 #endif // FORTRAN_RUNTIME_COMMAND_H_
66