当前位置: 首页>>代码示例>>C++>>正文


C++ xmlrpc_env_set_fault_formatted函数代码示例

本文整理汇总了C++中xmlrpc_env_set_fault_formatted函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlrpc_env_set_fault_formatted函数的具体用法?C++ xmlrpc_env_set_fault_formatted怎么用?C++ xmlrpc_env_set_fault_formatted使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlrpc_env_set_fault_formatted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: validateUtf16

static void
validateUtf16(xmlrpc_env *const envP,
              wchar_t const wc) {
/*----------------------------------------------------------------------------
   Validate that the string is a legal UTF16 encoding of a Unicode
   character.

   Actually, we validate that it is UCS-2.  The set of UCS-2 encodings is a
   subset of the set of UTF16 encodings.  In particular, it is the set of
   UTF16 encodings that are 16 bits.  UCS-2 is a fixed-length encoding, with
   16 bits per character, whereas UTF16 is variable length, with 1 or more 16
   bit units per character.

   The name of the subroutine reflects the fact that in concept, we _should_
   accept any UTF16, but we haven't taken the time yet to figure out how to do
   that (in the big picture, not just this subroutine).  The user will notice
   only if he uses those really arcane 3.1% of the Unicode characters that
   take more than 16 bits to represent in UTF16.
-----------------------------------------------------------------------------*/
    if (wc > UCS2_MAX_LEGAL_CHARACTER)
        xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_INVALID_UTF8_ERROR,
                "Xmlrpc-c is not capable of handling UTF16 character encodings "
                        "longer than 16 bits, which means you can't have a code point "
                        "> U+FFFD.  "
                        "This string contains 0x%04x",
                (unsigned) wc);
    else if (UTF16_FIRST_SURROGATE <= wc && wc <= UTF16_LAST_SURROGATE)
        xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_INVALID_UTF8_ERROR,
                "UTF-16 surrogates may not appear in UTF-8 data.  "
                        "String contains %04x", (unsigned) wc);
}
开发者ID:arssivka,项目名称:naomech,代码行数:33,代码来源:utf8.c

示例2: xmlrpc_env_set_fault_formatted

// Return open index for given key or 0
Index *open_index(xmlrpc_env *env, int key)
{
    try
    {
        ServerConfig config;
        if (!get_config(env, config))
            return 0;
        stdString index_name;
        if (!config.find(key, index_name))
        {
            xmlrpc_env_set_fault_formatted(env, ARCH_DAT_NO_INDEX,
                                           "Invalid key %d", key);
            return 0;
        } 
        LOG_MSG("Open index, key %d = '%s'\n", key, index_name.c_str());
        AutoPtr<Index> index(new AutoIndex());
        if (!index)
        {
            xmlrpc_env_set_fault_formatted(env, ARCH_DAT_NO_INDEX,
                                           "Cannot allocate index");
            return 0;
        }
        index->open(index_name);
        return index.release();
    }
    catch (GenericException &e)
    {
        LOG_MSG("Error: %s\n", e.what());
        xmlrpc_env_set_fault_formatted(env, ARCH_DAT_NO_INDEX,
                                       "%s", e.what());
    }
    return 0;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:34,代码来源:main_cgi.cpp

示例3: getMethListFromMulticallPlist

static void
getMethListFromMulticallPlist(xmlrpc_env *    const envP,
                              xmlrpc_value *  const paramArrayP,
                              xmlrpc_value ** const methlistPP) {

    if (xmlrpc_array_size(envP, paramArrayP) != 1)
        xmlrpc_env_set_fault_formatted(
            envP, XMLRPC_PARSE_ERROR,
            "system.multicall takes one parameter, which is an "
            "array, each element describing one RPC.  You "
            "supplied %u arguments", 
            xmlrpc_array_size(envP, paramArrayP));
    else {
        xmlrpc_value * methlistP;

        xmlrpc_array_read_item(envP, paramArrayP, 0, &methlistP);

        XMLRPC_ASSERT_ENV_OK(envP);

        if (xmlrpc_value_type(methlistP) != XMLRPC_TYPE_ARRAY)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_TYPE_ERROR,
                "system.multicall's parameter should be an array, "
                "each element describing one RPC.  But it is type "
                "%u instead.", xmlrpc_value_type(methlistP));
        else
            *methlistPP = methlistP;

        if (envP->fault_occurred)
            xmlrpc_DECREF(methlistP);
    }
}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:32,代码来源:system_method.c

示例4: callOneMethod

static void
callOneMethod(xmlrpc_env *      const envP,
              xmlrpc_registry * const registryP,
              xmlrpc_value *    const rpcDescP,
              void *            const callInfo,
              xmlrpc_value **   const resultPP) {

    const char * methodName;
    xmlrpc_value * paramArrayP;

    XMLRPC_ASSERT_ENV_OK(envP);

    if (xmlrpc_value_type(rpcDescP) != XMLRPC_TYPE_STRUCT)
        xmlrpc_env_set_fault_formatted(
            envP, XMLRPC_TYPE_ERROR,
            "An element of the multicall array is type %u, but should "
            "be a struct (with members 'methodName' and 'params')",
            xmlrpc_value_type(rpcDescP));
    else {
        xmlrpc_decompose_value(envP, rpcDescP, "{s:s,s:A,*}",
                               "methodName", &methodName,
                               "params", &paramArrayP);
        if (!envP->fault_occurred) {
            /* Watch out for a deep recursion attack. */
            if (xmlrpc_streq(methodName, "system.multicall"))
                xmlrpc_env_set_fault_formatted(
                    envP,
                    XMLRPC_REQUEST_REFUSED_ERROR,
                    "Recursive system.multicall forbidden");
            else {
                xmlrpc_env env;
                xmlrpc_value * resultValP;

                xmlrpc_env_init(&env);
                xmlrpc_dispatchCall(&env, registryP, methodName, paramArrayP,
                                    callInfo,
                                    &resultValP);
                if (env.fault_occurred) {
                    /* Method failed, so result is a fault structure */
                    *resultPP = 
                        xmlrpc_build_value(
                            envP, "{s:i,s:s}",
                            "faultCode", (xmlrpc_int32) env.fault_code,
                            "faultString", env.fault_string);
                } else {
                    *resultPP = xmlrpc_build_value(envP, "(V)", resultValP);

                    xmlrpc_DECREF(resultValP);
                }
                xmlrpc_env_clean(&env);
            }
            xmlrpc_DECREF(paramArrayP);
            xmlrpc_strfree(methodName);
        }
    }
}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:56,代码来源:system_method.c

示例5: service_set_url

static xmlrpc_value *
service_set_url (xmlrpc_env   *env,
                 xmlrpc_value *param_array,
                 void         *user_data)
{
    char *service_identifier;
    char *old_url, *new_url;
    RCWorldService *service;

    xmlrpc_parse_value (env, param_array, "(ss)",
                        &service_identifier, &new_url);
    XMLRPC_FAIL_IF_FAULT (env);

    service = service_lookup (service_identifier);

    if (!service) {
        xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE,
                                        "Unable to unmount service for '%s'",
                                        service_identifier);
        goto cleanup;
    }

    old_url = service->url;
    service->url = g_strdup (new_url);

    /* FIXME: This is wrong. rc_world_refresh () returns pending only if
       refresh has not completed yet. Pending needs to be unref'ed when
       we're done with it as well.
       It's not a big deal right now as nothing actually calls this anymore.
    */
    if (!rc_world_refresh (RC_WORLD (service))) {
        xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE,
                                        "Unable to change mirrors for '%s'",
                                        service->name);
        g_free (service->url);
        service->url = old_url;
        goto cleanup;
    }

    g_free (old_url);

    rcd_services_save ();

cleanup:
    if (env->fault_occurred)
        return NULL;

    return xmlrpc_build_value (env, "i", 0);
}
开发者ID:joeshaw,项目名称:rcd,代码行数:49,代码来源:rcd-rpc-service.c

示例6: parseResponse

static void
parseResponse(xmlrpc_env *       const envP,
              xmlrpc_mem_block * const respXmlP,
              xmlrpc_value **    const resultPP,
              int *              const faultCodeP,
              const char **      const faultStringP) {

    xmlrpc_env respEnv;

    xmlrpc_env_init(&respEnv);

    xmlrpc_parse_response2(
        &respEnv,
        XMLRPC_MEMBLOCK_CONTENTS(char, respXmlP),
        XMLRPC_MEMBLOCK_SIZE(char, respXmlP),
        resultPP, faultCodeP, faultStringP);

    if (respEnv.fault_occurred)
        xmlrpc_env_set_fault_formatted(
            envP, respEnv.fault_code,
            "Unable to make sense of XML-RPC response from server.  "
            "%s.  Use XMLRPC_TRACE_XML to see for yourself",
            respEnv.fault_string);

    xmlrpc_env_clean(&respEnv);
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:26,代码来源:xmlrpc_client.c

示例7: service_remove

static xmlrpc_value *
service_remove (xmlrpc_env   *env,
                xmlrpc_value *param_array,
                void         *user_data)
{
    char *service_identifier;
    RCWorldService *service;

    xmlrpc_parse_value (env, param_array, "(s)", &service_identifier);
    XMLRPC_FAIL_IF_FAULT (env);

    service = service_lookup (service_identifier);

    if (!service) {
        xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE,
                                        "Unable to unmount service for '%s'",
                                        service_identifier);
        goto cleanup;
    }

    rc_world_multi_remove_subworld (RC_WORLD_MULTI (rc_get_world ()),
                                    RC_WORLD (service));

    rcd_services_save ();

cleanup:
    if (env->fault_occurred)
        return NULL;

    return xmlrpc_build_value (env, "i", 0);
}
开发者ID:joeshaw,项目名称:rcd,代码行数:31,代码来源:rcd-rpc-service.c

示例8: xmlrpc_struct_size

int 
xmlrpc_struct_size(xmlrpc_env *   const envP,
                   xmlrpc_value * const structP) {

    int retval;

    XMLRPC_ASSERT_ENV_OK(envP);
    XMLRPC_ASSERT_VALUE_OK(structP);

    if (structP->_type != XMLRPC_TYPE_STRUCT) {
        xmlrpc_env_set_fault_formatted(
            envP, XMLRPC_TYPE_ERROR, "Value is not a struct.  It is type #%d",
            structP->_type);
        retval = -1;
    } else {
        size_t const size =
            XMLRPC_MEMBLOCK_SIZE(_struct_member, &structP->_block);

        assert((size_t)(int)size == size);
            /* Because structs are defined to have few enough members */

        retval = (int)size;
    }
    return retval;
}
开发者ID:BlackPearl01,项目名称:quick-box,代码行数:25,代码来源:xmlrpc_struct.c

示例9: writeFile

static void
writeFile(xmlrpc_env *       const envP,
          FILE *             const ofP,
          xmlrpc_mem_block * const fileContentsP) {

    size_t totalWritten;

    totalWritten = 0;

    while (!envP->fault_occurred &&
           totalWritten < XMLRPC_MEMBLOCK_SIZE(char, fileContentsP)) {
        size_t bytesWritten;

        bytesWritten = fwrite(
            XMLRPC_MEMBLOCK_CONTENTS(char, fileContentsP) + totalWritten,
            1,
            XMLRPC_MEMBLOCK_SIZE(char, fileContentsP) - totalWritten,
            ofP);

        if (bytesWritten < 1)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_INTERNAL_ERROR,
                "Error writing output");

        totalWritten -= bytesWritten;
    }
}
开发者ID:mirror,项目名称:xmlrpc-c,代码行数:27,代码来源:xmlrpc_transport.c

示例10: setParseErr

static void
setParseErr(xmlrpc_env *   const envP,
            Tokenizer * const tokP,
            const char *   const format,
            ...) {

    struct docPosition const pos = currentDocumentPosition(tokP);

    va_list args;
    const char * msg;

    XMLRPC_ASSERT(envP != NULL);
    XMLRPC_ASSERT(format != NULL);

    va_start(args, format);

    xmlrpc_vasprintf(&msg, format, args);

    xmlrpc_env_set_fault_formatted(
        envP, XMLRPC_PARSE_ERROR,
        "JSON parse error at Line %u, Column %u: %s",
        pos.lineNum, pos.colNum, msg);

    xmlrpc_strfree(msg);

    va_end(args);
}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:27,代码来源:json.c

示例11: xmlrpc_parse_response2

void
xmlrpc_parse_response2(xmlrpc_env *    const envP,
                       const char *    const xmlData,
                       size_t          const xmlDataLen,
                       xmlrpc_value ** const resultPP,
                       int *           const faultCodeP,
                       const char **   const faultStringP) {
/*----------------------------------------------------------------------------
  Given some XML text, attempt to parse it as an XML-RPC response.

  If the response is a regular, valid response, return a new reference
  to the appropriate value as *resultP and return NULL as
  *faultStringP and nothing as *faultCodeP.

  If the response is valid, but indicates a failure of the RPC, return the
  fault string in newly malloc'ed space as *faultStringP and the fault
  code as *faultCodeP and nothing as *resultP.

  If the XML text is not a valid response or something prevents us from
  parsing it, return a description of the error as *envP and nothing else.
-----------------------------------------------------------------------------*/
    xml_element * response;

    XMLRPC_ASSERT_ENV_OK(envP);
    XMLRPC_ASSERT(xmlData != NULL);

    /* SECURITY: Last-ditch attempt to make sure our content length is legal.
    ** XXX - This check occurs too late to prevent an attacker from creating
    ** an enormous memory block, so you should try to enforce it
    ** *before* reading any data off the network. */
    if (xmlDataLen > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))
        xmlrpc_env_set_fault_formatted(
            envP, XMLRPC_LIMIT_EXCEEDED_ERROR,
            "XML-RPC response too large.  Our limit is %u characters.  "
            "We got %u characters",
            xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID), xmlDataLen);
    else {
        xmlrpc_env env;
        xmlrpc_env_init(&env);

        xml_parse(&env, xmlData, xmlDataLen, &response);

        if (env.fault_occurred)
            setParseFault(envP, "Not valid XML.  %s", env.fault_string);
        else {
            /* Pick apart and verify our structure. */
            if (xmlrpc_streq(xml_element_name(response), "methodResponse")) {
                parseMethodResponseElt(envP, response,
                                       resultPP, faultCodeP, faultStringP);
            } else
                setParseFault(envP, "XML-RPC response must consist of a "
                              "<methodResponse> element.  "
                              "This has a <%s> instead.",
                              xml_element_name(response));
            
            xml_element_free(response);
        }
        xmlrpc_env_clean(&env);
    }
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:60,代码来源:xmlrpc_parse.c

示例12: xmlrpc_read_base64

void
xmlrpc_read_base64(xmlrpc_env *           const envP,
                   const xmlrpc_value *   const valueP,
                   size_t *               const lengthP,
                   const unsigned char ** const byteStringValueP) {

    validateType(envP, valueP, XMLRPC_TYPE_BASE64);
    if (!envP->fault_occurred) {
        size_t const size = 
            XMLRPC_MEMBLOCK_SIZE(char, &valueP->_block);
        const char * const contents = 
            XMLRPC_MEMBLOCK_CONTENTS(char, &valueP->_block);

        char * byteStringValue;

        byteStringValue = calloc(1,size);
        if (byteStringValue == NULL)
            xmlrpc_env_set_fault_formatted(
                envP, XMLRPC_INTERNAL_ERROR, "Unable to allocate %u bytes "
                "for byte string.", size);
        else {
            memcpy(byteStringValue, contents, size);
            *byteStringValueP = (const unsigned char *)byteStringValue;
            *lengthP = size;
        }
    }
开发者ID:RayPlante,项目名称:usvirtualobservatory,代码行数:26,代码来源:xmlrpc_data.c

示例13: parseCallXml

static void
parseCallXml(xmlrpc_env *   const envP,
             const char *   const xmlData,
             size_t         const xmlDataLen,
             xml_element ** const callElemPP) {
/*----------------------------------------------------------------------------
   Parse the XML of an XML-RPC call.
-----------------------------------------------------------------------------*/
    xml_element * callElemP;
    xmlrpc_env env;

    xmlrpc_env_init(&env);
    xml_parse(&env, xmlData, xmlDataLen, &callElemP);
    if (env.fault_occurred)
        xmlrpc_env_set_fault_formatted(
            envP, env.fault_code, "Call is not valid XML.  %s",
            env.fault_string);
    else {
        if (!xmlrpc_streq(xml_element_name(callElemP), "methodCall"))
            setParseFault(envP,
                          "XML-RPC call should be a <methodCall> element.  "
                          "Instead, we have a <%s> element.",
                          xml_element_name(callElemP));

        if (envP->fault_occurred)
            xml_element_free(callElemP);
    }
    *callElemPP = callElemP;

    xmlrpc_env_clean(&env);
}
开发者ID:TekatoD,项目名称:xmlrpc-c,代码行数:31,代码来源:xmlrpc_parse.c

示例14: service_add

static xmlrpc_value *
service_add (xmlrpc_env   *env,
             xmlrpc_value *param_array,
             void         *user_data)
{
    char *service_url, *mangled_url;
    GError *err = NULL;

    xmlrpc_parse_value (env, param_array, "(s)", &service_url);
    XMLRPC_FAIL_IF_FAULT (env);

    /* We always want to download data from the site */
    mangled_url = g_strconcat (service_url, "?remote_only=1", NULL);

    if (!rc_world_multi_mount_service (RC_WORLD_MULTI (rc_get_world ()),
                                       mangled_url, &err)) {
        xmlrpc_env_set_fault_formatted (env, RCD_RPC_FAULT_INVALID_SERVICE,
                                        "Unable to mount service for '%s': %s",
                                        service_url, err->message);
    } else
        rcd_services_save ();

    g_free (mangled_url);

cleanup:
    if (env->fault_occurred)
        return NULL;

    return xmlrpc_build_value (env, "i", 0);
}
开发者ID:joeshaw,项目名称:rcd,代码行数:30,代码来源:rcd-rpc-service.c

示例15: test_env

static void test_env(void)
{
    xmlrpc_env env, env2;
    char *s;

    /* Test xmlrpc_env_init. */
    xmlrpc_env_init(&env);
    TEST(!env.fault_occurred);
    TEST(env.fault_code == 0);
    TEST(env.fault_string == NULL);

    /* Test xmlrpc_set_fault. */
    xmlrpc_env_set_fault(&env, 1, test_string_1);
    TEST(env.fault_occurred);
    TEST(env.fault_code == 1);
    TEST(env.fault_string != test_string_1);
    TEST(strcmp(env.fault_string, test_string_1) == 0);

    /* Change an existing fault. */
    xmlrpc_env_set_fault(&env, 2, test_string_2);
    TEST(env.fault_occurred);
    TEST(env.fault_code == 2);
    TEST(strcmp(env.fault_string, test_string_2) == 0);    

    /* Set a fault with a format string. */
    xmlrpc_env_set_fault_formatted(&env, 3, "a%s%d", "bar", 9);
    TEST(env.fault_occurred);
    TEST(env.fault_code == 3);
    TEST(strcmp(env.fault_string, "abar9") == 0);

    /* Set a fault with an oversized string. */
    s = "12345678901234567890123456789012345678901234567890";
    xmlrpc_env_set_fault_formatted(&env, 4, "%s%s%s%s%s%s", s, s, s, s, s, s);
    TEST(env.fault_occurred);
    TEST(env.fault_code == 4);
    TEST(strlen(env.fault_string) == 255);

    /* Test cleanup code (with help from memprof). */
    xmlrpc_env_clean(&env);

    /* Test cleanup code on in absence of xmlrpc_env_set_fault. */
    xmlrpc_env_init(&env2);
    xmlrpc_env_clean(&env2);
}
开发者ID:BenedictHiddleston,项目名称:xmlrpc-c-1.06.30,代码行数:44,代码来源:test.c


注:本文中的xmlrpc_env_set_fault_formatted函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。