Exemplo n.º 1
0
int remove_indicationObject (void *obj, CMPIUint32 ctx_id)
{
    ind_object **tmp;
    indication_objects *curr;
    CMPIUint64 id = ( (ind_object*)obj)->id;

    TRACE_NORMAL(("Deleting Indication Object."));

    INIT_LOCK(_indication_objects_lock);
    CMPI_BrokerExt_Ftab->lockMutex(_indication_objects_lock);
    curr = __indication_objects;
    while (curr)
    {
        if (curr->ctx_id == ctx_id)
        {
            break;
        }
        curr = curr->next;
    }
    for (tmp = &curr->objects; *tmp != NULL; *tmp = (*tmp)->next)
    {
        if ((*tmp)->id == id)
        {
            ind_object *r = (*tmp);
            (*tmp) = r->next;
            __free_ind_object (r);
            TRACE_INFO(("Deleted Indication Object with ID: %llu", id));
            CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);
            return 0;
        }
    }
    CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);
    return -1;
}
Exemplo n.º 2
0
static CMPIStatus TCPCOMM_IndicationMI_deActivateFilter(provider_address * addr,
        RemoteCMPIIndicationMI * cThis,
        CMPIContext * context,
        CMPIResult * result,
        CMPIObjectPath * cop,
        CMPISelectExp * filter,
        const char *indType,
        CMPIBoolean lastActivation)
#endif
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    (__sft)->serialize_CMPISelectExp(socket, filter);
    (__sft)->serialize_string(socket, indType);
    (__sft)->serialize_UINT8(socket, lastActivation);
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
#ifndef CMPI_VER_100
        socketcomm_array2result(r, result);
#endif
        return rc;
    };
};
provider_address * resolve_instance ( 
    CONST CMPIBroker * broker,
    CONST CMPIContext * ctx, 
    CONST CMPIObjectPath * cop, 
    const char * provider, 
    CMPIStatus * rc)
{
    CMPIStatus irc;
    const char *ip;
    provider_address *a = NULL;

    CMPIData info = CMGetContextEntry(ctx,"CMPIRRemoteInfo",&irc);

    if (irc.rc == CMPI_RC_OK)
    {
        ip = CMGetCharsPtr(info.value.string,&irc);
        switch (ip[1])
        {
            case '0':
                a = outofprocess_resolver(broker,provider);
                break;
            case '1':
                a = namespace_resolver(broker,provider,ip+3);
                break;
        }
    }

    TRACE_NORMAL(("Resolve requested for provider: %s", provider ));
    if (rc) 
    {
        *rc = irc;
    }
    return a;
}
Exemplo n.º 4
0
static CMPIStatus TCPCOMM_AssociationMI_references(provider_address * addr,
        RemoteCMPIAssociationMI * cThis,
        CONST CMPIContext * context,
        CONST CMPIResult * result,
        CONST CMPIObjectPath * cop,
        const char *assocclass,
        const char *role,
        CONST char **props)
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    (__sft)->serialize_string(socket, assocclass);
    (__sft)->serialize_string(socket, role);
    socketcomm_serialize_props(socket, (__sft), (char **)props);
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
        socketcomm_array2result(r, result);
        return rc;
    };
}
Exemplo n.º 5
0
static CMPIStatus TCPCOMM_InstanceMI_deleteInstance(provider_address * addr,
        RemoteCMPIInstanceMI * cThis,
        CONST CMPIContext * context,
        CONST CMPIResult * result,
        CONST CMPIObjectPath * cop)
{
    int socket;
    unsigned long int ctxid = save_context(context);
    TRACE_NORMAL(("Executing remote MI call."));
    CMAddContextEntry(context, RCMPI_CTX_ID, &ctxid, CMPI_uint32);
    socket = __provider_connect(addr, cThis->provider, &cThis->ticket,
                                __FUNCTION__, context, cop);
    if (socket < 0)
        CMReturnWithString(CMPI_RC_ERR_FAILED,connect_error(addr));
    {
        CMPIStatus rc;
        CMPIArray *r;
        rc = (__sft)->deserialize_CMPIStatus(socket, cThis->broker);
        r = (__sft)->deserialize_CMPIArray(socket, cThis->broker);
        close(socket);
        remove_context(ctxid);
        socketcomm_array2result(r, result);
        return rc;
    };
}
Exemplo n.º 6
0
void socketcomm_deserialize_context ( int socket,
				      const struct BinarySerializerFT * sft,
				      CONST CMPIBroker * broker,
				      CONST CMPIContext * ctx )
{
	unsigned int size;

	size = sft->deserialize_UINT32 ( socket );

	TRACE_NORMAL(("deserializing context with %d entries", size ));

	while ( size-- ) {
		CMPIString * entryName =
			sft->deserialize_CMPIString ( socket, broker );
		CMPIData entry =
			sft->deserialize_CMPIData ( socket, broker );
		CMPIType type =
			( entry.state & CMPI_nullValue )?
			CMPI_null: entry.type;

		TRACE_INFO(("adding entryName: %s", CMGetCharsPtr ( entryName, NULL ) ));

		CMAddContextEntry ( ctx,
				    CMGetCharsPtr ( entryName, NULL ),
				    &entry.value,
				    type );
	}
}
Exemplo n.º 7
0
void socketcomm_copy_args ( CMPIArgs * src, CMPIArgs * dst )
{
	unsigned int i,arg_count;

	TRACE_NORMAL(("Copying CMPIArgs."));

	arg_count = CMGetArgCount ( src, NULL );

	TRACE_INFO(("arg count: %d", arg_count ));

	for ( i = 0; i < arg_count; i++ ) {

		CMPIString * argName;
		CMPIData data = CMGetArgAt ( src, i, &argName, NULL );

		TRACE_INFO(("arg:\nname: %s\ntype: 0x%x\nstate: 0x%x.",
			    CMGetCharsPtr ( argName, NULL ),
			    data.type, data.state ));

		if ( data.state & CMPI_nullValue ) {
			CMAddArg ( dst,
				   CMGetCharsPtr ( argName, NULL ),
				   NULL,
				   CMPI_null );
		} else CMAddArg ( dst,
				  CMGetCharsPtr ( argName, NULL ),
				  &data.value,
				  data.type );
	}
}
Exemplo n.º 8
0
/*!
  The function maintains a list of previously loaded comm-layers locally.
  A mutex is used to ensure proper access to this list. If a comm-layer
  cannot be found within the list, it is being loaded and inserted at
  the begininng.

  \param comm_id the name of the communication layer to be looked up.
  \param broker broker handle as passed to the init function.
  \param ctx context as passed to the init function.

  \return the comm-layer matching the id or NULL if it cannot be loaded.
 */
provider_comm * load_provider_comm ( const char * comm_id,
				     CONST CMPIBroker * broker,
				     CONST CMPIContext * ctx )
{
	provider_comm * tmp;

	TRACE_VERBOSE(("entered function."));
	TRACE_NORMAL(("loading remote communication layer: %s", comm_id ));

        INIT_LOCK(__mutex);
        CMPI_BrokerExt_Ftab->lockMutex(__mutex);

	for ( tmp = __comm_layers; tmp != NULL; tmp = tmp->next ) {

		if ( strcmp ( tmp->id, comm_id ) == 0 ) {
                        CMPI_BrokerExt_Ftab->unlockMutex(__mutex);

			TRACE_INFO(("found previously loaded comm-layer."));
			TRACE_VERBOSE(("leaving function."));
			return tmp;
		}
	}

	tmp = load_comm_library ( comm_id, broker, ctx );

	if ( tmp != NULL ) {
		tmp->next     = __comm_layers;
		__comm_layers = tmp;
	}

        CMPI_BrokerExt_Ftab->unlockMutex(__mutex);

	TRACE_VERBOSE(("leaving function."));
  	return tmp;
}
Exemplo n.º 9
0
/*!
  The function maintains a list of previously loaded comm-layers locally.
  A mutex is used to ensure proper access to this list. If a comm-layer
  is found within the list, it is being unloaded.

  \param comm_id the name of the communication layer to be looked up.
  \param broker broker handle as passed to the init function.
  \param ctx context as passed to the cleanup function.

 */
void unload_provider_comms ( void )
{
	provider_comm * tmp;
	provider_comm * next;
	TRACE_VERBOSE(("entered function."));
	TRACE_NORMAL(("unloading remote communication layers"));

        INIT_LOCK(__mutex);
        CMPI_BrokerExt_Ftab->lockMutex(__mutex);

	for ( tmp = __comm_layers; tmp != NULL; tmp = next ) {
		TRACE_INFO(("unloading comm-layer: %s.", tmp->id));
		next = tmp->next;
	    	// IBMKR: Call the cleanup function of comm library.
	    	tmp->terminate();
		// IBMKR: free the library name.
		free (tmp->id); tmp->id = 0;
		unload_comm_library(tmp);
	}

	__comm_layers = NULL;
        CMPI_BrokerExt_Ftab->unlockMutex(__mutex);

	TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 10
0
/*!
  The function unloads "lib<id>.so".

  \param id comm the provider_comm structure that can be unloaded

 */
static void unload_comm_library ( provider_comm * comm )
{
	TRACE_VERBOSE(("entered function."));
	TRACE_NORMAL(("unloading comm-layer library: %s", comm->id));

	_unload_lib ( comm->handle );

	TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 11
0
provider_address * resolve_class ( 
    CONST CMPIBroker * broker,
    CONST CMPIContext * ctx, 
    CONST CMPIObjectPath * cop, 
    const char * provider, 
    CMPIStatus * rc)
{
    TRACE_NORMAL(("Resolve requested for provider: %s", provider ));
    return resolve_instance ( broker, ctx, cop, provider, rc );
}
Exemplo n.º 12
0
static CMPIStatus
TCPCOMM_cleanup()
{
    CMPIStatus rc = {CMPI_RC_OK,NULL};

    TRACE_NORMAL(("Closing connections."));
    rc.rc = close_connection(CIMOM_LISTEN_PORT);
    cleanup_context();
    return rc;
}
Exemplo n.º 13
0
static CMPIInstance * __beft_newInstance ( 
    CONST CMPIBroker * broker,
    CONST CMPIObjectPath * cop,
    CMPIStatus * rc )
{
    CMPIStatus rc1 = checkArgsReturnStatus(cop);
    if (rc1.rc != CMPI_RC_OK)
    {
        CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
        return 0;
    }
    TRACE_NORMAL(("Creating new native CMPIInstance."));
    return native_new_CMPIInstance ( cop, rc );
}
Exemplo n.º 14
0
/*!
  The function tries to load "lib<id>.so" looking for an entry point
  "<id>_InitCommLayer". The latter one is called to obtain a provider_comm
  structure including the function pointer table for MI calls towards
  remote providers.

  \param id the name of the comm-layer for which the library has to be loaded.
  \param broker broker handle as passed to the init function.
  \param ctx context as passed to the init function.

  \return pointer to the provider_comm structure from the comm-layer, or NULL.
 */
static provider_comm * load_comm_library ( const char * id,
					   CONST CMPIBroker * broker,
					   CONST CMPIContext * ctx )
{
	void * hLibrary;
    CMPIStatus rc = {CMPI_RC_OK, NULL};

	TRACE_VERBOSE(("entered function."));
	TRACE_NORMAL(("loading comm-layer library: lib%s.so", id));

	hLibrary = _load_lib ( id );

	if ( hLibrary != NULL ) {
		char function[255];
		INIT_COMM_LAYER fp;
		sprintf ( function, "%s_InitCommLayer", id );
#ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
		fp = (INIT_COMM_LAYER) dllqueryfn ( (dllhandle *) hLibrary, function );
#else
		fp = (INIT_COMM_LAYER) dlsym ( hLibrary, function );
#endif

		if ( fp != NULL ) {
			provider_comm * result = fp ( broker, ctx );
			result->id = strdup ( id );
			result->handle = hLibrary;

			TRACE_INFO(("comm-layer successfully initialized."));
			TRACE_VERBOSE(("leaving function."));
			return result;
		}
#ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
		dllfree ( (dllhandle*) hLibrary );
#else
		dlclose ( hLibrary );
#endif
	}
#ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
	error_at_line ( 0, errno, __FILE__, __LINE__,
			"Unable to load/init communication-layer library.");
#else
	error_at_line ( 0, 0, __FILE__, __LINE__,
			"Unable to load/init communication-layer library: %s",
			dlerror () );
#endif
	TRACE_VERBOSE(("leaving function."));
	return NULL;
}
Exemplo n.º 15
0
void* get_indicationObject (CMPIUint64 id, CMPIUint32 ctx_id)
{
    indication_objects *curr;
    ind_object *tmp;
    int global_context = 0;

    TRACE_NORMAL(("Getting the  Indication Object."));

    INIT_LOCK(_indication_objects_lock);
    CMPI_BrokerExt_Ftab->lockMutex(_indication_objects_lock);

    do
    {
        curr = __indication_objects;
        while (curr)
        {
            if (curr->ctx_id == ctx_id)
            {
                break;
            }
            curr = curr->next;
        }
        if (!curr && !global_context)
        {
            global_context = 1;
            ctx_id = PEGASUS_INDICATION_GLOBAL_CONTEXT;
        }
        else
        {
            break;
        }
    }while (global_context);

    for (tmp = curr ? curr->objects : NULL; tmp != NULL; tmp = tmp->next)
    {
        if (tmp->id == id)
        {
            TRACE_INFO(("Got the Indication Object with ID: %llu", id));
            CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);
            return tmp->ptr;
        }
    }
    CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);

    return NULL;

}
Exemplo n.º 16
0
/*
    This function creates reference to the Object created in MB.
    This reference is passed to Remote Daemon, any changes or any
    calls made on this object on daemon side, will make UP calls
    to MB and uses this object.
*/
CMPIUint64 create_indicationObject (
    void *obj,
    CMPIUint32 ctx_id,
    CMPIUint8 type)
{
    indication_objects *tmp;
    ind_object *ind_obj;

    TRACE_NORMAL(("Creating Indication Object."));

    INIT_LOCK(_indication_objects_lock);
    CMPI_BrokerExt_Ftab->lockMutex(_indication_objects_lock);

    tmp = __indication_objects;
    while (tmp)
    {
        if (tmp->ctx_id == ctx_id)
        {
            break;
        }
        tmp = tmp->next;
    }
    if (!tmp)
    {
        tmp = (indication_objects *)
        malloc ( sizeof ( indication_objects ) );
        tmp->ctx_id = ctx_id;
        tmp->next = __indication_objects;
        __indication_objects = tmp;
        tmp->objects = NULL;
    }
    ind_obj = (ind_object*) malloc ( sizeof ( ind_object ) );
    ind_obj->id = (ssize_t) obj;
    ind_obj->ptr = obj;
    ind_obj->type = type;
    ind_obj->next = tmp->objects;
    tmp->objects = ind_obj;

    CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);

    TRACE_INFO(("Created object with id: %llu", ind_obj->id ));

    return ind_obj->id;
}
Exemplo n.º 17
0
/*!
    The function tries to load "lib<id>.so" looking for an entry point
    "<id>_InitCommLayer". The latter one is called to obtain a provider_comm
    structure including the function pointer table for MI calls towards
    remote providers.

    \param id the name of the comm-layer for which the library has to be loaded.
    \param broker broker handle as passed to the init function.
    \param ctx context as passed to the init function.

    \return pointer to the provider_comm structure from the comm-layer, or NULL.
*/
static provider_comm * load_comm_library (
    const char * id,
    CONST CMPIBroker * broker,
    CONST CMPIContext * ctx )
{
    void * hLibrary;
    char function[255];
    CMPIStatus rc = {CMPI_RC_OK, NULL};

    TRACE_VERBOSE(("entered function."));
    TRACE_NORMAL(("loading comm-layer library: lib%s.so", id));

    hLibrary = _load_lib ( id );

    if (hLibrary != NULL)
    {
        INIT_COMM_LAYER fp;
        sprintf ( function, "%s_InitCommLayer", id );
        //invokes dlsym on unix and GetProcAddress on windows
        fp = (INIT_COMM_LAYER)PEGASUS_CMPIR_GETPROCADDRESS(hLibrary,function);
        if (fp != NULL)
        {
            provider_comm * result = fp(broker, ctx);
            result->id = strdup ( id );
            result->handle = hLibrary;

            TRACE_INFO(("comm-layer successfully initialized."));
            TRACE_VERBOSE(("leaving function."));
            return result;
        }
        //invokes dlfree call on unix and FreeLibrary on windows
        PEGASUS_CMPIR_FREELIBRARY( hLibrary );
    }
    error_at_line (
        0,
        errno,
        __FILE__,
        __LINE__,
        "Unable to load/init communication-layer library.%s Error",
        id);
    TRACE_VERBOSE(("leaving function."));
    return NULL;
}
Exemplo n.º 18
0
/*!
  The function evaluates the up-call context id to set up
  the basic entities broker and context, before actually
  spawning a separate thread to handle the request.

  \param socket the connection socket.
  \param broker the broker to forward the request to.

  \sa __dispatch_MB_function
  \sa __verify_MB_call
 */
static void __handle_MB_call(int socket, CONST CMPIBroker * broker)
{
    CONST CMPIContext *ctx;

    struct accept_thread *athread = (struct accept_thread *)
                                    malloc(sizeof(struct accept_thread));

    TRACE_VERBOSE(("entered function."));
    TRACE_NORMAL(("handling incoming broker service request."));

    ctx = get_context(__sft->deserialize_UINT32(socket));

    athread->socket = socket;
    athread->broker = broker;
    athread->context = CBPrepareAttachThread(broker, ctx);

    CMPI_BrokerExt_Ftab->newThread((void*(*)(void*))__dispatch_MB_function,athread,1);

    TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 19
0
void cleanup_indicationObjects (CMPIUint32 ctx_id)
{
    indication_objects *tmp, *prev;
    ind_object *obj;

    TRACE_NORMAL(("Cleaning all Indication Objects."));

    INIT_LOCK(_indication_objects_lock);
    CMPI_BrokerExt_Ftab->lockMutex(_indication_objects_lock);
    tmp = __indication_objects;
    while (tmp)
    {
        if (tmp->ctx_id == ctx_id)
        {
            break;
        }
        prev = tmp;
        tmp = tmp->next;
    }
    if (!tmp)
    {
        TRACE_CRITICAL(("Indication context id (%u) not found.", ctx_id));
        return;
    }
    while (tmp->objects)
    {
        obj = tmp->objects;
        tmp->objects = tmp->objects->next;
        __free_ind_object (obj);
    }
    if (tmp == __indication_objects)
    {
        __indication_objects = __indication_objects->next;
    }
    else
    {
        prev->next = tmp->next;
    }
    free (tmp);
    CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);
}
Exemplo n.º 20
0
/*!
  The function evaluates the up-call ticket, retrieves the appropriate
  broker handle, and passes on the request to __handle_MB_call(), if
  successful.

  \param socket the connection socket.
 */
static void __verify_MB_call(int socket)
{
    comm_ticket ticket;
    CONST CMPIBroker *broker;

    TRACE_VERBOSE(("entered function."));
    TRACE_NORMAL(("handling incoming broker service request."));

    io_read_fixed_length(socket, &ticket, sizeof(comm_ticket));
    broker = verify_ticket(&ticket);

    if (broker == NULL) {

        TRACE_CRITICAL(("ticket invalid, could not obtain a broker"
                        " handle."));
        // return bad status.
        close(socket);

    } else
        __handle_MB_call(socket, broker);

    TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 21
0
/*!
  Since results from remote providers cannot be sent as CMPIResult directly,
  they are serialized using arrays, which can be transferred to the result
  using this method.

  \param array the source array.
  \param result the destination result.
 */
void socketcomm_array2result ( CMPIArray * array, CONST CMPIResult * result )
{
	TRACE_VERBOSE(("entered function."));

	if ( array != NULL && result != NULL ) {

		CMPICount size = CMGetArrayCount ( array, NULL );
		CMPICount i;

		TRACE_NORMAL(("Transferring %d array elements to CMPIResult.",
			      size));

		for ( i = 0; i < size; i++ ) {

			CMPIData data = CMGetArrayElementAt ( array, i, NULL );

			if ( data.type == CMPI_instance ) {

				TRACE_INFO(("transferring instance."));
				CMReturnInstance ( result, data.value.inst );
			} else if ( data.type == CMPI_ref ) {

				TRACE_INFO(("transferring object path."));
				CMReturnObjectPath ( result, data.value.ref );
			} else {

				TRACE_INFO(("transferring CMPIData."));
				CMReturnData ( result,
					       &data.value,
					       data.type );
			}
		}
	}

	TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 22
0
void socketcomm_serialize_context ( int socket,
				    const struct BinarySerializerFT * sft,
				    CONST CMPIContext * ctx )
{
	unsigned int size = CMGetContextEntryCount ( ctx, NULL ), i;

	TRACE_NORMAL(("serializing context with %d entries", size ));

	sft->serialize_UINT32 ( socket, size );

	for ( i = 0; i < size; i++ ) {
		CMPIString * entryName;
		CMPIData entry = CMGetContextEntryAt ( ctx,
						       i,
						       &entryName,
						       NULL );

		TRACE_INFO(("serializing entry(%d): %s",
			    i, CMGetCharsPtr ( entryName, NULL ) ));

		sft->serialize_CMPIString ( socket, entryName );
		sft->serialize_CMPIData ( socket, entry );
	}
}
Exemplo n.º 23
0
/*!
  This function is running in a separate thread and sets up the environment
  for the actual request handler before calling it. This comprises reading
  the function name and deserializing the calling context.

  \param athread contains socket, broker and context handles.

  \sa __mb_functions
  \sa __handle_MB_call
 */
static void __dispatch_MB_function(struct accept_thread *athread)
{
    char *function;
    unsigned int i;

    TRACE_VERBOSE(("entered function."));
    TRACE_NORMAL(("dispatching broker service function request."));

    CBAttachThread(athread->broker, athread->context);
    function =
        __sft->deserialize_string(athread->socket, athread->broker);

    socketcomm_deserialize_context(athread->socket,  __sft, athread->broker,
                                   athread->context);

    for (i = 0;
            i < sizeof(__mb_functions) / sizeof(struct socket_mb_function);
            i++) {

        if (strcmp(function, __mb_functions[i].name) == 0) {

            TRACE_INFO(("calling %s to handle request.",
                        __mb_functions[i].name));

            __mb_functions[i].function(athread->socket, athread->broker,
                                       athread->context);
            break;
        }
    }

    CBDetachThread(athread->broker, athread->context);
    close(athread->socket);
    free(athread);

    TRACE_VERBOSE(("leaving function."));
}
Exemplo n.º 24
0
char * value2Chars ( CMPIType type, CMPIValue * value )
{
    char str[256],*p;
    unsigned int size;
    CMPIString *cStr;
    TRACE_NORMAL(("value2string type 0x%x CMPIValue.", type));

    if (type & CMPI_ARRAY)
    {

//      TRACE_INFO(("serializing array object type."));
//      return __serialize_CMPIArray ( fd, value->array );

    }
    else if (type & CMPI_ENC)
    {

        TRACE_INFO(("trying to stringify encapsulated data type."));

        switch (type)
        {
            case CMPI_instance:
                break;

            case CMPI_ref:
                cStr=__oft_toString(value->ref,NULL);
                return strdup((char*)cStr->hdl);
                break;

            case CMPI_args:
                break;

            case CMPI_filter:
                break;

            case CMPI_string:
            case CMPI_numericString:
            case CMPI_booleanString:
            case CMPI_dateTimeString:
            case CMPI_classNameString:
                size=(unsigned int) strlen((char*)value->string->hdl);
                p=malloc(size+8);
                sprintf(p,"\"%s\"",(char*)value->string->hdl);
                return strdup(p);

            case CMPI_dateTime:
                break;

        }
        TRACE_CRITICAL(("non-supported encapsulated data type."));


    }
    else if (type & CMPI_SIMPLE)
    {

        TRACE_INFO(("serializing simple value."));

        switch (type)
        {
            case CMPI_boolean:
                return strdup(value->boolean ? "true" : "false" );

            case CMPI_char16:
                break;
        }

        TRACE_CRITICAL(("non-supported simple data type."));

    }
    else if (type & CMPI_INTEGER)
    {

        TRACE_INFO(("serializing integer value."));

        switch (type)
        {
            case CMPI_uint8:
                sprintf(str,"%u",value->uint8);
                return strdup(str);
            case CMPI_sint8:
                sprintf(str,"%d",value->sint8);
                return strdup(str);
            case CMPI_uint16:
                sprintf(str,"%u",value->uint16);
                return strdup(str);
            case CMPI_sint16:
                sprintf(str,"%d",value->sint16);
                return strdup(str);
            case CMPI_uint32:
                sprintf(str,"%u",value->uint32);
                return strdup(str);
            case CMPI_sint32:
                sprintf(str,"%d",value->sint32);
                return strdup(str);
            case CMPI_uint64:
#if defined CMPI_PLATFORM_WIN32_IX86_MSVC
                sprintf(str,"I64u",value->uint64);
#else
                sprintf(str,"%llu",value->uint64);
#endif
                return strdup(str);
            case CMPI_sint64:

#if defined CMPI_PLATFORM_WIN32_IX86_MSVC
                sprintf(str,"%I64d",value->sint64);
#else
                sprintf(str,"%lld",value->sint64);
#endif
                return strdup(str);
        }

        TRACE_CRITICAL(("non-supported integer data type."));

    }
    else if (type & CMPI_REAL)
    {

        switch (type)
        {
            case CMPI_real32:
                sprintf(str,"%g",value->real32);
                return strdup(str);
            case CMPI_real64:
                sprintf(str,"%g",value->real64);
                return strdup(str);
        }

        TRACE_CRITICAL(("non-supported floating point data type."));
    }
    sprintf(str,"*NOT RECOGNIZED VALUE TYPE %d*",type);
    return strdup(str);
}