Mercurial > octave
annotate liboctave/system/oct-env.h @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
2926 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 1996-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27832
diff
changeset
|
7 |
2926 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 (at your option) any later version. |
2926 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
19 GNU General Public License for more details. |
2926 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
2926 | 24 |
25 */ | |
26 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 #if ! defined (octave_oct_env_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
28 #define octave_oct_env_h 1 |
2926 | 29 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
30 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
31 |
2926 | 32 #include <string> |
33 | |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
34 namespace octave |
2926 | 35 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
36 namespace sys |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
37 { |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
38 class |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
39 OCTAVE_API |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
40 env |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
41 { |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
42 protected: |
2926 | 43 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
44 env (void); |
2926 | 45 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
46 public: |
2926 | 47 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
48 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
49 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
50 env (const env&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
51 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
52 env& operator = (const env&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
53 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
54 static std::string polite_directory_format (const std::string& name); |
6838 | 55 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 static bool absolute_pathname (const std::string& s); |
2926 | 57 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
58 static bool rooted_relative_pathname (const std::string& s); |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
59 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
60 static std::string base_pathname (const std::string& s); |
2926 | 61 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
62 static std::string |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
63 make_absolute (const std::string& s, |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
64 const std::string& dot_path = get_current_directory ()); |
2926 | 65 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
66 static std::string get_current_directory (void); |
19458
d8fd3842a507
Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents:
17822
diff
changeset
|
67 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
68 static std::string get_home_directory (void); |
2926 | 69 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
70 static std::string get_temp_directory (void); |
2926 | 71 |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
72 static std::string get_user_config_directory (void); |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
73 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
74 static std::string get_program_name (void); |
2926 | 75 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
76 static std::string get_program_invocation_name (void); |
2926 | 77 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
78 static std::string get_user_name (void); |
2926 | 79 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
80 static std::string get_host_name (void); |
2926 | 81 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
82 static std::string getenv (const std::string& name); |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
83 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
84 static void putenv (const std::string& name, const std::string& value); |
5489 | 85 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
86 static bool have_x11_display (void); |
2926 | 87 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
88 static bool chdir (const std::string& newdir); |
2926 | 89 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
90 static void set_program_name (const std::string& s); |
2926 | 91 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
92 private: |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
93 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
94 static bool instance_ok (void); |
2926 | 95 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
96 std::string do_polite_directory_format (const std::string& name) const; |
2926 | 97 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
98 bool do_absolute_pathname (const std::string& s) const; |
2926 | 99 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
100 bool do_rooted_relative_pathname (const std::string& s) const; |
6838 | 101 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
102 std::string do_base_pathname (const std::string& s) const; |
2926 | 103 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
104 std::string do_make_absolute (const std::string& s, |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
105 const std::string& dot_path) const; |
2926 | 106 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
107 std::string do_getcwd (void) const; |
2926 | 108 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
109 std::string do_get_home_directory (void) const; |
2926 | 110 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
111 std::string do_get_temp_directory (void) const; |
19458
d8fd3842a507
Use gnulib gen_tempname to create temporary names (Bug #43872).
John Donoghue <john.donoghue@ieee.org>
parents:
17822
diff
changeset
|
112 |
27832
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
113 std::string do_get_user_config_directory (void) const; |
8fd7d1d2a4ca
Read startup files from XDG_CONFIG_HOME or LOCALAPPDATA (bug #36477).
Mike Miller <mtmiller@octave.org>
parents:
26376
diff
changeset
|
114 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
115 std::string do_get_user_name (void) const; |
2926 | 116 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
117 std::string do_get_host_name (void) const; |
2926 | 118 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
119 std::string do_getenv (const std::string& name) const; |
2926 | 120 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
121 void do_putenv (const std::string& name, const std::string& value) const; |
2926 | 122 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
123 bool do_chdir (const std::string& newdir); |
2926 | 124 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
125 void do_set_program_name (const std::string& s) const; |
2926 | 126 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
127 void pathname_backup (std::string& path, int n) const; |
2926 | 128 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
129 void error (int) const; |
2926 | 130 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
131 void error (const std::string&) const; |
2926 | 132 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
133 // The real thing. |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
134 static env *instance; |
2926 | 135 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23615
diff
changeset
|
136 static void cleanup_instance (void) { delete instance; instance = nullptr; } |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
137 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
138 // TRUE means follow symbolic links that point to directories just |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
139 // as if they are real directories. |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
140 bool follow_symbolic_links; |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
141 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
142 // TRUE means that pwd always give verbatim directory, regardless |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
143 // of symbolic link following. |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
144 bool verbatim_pwd; |
2926 | 145 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
146 // Where are we? |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
147 mutable std::string current_directory; |
2926 | 148 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
149 // Etc. |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
150 mutable std::string prog_name; |
2926 | 151 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
152 mutable std::string prog_invocation_name; |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
153 |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
154 mutable std::string user_name; |
2926 | 155 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
156 mutable std::string host_name; |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
157 }; |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
158 } |
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
159 } |
2926 | 160 |
161 #endif |