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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2