⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_gsoap.c

📁 linux下简单对象应用协议的开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
        pRqConf->m_nOutBufCount = 0;        pRqConf->m_nOutBufLength = nResponseBufferLen;        pRqConf->m_pOutBuf = apr_pcalloc(r->pool, nResponseBufferLen);        pRqConf->http_parse = NULL;        pRqConf->m_pszAllHeaders =            apr_pcalloc(r->pool, pRqConf->m_nHeaderLength + 1);        pRqConf->m_pszCurrentHeaderReadingPosition = pRqConf->m_pszAllHeaders;        strcpy(pRqConf->m_pszAllHeaders, r->the_request);        strcat(pRqConf->m_pszAllHeaders, "\r\n");        pRqConf->pIntf = pIntf;    }    /*     * We're about to start sending content, so we need to force the HTTP     * headers to be sent at this point.  Otherwise, no headers will be sent     * at all.  We can set any we like first, of course.  **NOTE** Here's     * where you set the "Content-type" header, and you do so by putting it in     * r->content_type, *not* r->headers_out("Content-type").  If you don't     * set it, it will be filled in with the server's default type (typically     * "text/plain").  You *must* also ensure that r->content_type is lower     * case.     *     */    /*     * If we're only supposed to send header information (HEAD request), we're     * already there.     */    if(r->header_only)    {        return OK;    }    if(NULL != pszError)    {        SendErrorMessage(r, pszError);        return OK;    }    nRet = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK);    if(OK != nRet)    {        SendErrorMessage(r, "Failed to start receiving POST buffer");        return OK;    }    nRet = ap_should_client_block(r);    if(0 == nRet)    {        SendErrorMessage(r, "No body received");        return OK;    }    if(NULL != pszError)    {        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, pszError);        SendErrorMessage(r, pszError);        return OK;    }    if(NULL != pIntf->fsoap_init)    {        (*pIntf->fsoap_init) (psoap, r);        psoap->namespaces = pIntf->namespaces;        set_callbacks(r, pRqConf, psoap);        if(NULL != pIntf->fsoap_serve)        {            nRet = (*pIntf->fsoap_serve) (psoap, r);        }        else        {            SendErrorMessage(r, "no soap_serve entry point");            return OK;        }        if(NULL != pIntf->fsoap_destroy)        {            pIntf->fsoap_destroy(psoap, r); // not an error in 2.1.10 any more.        }        if(NULL != pIntf->fsoap_end)        {            pIntf->fsoap_end(psoap, r);        }        else        {            SendErrorMessage(r, "no soap_end entry point");        }        if(NULL != pIntf->fsoap_done)        {            pIntf->fsoap_done(psoap, r);        }        else        {            SendErrorMessage(r, "no soap_done entry point");        }    }    else    {        SendErrorMessage(r, "no soap_init entry point");        return OK;    }    /*     * We did what we wanted to do, so tell the rest of the server we     * succeeded. We need not delete pszResponse, because it was allocated from the request pool.     */    return OK;}/* * Now let's declare routines for each of the callback phase in order.       * (That's the order in which they're listed in the callback list, *not      * the order in which the server calls them!  See the command_rec            * declaration).  Note that these may be                                     * called for situations that don't relate primarily to our function - in    * other words, the fixup handler shouldn't assume that the request has      * to do with "gsoap" stuff.                                                  * With the exception of the content handler, all of our routines will be    * called for each request, unless an earlier handler from another module    * aborted the sequence.                                                     * * Handlers that are declared as "int" can return the following:             * OK          Handler accepted the request and did its thing with it.      * DECLINED    Handler took no action.                                      * HTTP_mumble Handler looked at request and found it wanting.               * What the server does after calling a module handler depends upon the      * handler's return value.  In all cases, if the handler returns             * DECLINED, the server will continue to the next module with an handler     * for the current phase.  However, if the handler return a non-OK,          * non-DECLINED status, the server aborts the request right there.  If       * the handler returns OK, the server's next action is phase-specific;       * see the individual handler comments below for details.                    *//* *  * * This function is called during server initialisation.  Any information * * that needs to be recorded must be in static cells, since there's no * * configuration record. * * * * There is no return value. */static intgsoap_init(apr_pool_t * p, apr_pool_t * ptemp, apr_pool_t * plog,           server_rec * psrec){    ap_log_error(APLOG_MARK, APLOG_INFO, 0, psrec, "mod_gsoap initialized");    return OK;}/* * This function gets called to create a per-directory configuration * record.  This will be called for the "default" server environment, and for * each directory for which the parser finds any of our directives applicable. * If a directory doesn't have any of our directives involved (i.e., they * aren't in the .htaccess file, or a <Location>, <Directory>, or related * block), this routine will *not* be called - the configuration for the * closest ancestor is used. * * The return value is a pointer to the created module-specific * structure. */static void *gsoap_create_dir_config(apr_pool_t * p, char *dirspec){    gsoapConfiguration *pConfig = gsoapConfiguration_create(p);    pConfig->m_Type = ct_directory;    return pConfig;}/* * This function gets called to merge two per-directory configuration * records.  This is typically done to cope with things like .htaccess files * or <Location> directives for directories that are beneath one for which a * configuration record was already created.  The routine has the * responsibility of creating a new record and merging the contents of the * other two into it appropriately.  If the module doesn't declare a merge * routine, the record for the closest ancestor location (that has one) is * used exclusively. * * The routine MUST NOT modify any of its arguments! * * The return value is a pointer to the created module-specific structure * containing the merged values. */static void *gsoap_merge_dir_config(apr_pool_t * p, void *parent_conf, void *newloc_conf){    gsoapConfiguration *pMergedConfig = gsoapConfiguration_create(p);    gsoapConfiguration *pParentConfig = (gsoapConfiguration *) parent_conf;    gsoapConfiguration *pNewConfig = (gsoapConfiguration *) newloc_conf;    gsoapConfiguration_merge(pMergedConfig, pParentConfig, pNewConfig);    return pMergedConfig;}/* * This function gets called to create a per-server configuration * record.  It will always be called for the "default" server. * * The return value is a pointer to the created module-specific * structure. */static void *gsoap_create_server_config(apr_pool_t * p, server_rec * s){    gsoapConfiguration *pConfig = gsoapConfiguration_create(p);    pConfig->m_Type = ct_server;    return pConfig;}/* * This function gets called to merge two per-server configuration * records.  This is typically done to cope with things like virtual hosts and * the default server configuration. The routine has the responsibility of * creating a new record and merging the contents of the other two into it * appropriately. If the module doesn't declare a merge routine, the more * specific existing record is used exclusively. * * The routine MUST NOT modify any of its arguments! * * The return value is a pointer to the created module-specific structure * containing the merged values. */static void *gsoap_merge_server_config(apr_pool_t * p, void *server1_conf,                          void *server2_conf){    gsoapConfiguration *pMergedConfig = gsoapConfiguration_create(p);    gsoapConfiguration *pServer1Config = (gsoapConfiguration *) server1_conf;    gsoapConfiguration *pServer2Config = (gsoapConfiguration *) server2_conf;    gsoapConfiguration_merge(pMergedConfig, pServer1Config, pServer2Config);    pMergedConfig->m_Type = ct_server;    return (void *)pMergedConfig;}/** helper funciton for library command handler. * @param pszPath the path of the library. * @param bIsSOAPLibrary true if it is a shared library containing a SOAP server. * @return true if the library was added, false if it was aleady in the collection. */static boolAddSharedLibrary(gsoapConfiguration * pConfig, const char *pszPath,                 const bool bIsSOAPLibrary){    bool bAdded = false;    apr_pool_t *pPool = gsoapConfiguration_getModulePool();    if(!SoapSharedLibraries_contains(pConfig->m_pLibraries, pszPath))    {        SoapSharedLibrary *pLibrary = SoapSharedLibrary_create(pPool);        SoapSharedLibrary_init2(pLibrary, pPool, apr_pstrdup(pPool, pszPath));        pLibrary->m_bIsSOAPLibrary = bIsSOAPLibrary;        SoapSharedLibraries_addLibrary(pConfig->m_pLibraries, pLibrary);        bAdded = true;    }    return bAdded;}static gsoapConfiguration *getConfiguration(request_rec * r){    return (gsoapConfiguration *) ap_get_module_config(r->per_dir_config,                                                       &gsoap_module);}static gsoapRequestConfiguration *getRequestConfiguration(struct soap *soap){    gsoapRequestConfiguration *pRqConf =        (gsoapRequestConfiguration *) soap->fplugin(soap, mod_gsoap_id);    return pRqConf;}/* * Patch from Ryan Troll * * Implement these as weak symbols, allowing symbol checking during * compilation to succeed, even when another object is actually * providing these symbols at runtime. *//* * This patch may not work properly on some systems. The patch is commented * out in case someone is interested in using it (at your own risk). *//*SOAP_NMAC struct Namespace namespaces[] __attribute__ ((weak));SOAP_NMAC struct Namespace namespaces[] = {    {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/",     "http://www.w3.org/*\//soap-envelope"},    {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/",     "http://www.w3.org/*\/soap-encoding"},    {"xsi", "http://www.w3.org/2001/XMLSchema-instance",     "http://www.w3.org/*\//XMLSchema-instance"},    {"xsd", "http://www.w3.org/2001/XMLSchema",     "http://www.w3.org/*\//XMLSchema"},    {NULL, NULL}};SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 void SOAP_FMAC4soap_serializeheader(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    pRqConf->pIntf->soap_serializeheader(soap);}SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 int SOAP_FMAC4soap_putheader(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_putheader(soap);}SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 int SOAP_FMAC4soap_getheader(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_getheader(soap);}SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap) __attribute__ ((weak));SOAP_FMAC3 void SOAP_FMAC4soap_fault(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    pRqConf->pIntf->soap_fault(soap);}SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 void SOAP_FMAC4soap_serializefault(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    pRqConf->pIntf->soap_serializefault(soap);}SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 int SOAP_FMAC4soap_putfault(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_putfault(soap);}SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 int SOAP_FMAC4soap_getfault(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_getfault(soap);}SOAP_FMAC3 const char **SOAP_FMAC4 soap_faultcode(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 const char **SOAP_FMAC4soap_faultcode(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_faultcode(soap);}SOAP_FMAC3 const char **SOAP_FMAC4 soap_faultstring(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 const char **SOAP_FMAC4soap_faultstring(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_faultstring(soap);}SOAP_FMAC3 const char **SOAP_FMAC4 soap_faultdetail(struct soap *soap)    __attribute__ ((weak));SOAP_FMAC3 const char **SOAP_FMAC4soap_faultdetail(struct soap *soap){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_faultdetail(soap);}SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *a,                                            int b) __attribute__ ((weak));SOAP_FMAC3 void SOAP_FMAC4soap_markelement(struct soap *soap, const void *a, int b){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    pRqConf->pIntf->soap_markelement(soap, a, b);}SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *a,                                          const char *b, int c, int d)    __attribute__ ((weak));SOAP_FMAC3 int SOAP_FMAC4soap_putelement(struct soap *soap, const void *a, const char *b, int c, int d){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_putelement(soap, a, b, c, d);}SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap *soap, int *a)    __attribute__ ((weak));SOAP_FMAC3 void *SOAP_FMAC4soap_getelement(struct soap *soap, int *a){    gsoapRequestConfiguration *pRqConf = getRequestConfiguration(soap);    return pRqConf->pIntf->soap_getelement(soap, a);}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -