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

   1 karl  1.71 //%2003////////////////////////////////////////////////////////////////////////
   2 mike  1.19 //
   3 karl  1.71 // 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.19 //
   8            // Permission is hereby granted, free of charge, to any person obtaining a copy
   9 mike  1.21 // 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.19 // 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.39 // 
  15 mike  1.21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  16 mike  1.19 // 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.21 // 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.19 // 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.21 // Modified By: Ben Heilbronn (ben_heilbronn@hp.com)
  29            //              Sushma Fernandes (sushma_fernandes@hp.com)
  30            //              Nag Boranna (nagaraja_boranna@hp.com)
  31 kumpf 1.75 //              Bapu Patil (bapu_patil@hp.com)
  32 mike  1.19 //
  33 david 1.54 // Modified By: Dave Rosckes (rosckes@us.ibm.com)
  34            //
  35 mike  1.19 //%/////////////////////////////////////////////////////////////////////////////
  36            
  37            #ifdef PEGASUS_OS_HPUX
  38            # include <dl.h>
  39 mike  1.21 #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
  40            # include <dll.h>
  41 chuck 1.44 #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
  42            #  include <fcntl.h> 
  43 david 1.70 #  include <qycmutilu2.H>
  44 chuck 1.44 #  include <unistd.cleinc>
  45 david 1.54 #  include "qycmmsgclsMessage.H" // ycmMessage class
  46 david 1.63 #  include "OS400SystemState.h"  // OS400LoadDynamicLibrary, etc
  47            #include "OS400ConvertChar.h"
  48 mike  1.19 #else
  49            # include <dlfcn.h>
  50            #endif
  51            
  52 mike  1.21 #include <unistd.h>
  53 mike  1.19 #include <dirent.h>
  54 mike  1.21 #include <pwd.h>
  55 kumpf 1.81 #include <grp.h>
  56 sage  1.23 
  57 kumpf 1.79 #include <errno.h>
  58            #if defined(PEGASUS_OS_SOLARIS) 
  59            #  include <string.h> 
  60            #endif 
  61            
  62 dudhe.girish 1.80 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) && !defined(PEGASUS_PLATFORM_DARWIN_PPC_GNU) 
  63 kumpf        1.24 #include <crypt.h> 
  64 sage         1.23 #endif
  65                   
  66 marek        1.60 #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
  67                   #include <arpa/inet.h>
  68 marek        1.83 #include <__ftp.h>
  69 marek        1.60 #endif
  70                   
  71 david        1.54 #if defined(PEGASUS_USE_SYSLOGS) 
  72                   #include <syslog.h>
  73                   #endif
  74                   
  75 mike         1.19 #include <sys/stat.h>
  76                   #include <sys/types.h>
  77                   #include <cstdio>
  78                   #include <time.h>
  79 kumpf        1.41 #include <sys/time.h>
  80 kumpf        1.24 #include <netdb.h>
  81 kumpf        1.41 #include "System.h"
  82 mike         1.21 #include <Pegasus/Common/Tracer.h>
  83 kumpf        1.25 #include <Pegasus/Common/Destroyer.h>
  84 kumpf        1.42 #include <Pegasus/Common/InternalException.h>
  85 marek        1.73 #ifdef PEGASUS_ZOS_SECURITY
  86                   #include "DynamicLibraryzOS_inline.h"
  87                   #endif
  88 mike         1.21 
  89 mike         1.19 PEGASUS_NAMESPACE_BEGIN
  90                   
  91 kumpf        1.35 Boolean System::bindVerbose = false;
  92                   
  93 david        1.63 #ifdef PEGASUS_OS_OS400
  94                   typedef struct os400_pnstruct
  95                   {
  96                     Qlg_Path_Name_T qlg_struct;
  97                     char * pn; 
  98                   } OS400_PNSTRUCT;
  99                   #endif
 100                   
 101 mike         1.19 inline void sleep_wrapper(Uint32 seconds)
 102                   {
 103                       sleep(seconds);
 104                   }
 105                   
 106                   void System::getCurrentTime(Uint32& seconds, Uint32& milliseconds)
 107                   {
 108                       timeval tv;
 109                       gettimeofday(&tv, 0);
 110 kumpf        1.33     seconds = Uint32(tv.tv_sec);
 111                       milliseconds = Uint32(tv.tv_usec) / 1000;
 112 mike         1.19 }
 113                   
 114                   String System::getCurrentASCIITime()
 115                   {
 116                       char    str[50];
 117                       time_t  rawTime;
 118                   
 119                       time(&rawTime);
 120 kumpf        1.32     strftime(str, 40,"%m/%d/%Y-%T", localtime(&rawTime));
 121 mike         1.19     String time = str;
 122                       return time;
 123                   }
 124                   
 125                   void System::sleep(Uint32 seconds)
 126                   {
 127                       sleep_wrapper(seconds);
 128                   }
 129                   
 130                   Boolean System::exists(const char* path)
 131                   {
 132 david        1.63 #if defined(PEGASUS_OS_OS400)
 133                       OS400_PNSTRUCT pathname;
 134                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 135                       pathname.qlg_struct.CCSID = 1208;
 136                   #pragma convert(37)
 137                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 138                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 139                   #pragma convert(0)
 140                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 141                       pathname.qlg_struct.Path_Length = strlen(path);
 142                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 143                       pathname.pn = (char *)path;
 144                    
 145                       return QlgAccess((Qlg_Path_Name_T *)&pathname, F_OK) == 0;
 146                   #else
 147 mike         1.19     return access(path, F_OK) == 0;
 148 david        1.63 #endif
 149 mike         1.19 }
 150                   
 151                   Boolean System::canRead(const char* path)
 152                   {
 153 david        1.63 
 154                   #if defined(PEGASUS_OS_OS400)
 155                       OS400_PNSTRUCT pathname;
 156                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 157                       pathname.qlg_struct.CCSID = 1208;
 158                   #pragma convert(37)
 159                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 160                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 161                   #pragma convert(0)
 162                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 163                       pathname.qlg_struct.Path_Length = strlen(path);
 164                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 165                       pathname.pn = (char *)path;
 166                   
 167                       return QlgAccess((Qlg_Path_Name_T *)&pathname, R_OK) == 0;
 168                   #else
 169 mike         1.19     return access(path, R_OK) == 0;
 170 david        1.63 #endif
 171 mike         1.19 }
 172                   
 173                   Boolean System::canWrite(const char* path)
 174                   {
 175 david        1.63 #if defined(PEGASUS_OS_OS400)
 176                       OS400_PNSTRUCT pathname;
 177                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 178                       pathname.qlg_struct.CCSID = 1208;
 179                   #pragma convert(37)
 180                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 181                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 182                   #pragma convert(0)
 183                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 184                       pathname.qlg_struct.Path_Length = strlen(path);
 185                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 186                       pathname.pn = (char *)path;
 187                    
 188                       return QlgAccess((Qlg_Path_Name_T *)&pathname, W_OK) == 0;
 189                   #else
 190 mike         1.19     return access(path, W_OK) == 0;
 191 david        1.63 #endif
 192 mike         1.19 }
 193                   
 194                   Boolean System::getCurrentDirectory(char* path, Uint32 size)
 195                   {
 196 david        1.63 #if defined(PEGASUS_OS_OS400)
 197                       OS400_PNSTRUCT pathname;
 198                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 199                       pathname.qlg_struct.CCSID = 1208;
 200                   #pragma convert(37)
 201                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 202                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 203                   #pragma convert(0)
 204                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 205                       pathname.qlg_struct.Path_Length = strlen(path);
 206                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 207                       pathname.pn = (char *)path;
 208                    
 209                       return QlgGetcwd((Qlg_Path_Name_T *)&pathname, size) == 0;
 210                   #else
 211 mike         1.19     return getcwd(path, size) != NULL;
 212 david        1.63 #endif
 213 mike         1.19 }
 214                   
 215                   Boolean System::isDirectory(const char* path)
 216                   {
 217                       struct stat st;
 218                   
 219 david        1.63 #if defined(PEGASUS_OS_OS400)
 220                       OS400_PNSTRUCT pathname;
 221                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 222                       pathname.qlg_struct.CCSID = 1208;
 223                   #pragma convert(37)
 224                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 225                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 226                   #pragma convert(0)
 227                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 228                       pathname.qlg_struct.Path_Length = strlen(path);
 229                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 230                       pathname.pn = (char *)path;
 231                   
 232                       if (QlgStat((Qlg_Path_Name_T *)&pathname, &st) != 0)
 233                   	return false;
 234                   #else
 235 mike         1.19     if (stat(path, &st) != 0)
 236 mike         1.21         return false;
 237 david        1.63 #endif
 238 mike         1.19     return S_ISDIR(st.st_mode);
 239                   }
 240                   
 241                   Boolean System::changeDirectory(const char* path)
 242                   {
 243 david        1.63 #if defined(PEGASUS_OS_OS400)
 244                       OS400_PNSTRUCT pathname;
 245                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 246                       pathname.qlg_struct.CCSID = 1208;
 247                   #pragma convert(37)
 248                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 249                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 250                   #pragma convert(0)
 251                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 252                       pathname.qlg_struct.Path_Length = strlen(path);
 253                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 254                       pathname.pn = (char *)path;
 255                    
 256                       return QlgChdir((Qlg_Path_Name_T *)&pathname) == 0;
 257                   #else
 258 mike         1.19     return chdir(path) == 0;
 259 david        1.63 #endif
 260 mike         1.19 }
 261                   
 262                   Boolean System::makeDirectory(const char* path)
 263                   {
 264 david        1.63 
 265                   #if defined(PEGASUS_OS_OS400)
 266                       OS400_PNSTRUCT pathname;
 267                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 268                       pathname.qlg_struct.CCSID = 1208;
 269                   #pragma convert(37)
 270                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 271                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 272                   #pragma convert(0)
 273                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 274                       pathname.qlg_struct.Path_Length = strlen(path);
 275                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 276                       pathname.pn = (char *)path;
 277                    
 278                       return QlgMkdir((Qlg_Path_Name_T *)&pathname, 0777) == 0;
 279                   #else
 280 mike         1.19     return mkdir(path, 0777) == 0;
 281 david        1.63 #endif
 282                   
 283 mike         1.19 }
 284                   
 285                   Boolean System::getFileSize(const char* path, Uint32& size)
 286                   {
 287                       struct stat st;
 288                   
 289 david        1.63 #if defined(PEGASUS_OS_OS400)
 290                       OS400_PNSTRUCT pathname;
 291                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 292                       pathname.qlg_struct.CCSID = 1208;
 293                   #pragma convert(37)
 294                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 295                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 296                   #pragma convert(0)
 297                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 298                       pathname.qlg_struct.Path_Length = strlen(path);
 299                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 300                       pathname.pn = (char *)path;
 301                   
 302                       if (QlgStat((Qlg_Path_Name_T *)&pathname, &st) != 0)
 303                   	return false;
 304                   #else
 305 mike         1.19     if (stat(path, &st) != 0)
 306 mike         1.21         return false;
 307 david        1.63 #endif
 308 mike         1.19 
 309                       size = st.st_size;
 310                       return true;
 311                   }
 312                   
 313                   Boolean System::removeDirectory(const char* path)
 314                   {
 315 david        1.63 #if defined(PEGASUS_OS_OS400)
 316                       OS400_PNSTRUCT pathname;
 317                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 318                       pathname.qlg_struct.CCSID = 1208;
 319                   #pragma convert(37)
 320                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 321                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 322                   #pragma convert(0)
 323                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 324                       pathname.qlg_struct.Path_Length = strlen(path);
 325                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 326                       pathname.pn = (char *)path;
 327                    
 328                       return QlgRmdir((Qlg_Path_Name_T *)&pathname) == 0;
 329                   #else
 330 mike         1.21     return rmdir(path) == 0;
 331 david        1.63 #endif
 332 mike         1.19 }
 333                   
 334                   Boolean System::removeFile(const char* path)
 335                   {
 336 david        1.63 #if defined(PEGASUS_OS_OS400)
 337                       OS400_PNSTRUCT pathname;
 338                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 339                       pathname.qlg_struct.CCSID = 1208;
 340                   #pragma convert(37)
 341                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 342                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 343                   #pragma convert(0)
 344                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 345                       pathname.qlg_struct.Path_Length = strlen(path);
 346                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 347                       pathname.pn = (char *)path;
 348                    
 349                       return QlgUnlink((Qlg_Path_Name_T *)&pathname) == 0;
 350                   #else
 351 mike         1.21     return unlink(path) == 0;
 352 david        1.63 #endif
 353 mike         1.19 }
 354                   
 355                   Boolean System::renameFile(const char* oldPath, const char* newPath)
 356                   {
 357 david        1.63 #if defined(PEGASUS_OS_OS400)
 358                       OS400_PNSTRUCT oldpathname;
 359                       memset((void*)&oldpathname, 0x00, sizeof(OS400_PNSTRUCT));
 360                       oldpathname.qlg_struct.CCSID = 1208;
 361                   #pragma convert(37)
 362                       memcpy(oldpathname.qlg_struct.Country_ID,"US",2);
 363                       memcpy(oldpathname.qlg_struct.Language_ID,"ENU",3);
 364                   #pragma convert(0)
 365                       oldpathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 366                       oldpathname.qlg_struct.Path_Length = strlen(oldPath);
 367                       oldpathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 368                       oldpathname.pn = (char *)oldPath;
 369                   
 370                       OS400_PNSTRUCT newpathname;
 371                       memset((void*)&newpathname, 0x00, sizeof(OS400_PNSTRUCT));
 372                       newpathname.qlg_struct.CCSID = 1208;
 373                   #pragma convert(37)
 374                       memcpy(newpathname.qlg_struct.Country_ID,"US",2);
 375                       memcpy(newpathname.qlg_struct.Language_ID,"ENU",3);
 376                   #pragma convert(0)
 377                       newpathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 378 david        1.63     newpathname.qlg_struct.Path_Length = strlen(newPath);
 379                       newpathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 380                       newpathname.pn = (char *)newPath;
 381                   
 382                       if (QlgLink((Qlg_Path_Name_T *)&oldpathname,
 383                   		(Qlg_Path_Name_T *)&newpathname) != 0)
 384                       {
 385                   	return false;
 386                       }
 387                   
 388                       return QlgUnlink((Qlg_Path_Name_T *)&oldpathname) == 0;
 389                   #else
 390                   
 391 mike         1.19     if (link(oldPath, newPath) != 0)
 392 mike         1.21         return false;
 393 mike         1.19 
 394                       return unlink(oldPath) == 0;
 395 david        1.63 #endif
 396 mike         1.19 }
 397                   
 398                   DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName)
 399                   {
 400 kumpf        1.40     PEG_METHOD_ENTER(TRC_OS_ABSTRACTION, "System::loadDynamicLibrary()");
 401 mike         1.19 
 402 mike         1.21     Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2, 
 403                                     "Attempting to load library %s", fileName);
 404 mike         1.19 
 405 mike         1.21 #if defined(PEGASUS_OS_HPUX)
 406 kumpf        1.35     void* handle;
 407                       if (bindVerbose)
 408                       {
 409                           handle = shl_load(fileName, 
 410                                        BIND_IMMEDIATE | DYNAMIC_PATH | BIND_VERBOSE, 0L);
 411                       }
 412                       else 
 413                       {
 414                           handle = shl_load(fileName, BIND_IMMEDIATE | DYNAMIC_PATH, 0L);
 415                       }
 416 mike         1.21     Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2, 
 417 kumpf        1.34                   "After loading lib %s, error code is %d", fileName, 
 418                                     (handle == (void *)0)?errno:0);
 419 mike         1.21 
 420 kumpf        1.40     PEG_METHOD_EXIT();
 421 mike         1.19     return DynamicLibraryHandle(handle);
 422 mike         1.21 #elif defined(PEGASUS_OS_TRU64)
 423 kumpf        1.40     PEG_METHOD_EXIT();
 424 mike         1.21     return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW));
 425                   #elif defined(PEGASUS_OS_ZOS)
 426 marek        1.73 	#if defined(PEGASUS_ZOS_SECURITY)
 427                   		if (!hasProgramControl(fileName))
 428                   		{
 429                   			PEG_METHOD_EXIT();
 430                   			return 0;
 431                   		}
 432                   	#endif
 433 kumpf        1.40     PEG_METHOD_EXIT();
 434 marek        1.73 	return DynamicLibraryHandle(dllload(fileName));
 435 chuck        1.44 #elif defined(PEGASUS_OS_OS400)
 436                       PEG_METHOD_EXIT();
 437 chuck        1.57     return DynamicLibraryHandle(OS400_LoadDynamicLibrary(fileName));
 438 mike         1.19 #else
 439 kumpf        1.40     PEG_METHOD_EXIT();
 440 schuur       1.76     return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW));
 441 mike         1.21 #endif
 442 mike         1.20 
 443 mike         1.21 }
 444 mike         1.20 
 445 mike         1.21 void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle)
 446                   {
 447                       // ATTN: Should this method indicate success/failure?
 448 dudhe.girish 1.80 #if defined(PEGASUS_OS_LINUX) || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_DARWIN)
 449 mike         1.21     dlclose(libraryHandle);
 450                   #endif
 451                   
 452                   #ifdef PEGASUS_OS_HPUX
 453                       // Note: shl_unload will unload the library even if it has been loaded
 454                       // multiple times.  No reference count is kept.
 455 kumpf        1.31     int ignored = shl_unload(reinterpret_cast<shl_t>(libraryHandle));
 456 mike         1.19 #endif
 457 chuck        1.57 
 458                   #ifdef PEGASUS_OS_OS400
 459                      OS400_UnloadDynamicLibrary((int)libraryHandle);
 460                   #endif
 461 kv.le        1.64 
 462                   #ifdef PEGASUS_OS_AIX
 463                       dlclose(libraryHandle);
 464                   #endif
 465                   
 466 marek        1.74 #ifdef PEGASUS_OS_ZOS
 467                   	dllfree(reinterpret_cast<dllhandle *> (libraryHandle));
 468                   #endif
 469 mike         1.19 }
 470                   
 471                   String System::dynamicLoadError() {
 472 mike         1.21     // ATTN: Is this safe in a multi-threaded process?  Should this string
 473                       // be returned from loadDynamicLibrary?
 474 mike         1.19 #ifdef PEGASUS_OS_HPUX
 475 mike         1.21     // ATTN: If shl_load() returns NULL, this value should be strerror(errno)
 476                       return String();
 477                   #elif defined(PEGASUS_OS_ZOS)
 478 mike         1.19     return String();
 479 chuck        1.44 #elif defined(PEGASUS_OS_OS400)
 480 chuck        1.57     return String(OS400_DynamicLoadError());
 481 mike         1.19 #else
 482                       String dlerr = dlerror();
 483                       return dlerr;
 484                   #endif
 485                   }
 486                   
 487                   
 488                   DynamicSymbolHandle System::loadDynamicSymbol(
 489                       DynamicLibraryHandle libraryHandle,
 490                       const char* symbolName)
 491                   {
 492                   #ifdef PEGASUS_OS_HPUX
 493                       char* p = (char*)symbolName;
 494                       void* proc = 0;
 495                   
 496 kumpf        1.31     if (shl_findsym((shl_t*)&libraryHandle, symbolName, TYPE_UNDEFINED,
 497                                       &proc) == 0)
 498                       {
 499 mike         1.21         return DynamicSymbolHandle(proc);
 500 kumpf        1.31     }
 501 mike         1.19 
 502 kumpf        1.47     if (shl_findsym((shl_t*)libraryHandle,
 503                                       (String("_") + symbolName).getCString(),
 504                                       TYPE_UNDEFINED,
 505 kumpf        1.31                     &proc) == 0)
 506 mike         1.19     {
 507 mike         1.21         return DynamicSymbolHandle(proc);
 508 mike         1.19     }
 509                   
 510                       return 0;
 511                   
 512 mike         1.21 #elif defined(PEGASUS_OS_ZOS)
 513                       return DynamicSymbolHandle(dllqueryfn((dllhandle *)libraryHandle,
 514                                                  (char*)symbolName));
 515 chuck        1.44 
 516                   #elif defined(PEGASUS_OS_OS400)
 517 chuck        1.57     return DynamicSymbolHandle(OS400_LoadDynamicSymbol((int)libraryHandle,
 518                                                  symbolName));
 519 mike         1.19 #else
 520                   
 521 chuck        1.57     return DynamicSymbolHandle(dlsym(libraryHandle,(char *) symbolName));
 522 mike         1.19 
 523                   #endif
 524                   }
 525                   
 526                   String System::getHostName()
 527                   {
 528 kumpf        1.75     static char hostname[PEGASUS_MAXHOSTNAMELEN];
 529 mike         1.19 
 530                       if (!*hostname)
 531 david        1.63     {
 532 mike         1.19         gethostname(hostname, sizeof(hostname));
 533 david        1.63 #if defined(PEGASUS_OS_OS400)
 534                   	EtoA(hostname);
 535                   #endif
 536                       }
 537 mike         1.19 
 538                       return hostname;
 539 kumpf        1.24 }
 540                   
 541 kumpf        1.30 String System::getFullyQualifiedHostName ()
 542                   {
 543                   #ifdef PEGASUS_OS_HPUX
 544 kumpf        1.75     char hostName [PEGASUS_MAXHOSTNAMELEN];
 545 kumpf        1.30     struct hostent *he;
 546                       String fqName;
 547                   
 548 kumpf        1.75     if (gethostname (hostName, PEGASUS_MAXHOSTNAMELEN) != 0)
 549 kumpf        1.30     {
 550                           return String::EMPTY;
 551                       }
 552                   
 553                       if (he = gethostbyname (hostName))
 554                       {
 555                          strcpy (hostName, he->h_name);
 556                       }
 557                   
 558                       fqName.assign (hostName);
 559                   
 560                       return fqName;
 561 marek        1.78 #elif defined(PEGASUS_OS_ZOS)
 562                   	char hostName [PEGASUS_MAXHOSTNAMELEN];
 563 marek        1.83 	char *domainName;
 564 marek        1.78 	String fqName;
 565                   	// receive short name of the local host
 566                   	if (gethostname(hostName, PEGASUS_MAXHOSTNAMELEN) != 0)
 567                   	{
 568                   		return String::EMPTY;
 569                   	}
 570                   	// get domain name of the local host
 571 marek        1.83 	domainName= __ipDomainName();
 572                   	if (domainName == 0)
 573 marek        1.78 	{
 574                   		return String::EMPTY;
 575                   	}
 576                   	// build fully qualified hostname
 577                   	fqName.assign(hostName);
 578                   	fqName.append(".");
 579                   	fqName.append(domainName);
 580                   
 581                   	return fqName;
 582 kumpf        1.30 #else
 583                       //
 584                       //  ATTN: Implement this method to return the fully qualified host name
 585                       //
 586                       return String::EMPTY;
 587                   #endif
 588                   }
 589                   
 590                   String System::getSystemCreationClassName ()
 591                   {
 592                   #ifdef PEGASUS_OS_HPUX
 593                       return "CIM_ComputerSystem";
 594                   #else
 595                       //
 596                       //  ATTN: Implement this method to return the system creation class name
 597                       //
 598                       return String::EMPTY;
 599                   #endif
 600                   }
 601                   
 602 kumpf        1.24 Uint32 System::lookupPort(
 603                       const char * serviceName, 
 604                       Uint32 defaultPort)
 605                   {
 606                       Uint32 localPort;
 607                   
 608                       struct servent *serv;
 609                   
 610                       //
 611                       // Get wbem-local port from /etc/services
 612                       //
 613 chuck        1.44 #if !defined(PEGASUS_OS_OS400)
 614 keith.petley 1.62 #ifdef PEGASUS_OS_SOLARIS
 615                   #define SERV_BUFF_SIZE	1024
 616                       struct servent	serv_result;
 617                       char		buf[SERV_BUFF_SIZE];
 618                   
 619                       if ( (serv = getservbyname_r(serviceName, TCP, &serv_result,
 620                   				buf, SERV_BUFF_SIZE)) != NULL )
 621                   #else // PEGASUS_OS_SOLARIS
 622 kumpf        1.37     if ( (serv = getservbyname(serviceName, TCP)) != NULL )
 623 keith.petley 1.62 #endif // PEGASUS_OS_SOLARIS
 624                   #else  // !PEGASUS_OS_OS400
 625 chuck        1.65     // Note - serviceName came from Constants.h - no need to
 626                       // convert to EBCDIC
 627 chuck        1.44     // Need to cast on OS/400
 628                       if ( (serv = getservbyname((char *)serviceName, TCP)) != NULL )
 629 keith.petley 1.62 #endif  // !PEGASUS_OS_OS400
 630 kumpf        1.24     {
 631 sage         1.43         localPort = htons((uint16_t)serv->s_port);
 632 kumpf        1.24     }
 633                       else
 634                       {
 635                           localPort = defaultPort;
 636                       }
 637                   
 638                       return localPort;
 639 mike         1.19 }
 640                   
 641 mike         1.21 String System::getPassword(const char* prompt)
 642                   {
 643                   
 644                       String password;
 645                   
 646 chuck        1.44 #if !defined(PEGASUS_OS_OS400)
 647                       // Not supported on OS/400, and we don't need it.
 648 mike         1.21     password = String(getpass( prompt ));
 649 chuck        1.44 #endif
 650 mike         1.21 
 651                       return password;
 652                   }
 653                   
 654 kumpf        1.38 String System::getEffectiveUserName()
 655 mike         1.21 {
 656                       String userName = String::EMPTY;
 657                       struct passwd*   pwd = NULL;
 658                   
 659 kumpf        1.66 #if defined(PEGASUS_OS_SOLARIS) || \
 660                       defined(PEGASUS_OS_HPUX) || \
 661                       defined(PEGASUS_OS_LINUX)
 662                   
 663                       const unsigned int PWD_BUFF_SIZE = 1024;
 664 kumpf        1.79     struct passwd       local_pwd;
 665                       char                buf[PWD_BUFF_SIZE];
 666                   
 667                       if(getpwuid_r(geteuid(), &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0)
 668                       {
 669                           String errorMsg = String("getpwuid_r failure : ") +
 670                                               String(strerror(errno));
 671                           Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 672                                                     errorMsg);
 673                           // L10N TODO - This message needs to be added.
 674                           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 675                           //                          errorMsg);
 676 keith.petley 1.62     }
 677                   #else
 678 mike         1.21     //
 679                       //  get the currently logged in user's UID.
 680                       //
 681 kumpf        1.38     pwd = getpwuid(geteuid());
 682 keith.petley 1.62 #endif
 683 mike         1.21     if ( pwd == NULL )
 684                       {
 685 kumpf        1.79          // L10N TODO - This message needs to be added.
 686                            //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 687                            //  "getpwuid_r failure, user may have been removed just after login");
 688                            Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4,
 689                                "getpwuid_r failure, user may have been removed just after login");
 690 mike         1.21     }
 691                       else
 692                       {
 693 chuck        1.65 #if defined(PEGASUS_OS_OS400)
 694 kumpf        1.79         EtoA(pwd->pw_name);
 695 chuck        1.65 #endif
 696 mike         1.21         //
 697                           //  get the user name
 698                           //
 699                           userName.assign(pwd->pw_name);
 700                       }
 701                   
 702                       return(userName);
 703                   }
 704                   
 705                   String System::encryptPassword(const char* password, const char* salt)
 706                   {
 707 chuck        1.44 #if !defined(PEGASUS_OS_OS400)
 708 mike         1.21     return ( String(crypt( password,salt)) );
 709 chuck        1.44 #else
 710                       // Not supported on OS400, and we don't need it.
 711                       return ( String(password) );
 712                   #endif
 713 mike         1.21 }
 714                   
 715 kumpf        1.47 Boolean System::isSystemUser(const char* userName)
 716 mike         1.21 {
 717 chuck        1.65 #if defined(PEGASUS_OS_OS400)
 718                       AtoE((char *)userName);
 719                   #endif
 720                   
 721 kumpf        1.66 #if defined(PEGASUS_OS_SOLARIS) || \
 722                       defined(PEGASUS_OS_HPUX) || \
 723                       defined(PEGASUS_OS_LINUX)
 724                   
 725                       const unsigned int PWD_BUFF_SIZE = 1024;
 726 keith.petley 1.62     struct passwd   pwd;
 727                       struct passwd   *result;
 728 kumpf        1.66     char            pwdBuffer[PWD_BUFF_SIZE];
 729 keith.petley 1.62 
 730 kumpf        1.66     if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
 731 kumpf        1.79     {
 732                           String errorMsg = String("getpwnam_r failure : ") +
 733                                               String(strerror(errno));
 734                           Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 735                                                     errorMsg);
 736                           // L10N TODO - This message needs to be added.
 737                           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 738                           //                          errorMsg);
 739                       }
 740                       if (result == NULL)
 741                       {
 742                           return false;
 743                       }
 744 keith.petley 1.62 #else
 745 mike         1.21     //
 746                       //  get the password entry for the user
 747                       //
 748                       if  ( getpwnam(userName) == NULL )
 749                       {
 750 chuck        1.65 #if defined(PEGASUS_OS_OS400)
 751 kumpf        1.79         EtoA((char *)userName);
 752 chuck        1.65 #endif
 753 kumpf        1.79         return false;
 754 mike         1.21     }
 755 kumpf        1.79 #endif
 756 chuck        1.65 #if defined(PEGASUS_OS_OS400)
 757                       EtoA((char *)userName);
 758                   #endif
 759 kumpf        1.79 
 760 mike         1.21     return true;
 761                   }
 762                   
 763 kumpf        1.25 Boolean System::isPrivilegedUser(const String userName)
 764 mike         1.21 {
 765                       //
 766 kumpf        1.38     // Check if the given user is a privileged user
 767 mike         1.21     //
 768 chuck        1.51 #if !defined(PEGASUS_OS_OS400)
 769 kumpf        1.38     struct passwd   pwd;
 770                       struct passwd   *result;
 771 kumpf        1.79     const unsigned int PWD_BUFF_SIZE = 1024;
 772                       char            pwdBuffer[PWD_BUFF_SIZE];
 773                   
 774                       if (getpwnam_r(
 775                             userName.getCString(), &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
 776                       {
 777                           String errorMsg = String("getpwnam_r failure : ") +
 778                                               String(strerror(errno));
 779                           Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 780                                                     errorMsg);
 781                           // L10N TODO - This message needs to be added.
 782                           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 783                           //                          errorMsg);
 784                       }
 785 kumpf        1.25 
 786 kumpf        1.79     // Check if the requested entry was found. If not return false.
 787                       if ( result != NULL )
 788 kumpf        1.25     {
 789 kumpf        1.79         // Check if the uid is 0.
 790 kumpf        1.38         if ( pwd.pw_uid == 0 )
 791 kumpf        1.25         {
 792 kumpf        1.38             return true;
 793 kumpf        1.25         }
 794 mike         1.21     }
 795 kumpf        1.38     return false;
 796 kumpf        1.79 
 797 chuck        1.51 #else
 798 chuck        1.65     CString user = userName.getCString();
 799                       const char * tmp = (const char *)user;
 800                       AtoE((char *)tmp);
 801                       return ycmCheckUserCmdAuthorities(tmp);
 802 chuck        1.51 #endif
 803 kumpf        1.79 
 804 kumpf        1.26 }
 805                   
 806                   String System::getPrivilegedUserName()
 807                   {
 808                       static String userName = String::EMPTY;
 809                   
 810                       if (userName == String::EMPTY)
 811                       {
 812                           struct passwd*   pwd = NULL;
 813 kumpf        1.66 #if defined(PEGASUS_OS_SOLARIS) || \
 814                       defined(PEGASUS_OS_HPUX) || \
 815                       defined(PEGASUS_OS_LINUX)
 816                           const unsigned int PWD_BUFF_SIZE = 1024;
 817 kumpf        1.79         struct passwd   local_pwd;
 818                           char            buf[PWD_BUFF_SIZE];
 819                   
 820                           if(getpwuid_r(0, &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0)
 821                           {
 822                               String errorMsg = String("getpwuid_r failure : ") +
 823                                               String(strerror(errno));
 824                               Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 825                                                     errorMsg);
 826                               // L10N TODO - This message needs to be added.
 827                               //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 828                               //                      errorMsg);
 829                           }
 830 keith.petley 1.62 #else
 831 kumpf        1.26         //
 832                           //  get the privileged user's UID.
 833                           //
 834 kumpf        1.79         //  (on OS/400, this is QSECOFR)
 835 kumpf        1.26         pwd = getpwuid(0);
 836 keith.petley 1.62 #endif
 837 kumpf        1.26         if ( pwd != NULL )
 838                           {
 839 chuck        1.65 #if defined(PEGASUS_OS_OS400)
 840 kumpf        1.79             EtoA(pwd->pw_name);
 841 chuck        1.65 #endif
 842 kumpf        1.26             //
 843                               //  get the user name
 844                               //
 845                               userName.assign(pwd->pw_name);
 846                           }
 847                           else
 848                           {
 849 kumpf        1.79             Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4,
 850                                          "Could not find entry.");
 851 kumpf        1.26             PEGASUS_ASSERT(0);
 852                           }
 853                       }
 854                   
 855                       return (userName);
 856 mike         1.21 }
 857 kumpf        1.22 
 858 kumpf        1.81 Boolean System::isGroupMember(const char* userName, const char* groupName)
 859                   {
 860                       struct group                        grp;
 861                       char                                *member;
 862                       Boolean                             retVal = false;
 863                       const unsigned int                  PWD_BUFF_SIZE = 1024;
 864                       const unsigned int                  GRP_BUFF_SIZE = 1024;
 865                       struct passwd                       pwd;
 866                       struct passwd                       *result;
 867                       struct group                        *grpresult;
 868                       char                                pwdBuffer[PWD_BUFF_SIZE];
 869                       char                                grpBuffer[GRP_BUFF_SIZE];
 870                   
 871                       //
 872                       // Search Primary group information.
 873                       //
 874                   
 875                       // Find the entry that matches "userName"
 876                   
 877                       if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
 878                       {
 879 kumpf        1.81         String errorMsg = String("getpwnam_r failure : ") +
 880                                               String(strerror(errno));
 881                           Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 882                                                     errorMsg);
 883                           Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 884                                                     errorMsg);
 885                           throw InternalSystemError();
 886                       }
 887                   
 888                       if ( result != NULL )
 889                       {
 890                           // User found, check for group information.
 891                           gid_t           group_id;
 892                           group_id = pwd.pw_gid;
 893                   
 894                           // Get the group name using group_id and compare with group passed.
 895                           if ( getgrgid_r(group_id, &grp,
 896                                    grpBuffer, GRP_BUFF_SIZE, &grpresult) != 0)
 897                           {
 898                               String errorMsg = String("getgrgid_r failure : ") +
 899                                                    String(strerror(errno));
 900 kumpf        1.81             Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 901                                                         errorMsg);
 902                               Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 903                                                     errorMsg);
 904                               throw InternalSystemError();
 905                           }
 906                   
 907                           // Compare the user's group name to groupName.
 908                           if ( strcmp (grp.gr_name, groupName) == 0 )
 909                           {
 910                                // User is a member of the group.
 911                                return true;
 912                           }
 913                       }
 914                   
 915                       //
 916                       // Search supplemental groups.
 917                       // Get a user group entry
 918                       //
 919                       if ( getgrnam_r(groupName, &grp,
 920                                 grpBuffer, GRP_BUFF_SIZE, &grpresult) != 0 )
 921 kumpf        1.81     {
 922                           String errorMsg = String("getgrnam_r failure : ") +
 923                                               String(strerror(errno));
 924                           Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2,
 925                                                     errorMsg);
 926                           Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
 927                                                     errorMsg);
 928                           throw InternalSystemError();
 929                       }
 930                   
 931                       // Check if the requested group was found.
 932                       if (grpresult == NULL)
 933                       {
 934                           return false;
 935                       }
 936                   
 937                       Uint32 j = 0;
 938                   
 939                       //
 940                       // Get all the members of the group
 941                       //
 942 kumpf        1.81     member = grp.gr_mem[j++];
 943                   
 944                       while (member)
 945                       {
 946                           //
 947                           // Check if the user is a member of the group
 948                           //
 949                           if ( strcmp(userName, member) == 0 )
 950                           {
 951                               retVal = true;
 952                               break;
 953                           }
 954                           member = grp.gr_mem[j++];
 955                       }
 956                   
 957                       return retVal;
 958                   }
 959                   
 960 kumpf        1.22 Uint32 System::getPID()
 961                   {
 962                       //
 963                       // Get the Process ID
 964                       //
 965                       Uint32 pid = getpid();
 966                   
 967                       return pid;
 968                   }
 969 mike         1.28 
 970                   Boolean System::truncateFile(
 971                       const char* path, 
 972                       size_t newSize)
 973                   {
 974 chuck        1.44 #if !defined(PEGASUS_OS_OS400)
 975 kumpf        1.29     return (truncate(path, newSize) == 0);
 976 chuck        1.44 #else
 977 chuck        1.65     OS400_PNSTRUCT pathname;
 978                       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
 979                       pathname.qlg_struct.CCSID = 1208;
 980                   #pragma convert(37)
 981                       memcpy(pathname.qlg_struct.Country_ID,"US",2);
 982                       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
 983                   #pragma convert(0)
 984                       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
 985                       pathname.qlg_struct.Path_Length = strlen(path);
 986                       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
 987                       pathname.pn = (char *)path;
 988                   
 989                       int fd = QlgOpen((Qlg_Path_Name_T *)&pathname, O_WRONLY);
 990 chuck        1.44     if (fd != -1)
 991                       {
 992                          int rc = ftruncate(fd, newSize);
 993                          close(fd);
 994                          return (rc == 0);
 995                       }
 996                       
 997                       return false;
 998                   #endif
 999 mike         1.28 }
1000 tony         1.52 
1001                   // Is absolute path?
1002                   Boolean System::is_absolute_path(const char *path)
1003                   {
1004                     if (path == NULL)
1005                       return false;
1006                     
1007                     if (path[0] == '/')
1008                       return true;
1009                     
1010                     return false;
1011                   }
1012 david        1.54 
1013 kumpf        1.72 // Changes file permissions on the given file.
1014                   Boolean System::changeFilePermissions(const char* path, mode_t mode)
1015                   {
1016                       Sint32 ret = 0;
1017                   
1018                       const char * tmp = path;
1019                   
1020                   #if defined(PEGASUS_OS_OS400)
1021                       // ATTN: Update this code to handle UTF8 when path contains UTF8
1022                       AtoE((char *)tmp);
1023                   #endif
1024                   
1025                       ret = ::chmod(tmp, mode);
1026                   
1027                       return ( ret != -1 );
1028                   }
1029                   
1030 david        1.54 void System::openlog(const String ident)
1031                   {
1032 kumpf        1.77 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
1033 kumpf        1.56     // ATTN: Hard-code the "cimserver" identifier until the infrastructure
1034                       // is set up to pass this as the "ident" string.
1035                       //::openlog(ident.getCString(), LOG_PID|LOG_CONS, LOG_DAEMON);
1036 kumpf        1.69     ::openlog("cimserver", LOG_PID, LOG_DAEMON);
1037 david        1.54 
1038                   #endif
1039                   
1040                       return;
1041                   }
1042                   
1043                   void System::syslog(Uint32 severity, const char *data)
1044                   {
1045 kumpf        1.77 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
1046 david        1.54 
1047                       // FUTURE-SF-P3-20020517 : Use the Syslog on HP-UX. Eventually only 
1048                       // certain messages will go to the Syslog and others to the 
1049                       // Pegasus Logger.
1050                       Uint32 syslogLevel = LOG_DEBUG;
1051                   
1052                       // Map the log levels.
1053                       if (severity & Logger::TRACE) syslogLevel =       LOG_DEBUG;
1054                       if (severity & Logger::INFORMATION) syslogLevel = LOG_INFO;
1055                       if (severity & Logger::WARNING) syslogLevel =     LOG_WARNING;
1056                       if (severity & Logger::SEVERE) syslogLevel =      LOG_ERR;
1057                       if (severity & Logger::FATAL) syslogLevel =       LOG_CRIT;
1058                   
1059 david        1.55     ::syslog(syslogLevel, "%s", data);
1060 david        1.54 
1061                   #elif defined(PEGASUS_OS_OS400)
1062                   
1063                       std::string replacementData = data;
1064                       // All messages will go to the joblog. In the future
1065                       // some messages may go to other message queues yet
1066                       // to be determined.
1067                       if ((severity & Logger::TRACE) ||
1068                   	(severity & Logger::INFORMATION))
1069                       {
1070                   
1071                   	// turn into ycmMessage so we can put it in the job log
1072 chuck        1.65 #pragma convert(37)
1073 david        1.67 	ycmMessage theMessage("CPIDF80",
1074                   			          data,
1075                                                 strlen(data),
1076                   			          "Logger",
1077                                                 ycmCTLCIMID,
1078 david        1.68 			          TRUE);
1079 chuck        1.65 #pragma convert(0)
1080 david        1.54 
1081                   	// put the message in the joblog
1082                   	theMessage.joblogIt(UnitOfWorkError,
1083                   			    ycmMessage::Informational);
1084                       }
1085                   
1086                       if ((severity & Logger::WARNING) ||
1087                   	(severity & Logger::SEVERE)  ||
1088                   	(severity & Logger::FATAL))
1089                       {
1090                   	// turn into ycmMessage so we can put it in the job log
1091 chuck        1.65 #pragma convert(37)
1092 david        1.67 	ycmMessage theMessage("CPDDF82",
1093                   			          data,
1094                                                 strlen(data),
1095                   			          "Logger",
1096                                                 ycmCTLCIMID,
1097 david        1.68 			          TRUE);
1098 chuck        1.65 #pragma convert(0)
1099 david        1.54 	// put the message in the joblog
1100                   	theMessage.joblogIt(UnitOfWorkError,
1101                   			    ycmMessage::Diagnostic);
1102                       }
1103                   
1104                   #endif
1105                   
1106                       return;
1107                   }
1108                   
1109                   void System::closelog()
1110                   {
1111 kumpf        1.77 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
1112                    
1113 david        1.55     ::closelog();
1114 david        1.54 
1115                   #endif
1116                   
1117                       return;
1118                   }
1119                   
1120                   // System ID constants for Logger::put and Logger::trace
1121                   #if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
1122                   const String System::CIMSERVER = "qycmcimom";  // Server system ID
1123                   #else
1124                   const String System::CIMSERVER = "cimserver";  // Server system ID
1125                   #endif
1126 mike         1.21     
1127 mike         1.19 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2