Exemplo n.º 1
0
inline XmlRpcValue& XmlRpcValue::operator= (const XmlRpcValue& value) {
    // Must increment before we decrement, in case of assignment to self.
    xmlrpc_INCREF(value.mValue);
    xmlrpc_DECREF(mValue);
    mValue = value.mValue;
    return *this;
}
Exemplo n.º 2
0
xmlrpc_value *
value::cValue() const {

    if (this->cValueP) {
        xmlrpc_INCREF(this->cValueP);  // For Caller
    }
    return this->cValueP;
}
Exemplo n.º 3
0
inline XmlRpcValue::XmlRpcValue (xmlrpc_value *value,
                                 ReferenceBehavior behavior) 
{
    mValue = value;

    if (behavior == MAKE_REFERENCE)
        xmlrpc_INCREF(value);
}
Exemplo n.º 4
0
/* Utility routine to get the value of an array by its index.
*/
static xmlrpc_value *
xr_getArrValue (xmlrpc_value *val, int index)
{
    xmlrpc_value *v;
    xmlrpc_env   env;

    if (xmlrpc_value_type (val) == XMLRPC_TYPE_ARRAY) {
        xmlrpc_array_read_item (&env, val, index, &v);
        return (v);
    } else {
	xmlrpc_INCREF(val);
        return (val);
    }
}
Exemplo n.º 5
0
static void
test_value_alloc_dealloc(void) {

    xmlrpc_value * v;
    xmlrpc_env env;

    xmlrpc_env_init(&env);

    /* Test allocation and deallocation (w/memprof). */
    v = xmlrpc_build_value(&env, "i", (xmlrpc_int32) 5);
    TEST_NO_FAULT(&env);
    TEST(v != NULL);
    xmlrpc_INCREF(v);
    xmlrpc_DECREF(v);
    xmlrpc_DECREF(v);

    xmlrpc_env_clean(&env);
}
Exemplo n.º 6
0
void 
xmlrpc_array_append_item(xmlrpc_env *   const envP,
                         xmlrpc_value * const arrayP,
                         xmlrpc_value * const valueP) {

    XMLRPC_ASSERT_ENV_OK(envP);
    XMLRPC_ASSERT_VALUE_OK(arrayP);
    
    if (xmlrpc_value_type(arrayP) != XMLRPC_TYPE_ARRAY)
        xmlrpc_env_set_fault_formatted(
            envP, XMLRPC_TYPE_ERROR, "Value is not an array");
    else {
        size_t const size = 
            XMLRPC_MEMBLOCK_SIZE(xmlrpc_value *, &arrayP->_block);

        XMLRPC_MEMBLOCK_RESIZE(xmlrpc_value *, envP, &arrayP->_block, size+1);

        if (!envP->fault_occurred) {
            xmlrpc_value ** const contents =
                XMLRPC_MEMBLOCK_CONTENTS(xmlrpc_value*, &arrayP->_block);
            xmlrpc_INCREF(valueP);
            contents[size] = valueP;
        }
    }
Exemplo n.º 7
0
static void 
decomposeValueWithTree(xmlrpc_env *                  const envP,
                       xmlrpc_value *                const valueP,
                       bool                          const oldstyleMemMgmt,
                       const struct decompTreeNode * const decompRootP) {
/*----------------------------------------------------------------------------
   Decompose XML-RPC value *valueP, given the decomposition tree
   *decompRootP.  The decomposition tree tells what structure *valueP
   is expected to have and where to put the various components of it
   (e.g. it says "it's an array of 3 integers.  Put their values at
   locations x, y, and z")
-----------------------------------------------------------------------------*/
    switch (decompRootP->formatSpecChar) {
    case '-':
        /* There's nothing to validate or return */
        break;
    case 'i':
        xmlrpc_read_int(envP, valueP, decompRootP->store.Tinteger.valueP);
        break;

    case 'b':
        xmlrpc_read_bool(envP, valueP, decompRootP->store.Tbool.valueP);
        break;

    case 'd':
        xmlrpc_read_double(envP, valueP, decompRootP->store.Tdouble.valueP);
        break;

    case 't':
        xmlrpc_read_datetime_sec(envP, valueP,
                                 decompRootP->store.TdatetimeT.valueP);
        break;

    case '8':
        readDatetime8Str(envP, valueP, decompRootP->store.Tdatetime8.valueP,
                         oldstyleMemMgmt);
        break;

    case 's':
        if (decompRootP->store.Tstring.sizeP)
            readStringLp(envP, valueP,
                         decompRootP->store.Tstring.sizeP,
                         decompRootP->store.Tstring.valueP,
                         oldstyleMemMgmt);
        else
            readString(envP, valueP, decompRootP->store.Tstring.valueP,
                       oldstyleMemMgmt);
        break;

    case 'w':
#if HAVE_UNICODE_WCHAR
        if (decompRootP->store.Tstring.sizeP)
            readStringWLp(envP, valueP,
                          decompRootP->store.TwideString.sizeP,
                          decompRootP->store.TwideString.valueP,
                          oldstyleMemMgmt);
        else
            readStringW(envP, valueP, decompRootP->store.TwideString.valueP,
                        oldstyleMemMgmt);
#else
        XMLRPC_ASSERT(false);
#endif /* HAVE_UNICODE_WCHAR */
        break;
        
    case '6':
        readBase64(envP, valueP,
                   decompRootP->store.TbitString.sizeP,
                   decompRootP->store.TbitString.valueP,
                   oldstyleMemMgmt);
        break;

    case 'n':
        xmlrpc_read_nil(envP, valueP);
        break;

    case 'I':
        xmlrpc_read_i8(envP, valueP, decompRootP->store.Ti8.valueP);
        break;

    case 'p':
        xmlrpc_read_cptr(envP, valueP, decompRootP->store.Tcptr.valueP);
        break;

    case 'V':
        *decompRootP->store.Tvalue.valueP = valueP;
        if (!oldstyleMemMgmt)
            xmlrpc_INCREF(valueP);
        break;

    case 'A':
        if (xmlrpc_value_type(valueP) != XMLRPC_TYPE_ARRAY)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_TYPE_ERROR, "Value to be decomposed is of type "
                "%s, but the 'A' specifier requires type ARRAY",
                xmlrpc_type_name(xmlrpc_value_type(valueP)));
        else {
            *decompRootP->store.TarrayVal.valueP = valueP;
            if (!oldstyleMemMgmt)
                xmlrpc_INCREF(valueP);
        }
        break;

    case 'S':
        if (xmlrpc_value_type(valueP) != XMLRPC_TYPE_STRUCT)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_TYPE_ERROR, "Value to be decomposed is of type "
                "%s, but the 'S' specifier requires type STRUCT.",
                xmlrpc_type_name(xmlrpc_value_type(valueP)));
        else {
            *decompRootP->store.TstructVal.valueP = valueP;
            if (!oldstyleMemMgmt)
                xmlrpc_INCREF(valueP);
        }
        break;

    case '(':
        if (xmlrpc_value_type(valueP) != XMLRPC_TYPE_ARRAY)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_TYPE_ERROR, "Value to be decomposed is of type "
                "%s, but the '(...)' specifier requires type ARRAY",
                xmlrpc_type_name(xmlrpc_value_type(valueP)));
        else
            parsearray(envP, valueP, decompRootP->store.Tarray,
                       oldstyleMemMgmt);
        break;

    case '{':
        if (xmlrpc_value_type(valueP) != XMLRPC_TYPE_STRUCT)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_TYPE_ERROR, "Value to be decomposed is of type "
                "%s, but the '{...}' specifier requires type STRUCT",
                xmlrpc_type_name(xmlrpc_value_type(valueP)));
        else
            parsestruct(envP, valueP, decompRootP->store.Tstruct,
                        oldstyleMemMgmt);
        break;

    default:
        /* Every format character that is allowed in a decomposition tree
           node is handled above.
        */
        XMLRPC_ASSERT(false);
    }
}
Exemplo n.º 8
0
void
value::instantiate(xmlrpc_value *const valueP) {

    xmlrpc_INCREF(valueP);
    this->cValueP = valueP;
}
Exemplo n.º 9
0
static xmlrpc_value *
xr_defaultMethod (xmlrpc_env *envP, char *host, char *methodName,
               xmlrpc_value *paramArrayP, void *serverInfo)
{
    int      status;
    ServerP  svr = (Server *) serverInfo; 
    MethodP  m   = (Method *) NULL;
    extern int  xr_errstat;


   	
    if (DEBUG)
        fprintf (stderr, "DEFAULT:  method='%s' data= 0x%lx\n",
	    methodName, (unsigned long) serverInfo);
        

    /* Now look for the method in the interface registry.
    */
    for (m=svr->method_head; m; m = m->next) {

	if (strcmp (m->name, methodName) == 0) {

	    Caller *c = (Caller *) NULL;
	    xmlrpc_value *result = (xmlrpc_value *) NULL;


	    (void) pthread_mutex_lock (&svr_mutex);
	    c = &cs[(cindex = (cindex + 1) % SZ_CALL_RING)];
	    (void) pthread_mutex_unlock (&svr_mutex);

#ifdef FREE_RES
	    /*  Free old result values.
	     */
	    if (res_anum >= 0) {
		xr_freeArray (res_anum);
		res_anum = -1;
	    }
	    if (res_snum >= 0) {
		xr_freeStruct (res_snum);
		res_snum = -1;
	    }
#endif

	    memset (c, 0, sizeof(Caller));
	    c->env   = envP; 		/* setup the calling parameters */
	    c->host  = host;
	    c->name  = methodName;
	    c->param = paramArrayP;
	    c->info  = serverInfo;


	    /* Call the function.
	    */
	
	    xr_setStat (2);
	    if ( (status = (*(PFI)(*m->methodFunc))((void *)c)) ) {
		fprintf (stderr, "Matched failed '%s'...\n", m->name);
		xr_errstat = ERR;
	    } else {
	        xr_errstat = OK;
		xmlrpc_DECREF(paramArrayP);
	        result = (c->result ? c->result : (xmlrpc_value *) NULL);
	    }

	    xmlrpc_INCREF(result);
    	    return ( result ); 			/* return our result	*/
	}
    }


    if (!m) {
	char  msg[256];

	memset (msg, 0, 256);
	sprintf (msg, "No such method '%s'", methodName);
	xmlrpc_value *result = xmlrpc_string_new (envP, msg);

        return ( result );

    } else
        return ((xmlrpc_value *) NULL);		/* should never happen	*/
}
Exemplo n.º 10
0
inline xmlrpc_value *XmlRpcValue::makeReference (void) const {
    xmlrpc_INCREF(mValue);
    return mValue;
}
Exemplo n.º 11
0
inline XmlRpcValue::XmlRpcValue (const XmlRpcValue& value) {
    mValue = value.mValue;
    xmlrpc_INCREF(mValue);
}