(file) Return to System.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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.37 
 45 kumpf 1.38 #if defined(PEGASUS_OS_TYPE_WINDOWS)
 46 kumpf 1.37 #ifndef mode_t
 47 kumpf 1.38 typedef unsigned long mode_t;
 48 kumpf 1.37 #endif
 49            #endif
 50            
 51 konrad.r 1.41 #if defined(PEGASUS_OS_LSB)
 52               #if !defined(MAXHOSTNAMELEN)
 53               #define MAXHOSTNAMELEN 64
 54               #endif
 55               #endif
 56               
 57 kumpf    1.17 //
 58               // Protocal Type
 59               //
 60               #define TCP                        "tcp"
 61               
 62 mike     1.13 PEGASUS_NAMESPACE_BEGIN
 63               
 64 kumpf    1.23 
 65 mike     1.13 /** This is an opaque type which is used to represent dynamic library
 66                   handles returned by the System::loadDynamicLibrary() method and
 67                   accepted by the System::loadDynamicProcedure() method.
 68               */
 69               typedef struct DynamicLibraryHandle_* DynamicLibraryHandle;
 70               
 71               /** This is an opaque type which is returned by System::loadDynamicSymbol().
 72                   Values of this type may be casted to the appropriate target type.
 73               */
 74 chuck    1.27 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)         
 75 sage     1.20 typedef struct DynamicSymbolHandle_* DynamicSymbolHandle; 
 76               #else                                                     
 77               extern "C" {typedef int (* DynamicSymbolHandle)(void);}   
 78               #endif                                                    
 79               
 80 mike     1.14 
 81 david    1.32 
 82 mike     1.13 /** The System class defines wrappers for operating system related calls.
 83                   These are only placed here if they are extremely light. These are
 84                   usually just direct wrappers which map more or less one to one to the
 85                   underlying function.
 86               */
 87               class PEGASUS_COMMON_LINKAGE System
 88               {
 89               public:
 90                   /** getCurrentTime - Gets the current time as seconds and milliseconds
 91                   into the provided variables using system functions.
 92                   @param seconds Return for the seconds component of the time.
 93                   @param milliseconds Return for the milliseconds component of the time.
 94                   @return The value is returned in the parameters.
 95                   The time returned is as defined in number of seconds and milliseconds
 96                   since 00:00 Coordinated Universal Time (UTC), January 1, 1970,
 97 mike     1.14 
 98 mike     1.13     */
 99                   static void getCurrentTime(Uint32& seconds, Uint32& milliseconds);
100               
101                   /** getCurrentASCIITime Gets time/date in a fixed format. The format is
102                       YY MM DD-HH:MM:SS
103               	@return Returns String with the ASCII time date.
104                   */
105                   static String getCurrentASCIITime();
106               
107                   static void sleep(Uint32 seconds);
108               
109                   static Boolean exists(const char* path);
110               
111                   static Boolean canRead(const char* path);
112               
113                   static Boolean canWrite(const char* path);
114               
115                   static Boolean getCurrentDirectory(char* path, Uint32 size);
116               
117                   static Boolean isDirectory(const char* path);
118               
119 mike     1.13     static Boolean changeDirectory(const char* path);
120               
121                   static Boolean makeDirectory(const char* path);
122               
123                   static Boolean getFileSize(const char* path, Uint32& size);
124               
125                   static Boolean removeDirectory(const char* path);
126               
127                   static Boolean removeFile(const char* path);
128               
129                   static Boolean renameFile(const char* oldPath, const char* newPath);
130               
131 mike     1.21     static Boolean copyFile(const char* fromPath, const char* toPath);
132               
133 konrad.r 1.33     /** Unix issue:<br><br><b>RTLD_<bah></b> issue. Currently Pegasus uses RTLD_NOW during
134               	loading of the library if supported by OS.  Previous to 2.2, Pegasus used RTLD_GLOBAL on Linux
135               	- that behaviour is now deprecated.
136                   */
137 mike     1.13     static DynamicLibraryHandle loadDynamicLibrary(const char* fileName);
138               
139 mike     1.15     static void unloadDynamicLibrary(DynamicLibraryHandle libraryHandle);
140 mike     1.14 
141 mike     1.13     static String dynamicLoadError(void);
142               
143                   static DynamicSymbolHandle loadDynamicSymbol(
144               	DynamicLibraryHandle libraryHandle,
145               	const char* symbolName);
146               
147                   static String getHostName();
148 kumpf    1.22     static String getFullyQualifiedHostName ();
149                   static String getSystemCreationClassName ();
150 kumpf    1.17 
151                   static Uint32 lookupPort(
152                       const char * serviceName,
153                       Uint32 defaultPort);
154 mike     1.14 
155 kumpf    1.24     static String getEffectiveUserName();
156 mike     1.14 
157                   /**
158                   This function is used to input a password with echo disabled.
159                   The function reads up to a newline and returns a password of at most
160                   8 characters.
161               
162                   @param  prompt      String containing the message prompt to be displayed
163                   @return             password obtained from the user
164                   */
165                   static String getPassword(const char* prompt);
166               
167                   /**
168                   This function is used to encrypt the user's password. 
169                   The encryption is compatible with Apache's  password file (generated using
170                   the htpasswd command )
171               
172                   @param password     Password to be encrypted.
173                   @param salt         Two character string chosen from the set [a-zA-Z0-9./].
174               
175                   @return             Encrypted password.
176                   */
177 mike     1.14     static String encryptPassword(const char* password, const char* salt);
178               
179                   /**
180                   This function is used to verify whether specified user is a user 
181                   on the local system.
182               
183                   @param userName     User name to be verified.
184               
185                   @return             true if the username is valid, else false
186                   */
187 kumpf    1.28     static Boolean isSystemUser(const char* userName);
188 mike     1.14 
189                   /**
190 kumpf    1.24     Checks whether the given user is a privileged user.
191 mike     1.14 
192 kumpf    1.18     @param userName     User name to be checked.
193                   @return             true if the user is a privileged user, else false
194 mike     1.14     */
195 kumpf    1.24     static Boolean isPrivilegedUser(const String userName);
196 mike     1.14 
197 kumpf    1.16     /**
198 kumpf    1.19     This function returns the privileged user name on the system.
199               
200                   @return             the privileged user name
201                   */
202                   static String getPrivilegedUserName();
203               
204                   /**
205 kumpf    1.39     This function is used to verify whether the specified user is a member
206                   of the specified user group.
207               
208                   @param userName     User name to be verified.
209               
210                   @param groupName    User group name.
211               
212                   @return             true if the user is a member of the user group,
213                                       false otherwise.
214               
215                   @throw              InternalSystemError - If there is an error
216                                       accessing the specified user or group information.
217                   */
218                   static Boolean isGroupMember(const char* userName, const char* groupName);
219               
220                   /**
221 kumpf    1.16     This function is used to get the process ID of the calling process.
222               
223                   @return             Process ID
224                   */
225                   static Uint32 getPID();
226               
227 mike     1.21     static Boolean truncateFile(const char* path, size_t newSize);
228 kumpf    1.23 
229 kumpf    1.29     /** Compare two strings but ignore any case differences.
230                       This method is provided only because some platforms lack a strcasecmp
231                       function in the standard library.
232                   */
233                   static Sint32 strcasecmp(const char* s1, const char* s2);
234 tony     1.30     
235                   /** Return just the file or directory name from the path into basename.
236                       This method returns a file or directory name at the end of a path.
237                       The path can be relative or absolute. If the path is the root,
238                       then empty string is returned.        
239                   */
240 kumpf    1.31     static char *extract_file_name(const char *fullpath, char *basename);
241 tony     1.30 
242                   /** Return just the pathname into dirname. The fullpath can be relative
243                       or absolute. This method returns a path minus the file or
244                       directory name at the end of a supplied path (fullpath).
245                       If the fullpath is the root, then fullpath is returned.
246                       The resulting path will contain a trailing slash unless fullpath is
247                       a file or directory name, in which case, just the file or directory
248                       name is returned. 
249                   */
250 kumpf    1.31     static char *extract_file_path(const char *fullpath, char *dirname);
251 tony     1.30 
252                   // Is absolute path?
253 kumpf    1.31     static Boolean is_absolute_path(const char *path);
254 kumpf    1.36 
255                   /** Changes file permissions on the given file.
256                       @param path path of the file.
257                       @param mode the bit-wise inclusive OR of the values for the desired 
258                       permissions.
259                       @return true on success, false on error and errno is set appropriately.
260                   */
261                   static Boolean changeFilePermissions(const char* path, mode_t mode);
262 kumpf    1.29 
263 kumpf    1.40     /**
264                       Flag indicating whether shared libraries are loaded with the
265                       BIND_VERBOSE option.
266               
267                       THIS FLAG IS USED ON HP-UX ONLY.
268                    */
269 kumpf    1.23     static Boolean bindVerbose;
270 david    1.32 
271                   /** This function is an abstraction for the openlog interface used in the Logger
272                       class.  Each platform intending to use system logs should support this interface
273                   */
274                   static void openlog(const String);
275               
276                   /** This function is an abstraction for the syslog interface used in the Logger
277                       class.  Each platform intending to use system logs should support this interface
278                   */
279                   static void syslog(Uint32, const char *);
280               
281                   /** This function is an abstraction for the closelog interface used in the Logger
282                       class.  Each platform intending to use system logs should support this interface
283                   */
284                   static void closelog();
285               
286                   // System ID constants for Logger::put and Logger::trace
287                   static const String CIMSERVER;
288 tony     1.34 
289                   // System ID constants for Logger::put and Logger::trace
290                   static const String CIMLISTENER;
291 mike     1.13 };
292               
293               PEGASUS_NAMESPACE_END
294               
295               #endif /* Pegasus_System_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2