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 /** This is an opaque type which is used to represent dynamic library
44 handles returned by the System::loadDynamicLibrary() method and
45 accepted by the System::loadDynamicProcedure() method.
46 */
47 typedef struct DynamicLibraryHandle_* DynamicLibraryHandle;
48
49 /** This is an opaque type which is returned by System::loadDynamicSymbol().
50 Values of this type may be casted to the appropriate target type.
51 */
52 typedef struct DynamicSymbolHandle_* DynamicSymbolHandle;
|
53 mike 1.14
|
54 mike 1.13 /** The System class defines wrappers for operating system related calls.
55 These are only placed here if they are extremely light. These are
56 usually just direct wrappers which map more or less one to one to the
57 underlying function.
58 */
59 class PEGASUS_COMMON_LINKAGE System
60 {
61 public:
62 /** getCurrentTime - Gets the current time as seconds and milliseconds
63 into the provided variables using system functions.
64 @param seconds Return for the seconds component of the time.
65 @param milliseconds Return for the milliseconds component of the time.
66 @return The value is returned in the parameters.
67 The time returned is as defined in number of seconds and milliseconds
68 since 00:00 Coordinated Universal Time (UTC), January 1, 1970,
|
69 mike 1.14
|
70 mike 1.13 */
71 static void getCurrentTime(Uint32& seconds, Uint32& milliseconds);
72
73 /** getCurrentASCIITime Gets time/date in a fixed format. The format is
74 YY MM DD-HH:MM:SS
75 @return Returns String with the ASCII time date.
76 */
77 static String getCurrentASCIITime();
78
79 static void sleep(Uint32 seconds);
80
81 static Boolean exists(const char* path);
82
83 static Boolean canRead(const char* path);
84
85 static Boolean canWrite(const char* path);
86
87 static Boolean getCurrentDirectory(char* path, Uint32 size);
88
89 static Boolean isDirectory(const char* path);
90
91 mike 1.13 static Boolean changeDirectory(const char* path);
92
93 static Boolean makeDirectory(const char* path);
94
95 static Boolean getFileSize(const char* path, Uint32& size);
96
97 static Boolean removeDirectory(const char* path);
98
99 static Boolean removeFile(const char* path);
100
101 static Boolean renameFile(const char* oldPath, const char* newPath);
102
103 static DynamicLibraryHandle loadDynamicLibrary(const char* fileName);
104
|
105 mike 1.15 static void unloadDynamicLibrary(DynamicLibraryHandle libraryHandle);
|
106 mike 1.14
|
107 mike 1.13 static String dynamicLoadError(void);
108
109 static DynamicSymbolHandle loadDynamicSymbol(
110 DynamicLibraryHandle libraryHandle,
111 const char* symbolName);
112
113 static String getHostName();
|
114 kumpf 1.17
115 static Uint32 lookupPort(
116 const char * serviceName,
117 Uint32 defaultPort);
|
118 mike 1.14
119 static String getCurrentLoginName();
120
121 /**
122 This function is used to input a password with echo disabled.
123 The function reads up to a newline and returns a password of at most
124 8 characters.
125
126 @param prompt String containing the message prompt to be displayed
127 @return password obtained from the user
128 */
129 static String getPassword(const char* prompt);
130
131 /**
132 This function is used to encrypt the user's password.
133 The encryption is compatible with Apache's password file (generated using
134 the htpasswd command )
135
136 @param password Password to be encrypted.
137 @param salt Two character string chosen from the set [a-zA-Z0-9./].
138
139 mike 1.14 @return Encrypted password.
140 */
141 static String encryptPassword(const char* password, const char* salt);
142
143 /**
144 This function is used to verify whether specified user is a user
145 on the local system.
146
147 @param userName User name to be verified.
148
149 @return true if the username is valid, else false
150 */
151 static Boolean isSystemUser(char* userName);
152
153 /**
|
154 kumpf 1.18 When the user name is not passed as an argument, this function
155 checks whether the user running the command is a privileged user.
156 If a user name is given this function checks whether
157 the given user is a privileged user.
|
158 mike 1.14
|
159 kumpf 1.18 @param userName User name to be checked.
160
161 @return true if the user is a privileged user, else false
|
162 mike 1.14 */
|
163 kumpf 1.18 static Boolean isPrivilegedUser(const String userName = String::EMPTY);
|
164 mike 1.14
|
165 kumpf 1.16 /**
|
166 kumpf 1.19 This function returns the privileged user name on the system.
167
168 @return the privileged user name
169 */
170 static String getPrivilegedUserName();
171
172 /**
|
173 kumpf 1.16 This function is used to get the process ID of the calling process.
174
175 @return Process ID
176 */
177 static Uint32 getPID();
178
|
179 mike 1.13 };
180
181 PEGASUS_NAMESPACE_END
182
183 #endif /* Pegasus_System_h */
|