1 karl 1.35 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.13 //
|
3 karl 1.35 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.13 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 mike 1.14 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.13 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 kumpf 1.25 //
|
15 mike 1.14 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 mike 1.14 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.13 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
|
28 mike 1.15 // Modified By:
29 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
|
30 mike 1.13 //
|
31 david 1.32 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
32 //
|
33 mike 1.13 //%/////////////////////////////////////////////////////////////////////////////
34
35 #ifndef Pegasus_System_h
36 #define Pegasus_System_h
37
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/String.h>
|
40 kumpf 1.26 #include <Pegasus/Common/Linkage.h>
|
41 david 1.32 #include <Pegasus/Common/Logger.h>
|
42 kumpf 1.36 #include <sys/stat.h>
|
43 mike 1.13
|
44 kumpf 1.17 //
45 // Protocal Type
46 //
47 #define TCP "tcp"
48
|
49 mike 1.13 PEGASUS_NAMESPACE_BEGIN
50
|
51 kumpf 1.23
|
52 mike 1.13 /** This is an opaque type which is used to represent dynamic library
53 handles returned by the System::loadDynamicLibrary() method and
54 accepted by the System::loadDynamicProcedure() method.
55 */
56 typedef struct DynamicLibraryHandle_* DynamicLibraryHandle;
57
58 /** This is an opaque type which is returned by System::loadDynamicSymbol().
59 Values of this type may be casted to the appropriate target type.
60 */
|
61 chuck 1.27 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
|
62 sage 1.20 typedef struct DynamicSymbolHandle_* DynamicSymbolHandle;
63 #else
64 extern "C" {typedef int (* DynamicSymbolHandle)(void);}
65 #endif
66
|
67 mike 1.14
|
68 david 1.32
|
69 mike 1.13 /** The System class defines wrappers for operating system related calls.
70 These are only placed here if they are extremely light. These are
71 usually just direct wrappers which map more or less one to one to the
72 underlying function.
73 */
74 class PEGASUS_COMMON_LINKAGE System
75 {
76 public:
77 /** getCurrentTime - Gets the current time as seconds and milliseconds
78 into the provided variables using system functions.
79 @param seconds Return for the seconds component of the time.
80 @param milliseconds Return for the milliseconds component of the time.
81 @return The value is returned in the parameters.
82 The time returned is as defined in number of seconds and milliseconds
83 since 00:00 Coordinated Universal Time (UTC), January 1, 1970,
|
84 mike 1.14
|
85 mike 1.13 */
86 static void getCurrentTime(Uint32& seconds, Uint32& milliseconds);
87
88 /** getCurrentASCIITime Gets time/date in a fixed format. The format is
89 YY MM DD-HH:MM:SS
90 @return Returns String with the ASCII time date.
91 */
92 static String getCurrentASCIITime();
93
94 static void sleep(Uint32 seconds);
95
96 static Boolean exists(const char* path);
97
98 static Boolean canRead(const char* path);
99
100 static Boolean canWrite(const char* path);
101
102 static Boolean getCurrentDirectory(char* path, Uint32 size);
103
104 static Boolean isDirectory(const char* path);
105
106 mike 1.13 static Boolean changeDirectory(const char* path);
107
108 static Boolean makeDirectory(const char* path);
109
110 static Boolean getFileSize(const char* path, Uint32& size);
111
112 static Boolean removeDirectory(const char* path);
113
114 static Boolean removeFile(const char* path);
115
116 static Boolean renameFile(const char* oldPath, const char* newPath);
117
|
118 mike 1.21 static Boolean copyFile(const char* fromPath, const char* toPath);
119
|
120 konrad.r 1.33 /** Unix issue:<br><br><b>RTLD_<bah></b> issue. Currently Pegasus uses RTLD_NOW during
121 loading of the library if supported by OS. Previous to 2.2, Pegasus used RTLD_GLOBAL on Linux
122 - that behaviour is now deprecated.
123 */
|
124 mike 1.13 static DynamicLibraryHandle loadDynamicLibrary(const char* fileName);
125
|
126 mike 1.15 static void unloadDynamicLibrary(DynamicLibraryHandle libraryHandle);
|
127 mike 1.14
|
128 mike 1.13 static String dynamicLoadError(void);
129
130 static DynamicSymbolHandle loadDynamicSymbol(
131 DynamicLibraryHandle libraryHandle,
132 const char* symbolName);
133
134 static String getHostName();
|
135 kumpf 1.22 static String getFullyQualifiedHostName ();
136 static String getSystemCreationClassName ();
|
137 kumpf 1.17
138 static Uint32 lookupPort(
139 const char * serviceName,
140 Uint32 defaultPort);
|
141 mike 1.14
|
142 kumpf 1.24 static String getEffectiveUserName();
|
143 mike 1.14
144 /**
145 This function is used to input a password with echo disabled.
146 The function reads up to a newline and returns a password of at most
147 8 characters.
148
149 @param prompt String containing the message prompt to be displayed
150 @return password obtained from the user
151 */
152 static String getPassword(const char* prompt);
153
154 /**
155 This function is used to encrypt the user's password.
156 The encryption is compatible with Apache's password file (generated using
157 the htpasswd command )
158
159 @param password Password to be encrypted.
160 @param salt Two character string chosen from the set [a-zA-Z0-9./].
161
162 @return Encrypted password.
163 */
164 mike 1.14 static String encryptPassword(const char* password, const char* salt);
165
166 /**
167 This function is used to verify whether specified user is a user
168 on the local system.
169
170 @param userName User name to be verified.
171
172 @return true if the username is valid, else false
173 */
|
174 kumpf 1.28 static Boolean isSystemUser(const char* userName);
|
175 mike 1.14
176 /**
|
177 kumpf 1.24 Checks whether the given user is a privileged user.
|
178 mike 1.14
|
179 kumpf 1.18 @param userName User name to be checked.
180 @return true if the user is a privileged user, else false
|
181 mike 1.14 */
|
182 kumpf 1.24 static Boolean isPrivilegedUser(const String userName);
|
183 mike 1.14
|
184 kumpf 1.16 /**
|
185 kumpf 1.19 This function returns the privileged user name on the system.
186
187 @return the privileged user name
188 */
189 static String getPrivilegedUserName();
190
191 /**
|
192 kumpf 1.16 This function is used to get the process ID of the calling process.
193
194 @return Process ID
195 */
196 static Uint32 getPID();
197
|
198 mike 1.21 static Boolean truncateFile(const char* path, size_t newSize);
|
199 kumpf 1.23
|
200 kumpf 1.29 /** Compare two strings but ignore any case differences.
201 This method is provided only because some platforms lack a strcasecmp
202 function in the standard library.
203 */
204 static Sint32 strcasecmp(const char* s1, const char* s2);
|
205 tony 1.30
206 /** Return just the file or directory name from the path into basename.
207 This method returns a file or directory name at the end of a path.
208 The path can be relative or absolute. If the path is the root,
209 then empty string is returned.
210 */
|
211 kumpf 1.31 static char *extract_file_name(const char *fullpath, char *basename);
|
212 tony 1.30
213 /** Return just the pathname into dirname. The fullpath can be relative
214 or absolute. This method returns a path minus the file or
215 directory name at the end of a supplied path (fullpath).
216 If the fullpath is the root, then fullpath is returned.
217 The resulting path will contain a trailing slash unless fullpath is
218 a file or directory name, in which case, just the file or directory
219 name is returned.
220 */
|
221 kumpf 1.31 static char *extract_file_path(const char *fullpath, char *dirname);
|
222 tony 1.30
223 // Is absolute path?
|
224 kumpf 1.31 static Boolean is_absolute_path(const char *path);
|
225 kumpf 1.36
226 /** Changes file permissions on the given file.
227 @param path path of the file.
228 @param mode the bit-wise inclusive OR of the values for the desired
229 permissions.
230 @return true on success, false on error and errno is set appropriately.
231 */
232 static Boolean changeFilePermissions(const char* path, mode_t mode);
|
233 kumpf 1.29
|
234 kumpf 1.23 #if defined(PEGASUS_OS_HPUX)
235 static Boolean bindVerbose;
236 #endif
|
237 david 1.32
238 /** This function is an abstraction for the openlog interface used in the Logger
239 class. Each platform intending to use system logs should support this interface
240 */
241 static void openlog(const String);
242
243 /** This function is an abstraction for the syslog interface used in the Logger
244 class. Each platform intending to use system logs should support this interface
245 */
246 static void syslog(Uint32, const char *);
247
248 /** This function is an abstraction for the closelog interface used in the Logger
249 class. Each platform intending to use system logs should support this interface
250 */
251 static void closelog();
252
253 // System ID constants for Logger::put and Logger::trace
254 static const String CIMSERVER;
|
255 tony 1.34
256 // System ID constants for Logger::put and Logger::trace
257 static const String CIMLISTENER;
|
258 mike 1.13 };
259
260 PEGASUS_NAMESPACE_END
261
262 #endif /* Pegasus_System_h */
|