1 mike 1.13 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 mike 1.14 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9 mike 1.13 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
|
11 mike 1.14 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
13 mike 1.13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
15 mike 1.14 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
18 mike 1.13 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
|
25 mike 1.15 // Modified By:
26 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
|
27 mike 1.13 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #ifndef Pegasus_System_h
31 #define Pegasus_System_h
32
33 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/String.h>
35
|
36 kumpf 1.17 //
37 // Protocal Type
38 //
39 #define TCP "tcp"
40
|
41 mike 1.13 PEGASUS_NAMESPACE_BEGIN
42
|
43 kumpf 1.23
|
44 mike 1.13 /** This is an opaque type which is used to represent dynamic library
45 handles returned by the System::loadDynamicLibrary() method and
46 accepted by the System::loadDynamicProcedure() method.
47 */
48 typedef struct DynamicLibraryHandle_* DynamicLibraryHandle;
49
50 /** This is an opaque type which is returned by System::loadDynamicSymbol().
51 Values of this type may be casted to the appropriate target type.
52 */
|
53 sage 1.20 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
54 typedef struct DynamicSymbolHandle_* DynamicSymbolHandle;
55 #else
56 extern "C" {typedef int (* DynamicSymbolHandle)(void);}
57 #endif
58
|
59 mike 1.14
|
60 mike 1.13 /** The System class defines wrappers for operating system related calls.
61 These are only placed here if they are extremely light. These are
62 usually just direct wrappers which map more or less one to one to the
63 underlying function.
64 */
65 class PEGASUS_COMMON_LINKAGE System
66 {
67 public:
68 /** getCurrentTime - Gets the current time as seconds and milliseconds
69 into the provided variables using system functions.
70 @param seconds Return for the seconds component of the time.
71 @param milliseconds Return for the milliseconds component of the time.
72 @return The value is returned in the parameters.
73 The time returned is as defined in number of seconds and milliseconds
74 since 00:00 Coordinated Universal Time (UTC), January 1, 1970,
|
75 mike 1.14
|
76 mike 1.13 */
77 static void getCurrentTime(Uint32& seconds, Uint32& milliseconds);
78
79 /** getCurrentASCIITime Gets time/date in a fixed format. The format is
80 YY MM DD-HH:MM:SS
81 @return Returns String with the ASCII time date.
82 */
83 static String getCurrentASCIITime();
84
85 static void sleep(Uint32 seconds);
86
87 static Boolean exists(const char* path);
88
89 static Boolean canRead(const char* path);
90
91 static Boolean canWrite(const char* path);
92
93 static Boolean getCurrentDirectory(char* path, Uint32 size);
94
95 static Boolean isDirectory(const char* path);
96
97 mike 1.13 static Boolean changeDirectory(const char* path);
98
99 static Boolean makeDirectory(const char* path);
100
101 static Boolean getFileSize(const char* path, Uint32& size);
102
103 static Boolean removeDirectory(const char* path);
104
105 static Boolean removeFile(const char* path);
106
107 static Boolean renameFile(const char* oldPath, const char* newPath);
108
|
109 mike 1.21 static Boolean copyFile(const char* fromPath, const char* toPath);
110
|
111 mike 1.13 static DynamicLibraryHandle loadDynamicLibrary(const char* fileName);
112
|
113 mike 1.15 static void unloadDynamicLibrary(DynamicLibraryHandle libraryHandle);
|
114 mike 1.14
|
115 mike 1.13 static String dynamicLoadError(void);
116
117 static DynamicSymbolHandle loadDynamicSymbol(
118 DynamicLibraryHandle libraryHandle,
119 const char* symbolName);
120
121 static String getHostName();
|
122 kumpf 1.22 static String getFullyQualifiedHostName ();
123 static String getSystemCreationClassName ();
|
124 kumpf 1.17
125 static Uint32 lookupPort(
126 const char * serviceName,
127 Uint32 defaultPort);
|
128 mike 1.14
129 static String getCurrentLoginName();
130
131 /**
132 This function is used to input a password with echo disabled.
133 The function reads up to a newline and returns a password of at most
134 8 characters.
135
136 @param prompt String containing the message prompt to be displayed
137 @return password obtained from the user
138 */
139 static String getPassword(const char* prompt);
140
141 /**
142 This function is used to encrypt the user's password.
143 The encryption is compatible with Apache's password file (generated using
144 the htpasswd command )
145
146 @param password Password to be encrypted.
147 @param salt Two character string chosen from the set [a-zA-Z0-9./].
148
149 mike 1.14 @return Encrypted password.
150 */
151 static String encryptPassword(const char* password, const char* salt);
152
153 /**
154 This function is used to verify whether specified user is a user
155 on the local system.
156
157 @param userName User name to be verified.
158
159 @return true if the username is valid, else false
160 */
161 static Boolean isSystemUser(char* userName);
162
163 /**
|
164 kumpf 1.18 When the user name is not passed as an argument, this function
165 checks whether the user running the command is a privileged user.
166 If a user name is given this function checks whether
167 the given user is a privileged user.
|
168 mike 1.14
|
169 kumpf 1.18 @param userName User name to be checked.
170
171 @return true if the user is a privileged user, else false
|
172 mike 1.14 */
|
173 kumpf 1.18 static Boolean isPrivilegedUser(const String userName = String::EMPTY);
|
174 mike 1.14
|
175 kumpf 1.16 /**
|
176 kumpf 1.19 This function returns the privileged user name on the system.
177
178 @return the privileged user name
179 */
180 static String getPrivilegedUserName();
181
182 /**
|
183 kumpf 1.16 This function is used to get the process ID of the calling process.
184
185 @return Process ID
186 */
187 static Uint32 getPID();
188
|
189 mike 1.21 static Boolean truncateFile(const char* path, size_t newSize);
|
190 kumpf 1.23
191 #if defined(PEGASUS_OS_HPUX)
192 static Boolean bindVerbose;
193 #endif
|
194 mike 1.13 };
195
196 PEGASUS_NAMESPACE_END
197
198 #endif /* Pegasus_System_h */
|