(file) Return to CMPI_BrokerExt.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

File: [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI / CMPI_BrokerExt.cpp (download)
Revision: 1.10, Sun Oct 17 19:40:01 2004 UTC (19 years, 8 months ago) by karl
Branch: MAIN
CVS Tags: pegasus25BeforeLicenseUpdate, SLPPERFINST-root, SLPPERFINST-branch, RELEASE_2_4_1-BETA3, RELEASE_2_4_1-BETA2, RELEASE_2_4_1-BETA1, RELEASE_2_4_1, RELEASE_2_4_0-RC3, RELEASE_2_4_0-RC2, RELEASE_2_4_0, RELEASE_2_4-root, PEP213_SIZE_OPTIMIZATIONS, IBM_241_April1405, CHUNKTESTDONE_PEP140
Branch point for: RELEASE_2_4-branch
Changes since 1.9: +7 -5 lines
BUG#: 2196
TITLE: Copyright update

DESCRIPTION: Update all .cpp and .h files for new license and
update the doc/license.txt file.  Note that there were also
a couple of files that had to be fixed because they had violated
the comments rules (ex. blank line at head of file or in the case of
xmlwriter.cpp a comment line //=========  which drove the strip
function nuts.  These were fixed.  This has been compiled and tested
on windows.

//%2004////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation, The Open Group.
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
// Author:      Adrian Schuur, schuur@de.ibm.com
//
// Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1917
//
//%/////////////////////////////////////////////////////////////////////////////

#include "CMPI_Version.h"

#include "CMPI_Object.h"
#include "CMPI_Broker.h"
#include "CMPI_Ftabs.h"
#include "CMPI_String.h"
#include "CMPI_SelectExp.h"

#include <Pegasus/Common/CIMName.h>
#include <Pegasus/Common/CIMPropertyList.h>
#include <Pegasus/ProviderManager2/ProviderManager.h>
#include <Pegasus/Common/Thread.h>
#include <Pegasus/Common/AutoPtr.h>

#if defined (CMPI_VER_85)
  #include <Pegasus/Common/MessageLoader.h>
#endif

#include <stdarg.h>
#include <string.h>

#if defined(CMPI_PLATFORM_WIN32_IX86_MSVC)
  #include <sys/timeb.h>
#endif

PEGASUS_USING_STD;
PEGASUS_NAMESPACE_BEGIN

extern "C" {
	struct thrd_data {
	   CMPI_THREAD_RETURN(CMPI_THREAD_CDECL*pgm)(void*);
	   void *parm;
	};
}

static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL start_driver(void *parm)
{
   Thread* my_thread = (Thread*)parm;
   thrd_data *pp = (thrd_data*)my_thread->get_parm();
   thrd_data data=*pp;
   delete pp;

   return (PEGASUS_THREAD_RETURN)(data.pgm)(data.parm);
}

extern "C" {

   static char *resolveFileName (const char *filename)
   {
      String pn=ProviderManager::_resolvePhysicalName(filename);
      CString n=pn.getCString();
      return strdup((const char*)n);
   }

   static CMPI_THREAD_TYPE newThread
         (CMPI_THREAD_RETURN (CMPI_THREAD_CDECL *start )(void *), void *parm, int detached)
   {
      AutoPtr<thrd_data> data(new thrd_data());
      data->pgm=(CMPI_THREAD_RETURN (CMPI_THREAD_CDECL *)(void*))start;
      data->parm=parm;

      Thread *t=new Thread(start_driver,data.get(),detached==1);
      data.release();
      t->run();
      return (CMPI_THREAD_TYPE)t;
   }



   static int joinThread (CMPI_THREAD_TYPE thread, CMPI_THREAD_RETURN *returnCode)
   {
      ((Thread*)thread)->join();
      *returnCode=(CMPI_THREAD_RETURN)((Thread*)thread)->get_exit();
      return 0;
   }

   static int exitThread(CMPI_THREAD_RETURN return_code)
   {
      Thread::getCurrent()->exit_self((PEGASUS_THREAD_RETURN)return_code);
      return 0;
   }

   static int cancelThread(CMPI_THREAD_TYPE thread)
   {
      ((Thread*)thread)->cancel();
      return 0;
   }

   static int threadSleep(CMPIUint32 msec)
   {
      Thread::getCurrent()->sleep(msec);
      return 0;
   }

   static int threadOnce (int *once, void (*init)(void))
   {
      if (*once==0) {
         *once=1;
         (init)();
      }
      return *once;
   }


   static int createThreadKey(CMPI_THREAD_KEY_TYPE *key, void (*cleanup)(void*))
   {
      return pegasus_key_create((PEGASUS_THREAD_KEY_TYPE*)key);
   }

   static int destroyThreadKey(CMPI_THREAD_KEY_TYPE key)
   {
      return pegasus_key_delete(key);
   }

   static void *getThreadSpecific(CMPI_THREAD_KEY_TYPE key)
   {
      return pegasus_get_thread_specific(key);
   }

   static  int setThreadSpecific(CMPI_THREAD_KEY_TYPE key, void * value)
   {
      return pegasus_set_thread_specific(key,value);
   }


   static CMPI_MUTEX_TYPE newMutex (int opt)
   {
      Mutex *m=new Mutex();
      return m;
   }

   static void destroyMutex (CMPI_MUTEX_TYPE m)
   {
      delete ((Mutex*)m);
   }

   static void lockMutex (CMPI_MUTEX_TYPE m)
   {
      ((Mutex*)m)->lock(pegasus_thread_self());
   }

   static void unlockMutex (CMPI_MUTEX_TYPE m)
   {
      ((Mutex*)m)->unlock();
   }



   static CMPI_COND_TYPE newCondition (int opt)
   {
      Condition *c=new Condition();
      return c;
   }

   static void destroyCondition (CMPI_COND_TYPE c)
   {
      delete (Condition*)c;
   }

   static int condWait (CMPI_COND_TYPE c, CMPI_MUTEX_TYPE m)
   {
      // need to take care of mutex
      ((Condition*)c)->unlocked_wait(Thread::getCurrent()->self());
      return 0;
   }

   static int timedCondWait(CMPI_COND_TYPE c, CMPI_MUTEX_TYPE m, struct timespec *wait)
   {

   /* this is not truely mapping to pthread_timed_wait
      but will work for the time beeing
   */
      int msec;
      struct timespec next=*wait;

   #if defined(CMPI_PLATFORM_WIN32_IX86_MSVC)
      struct timeval {
         long tv_sec;
         long tv_usec;
      }now;
      struct _timeb timebuffer;

      _ftime( &timebuffer );
      now.tv_sec=timebuffer.time;
      now.tv_usec=timebuffer.millitm*1000;
   #else
      struct timeval now;
      gettimeofday(&now, NULL);
   #endif

      if (next.tv_nsec>1000000000) {
         next.tv_sec+=next.tv_nsec/1000000000;
         next.tv_nsec=next.tv_nsec%1000000000;
      }
      msec=(next.tv_sec-now.tv_sec)*1000;
      msec+=(next.tv_nsec/1000000)-(now.tv_usec/1000);

      Thread::getCurrent()->sleep(msec);
      return 0;
   }


   static int signalCondition(CMPI_COND_TYPE cond)
   {
      ((Condition*)cond)->signal(Thread::getCurrent()->self());
      return 0;
   }

}

static CMPIBrokerExtFT brokerExt_FT={
     CMPICurrentVersion,
     resolveFileName,

     newThread,
     joinThread,
     exitThread,
     cancelThread,
     threadSleep,
     threadOnce,

     createThreadKey,
     destroyThreadKey,
     getThreadSpecific,
     setThreadSpecific,

     newMutex,
     destroyMutex,
     lockMutex,
     unlockMutex,

     newCondition,
     destroyCondition,
     condWait,
     timedCondWait,
     signalCondition                       // Signal not supported yet
};

CMPIBrokerExtFT *CMPI_BrokerExt_Ftab=&brokerExt_FT;


PEGASUS_NAMESPACE_END




No CVS admin address has been configured
Powered by
ViewCVS 0.9.2