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

📄 mod_isapi.c

📁 Apache V2.0.15 Alpha For Linuxhttpd-2_0_15-alpha.tar.Z
💻 C
📖 第 1 页 / 共 4 页
字号:
        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    case 1008: /* HSE_REQ_IS_KEEP_CONN */        *((LPBOOL) lpvBuffer) = (r->connection->keepalive == 1);        return TRUE;    case 1010: /* XXX: Fake it : HSE_REQ_ASYNC_READ_CLIENT */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI asynchronous I/O not supported: %s",                           r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    case 1011: /* HSE_REQ_GET_IMPERSONATION_TOKEN  Added in ISAPI 4.0 */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction "                          "HSE_REQ_GET_IMPERSONATION_TOKEN "                          "is not supported: %s", r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;#ifdef HSE_REQ_MAP_URL_TO_PATH_EX    case 1012: /* HSE_REQ_MAP_URL_TO_PATH_EX */    {        /* Map a URL to a filename */        LPHSE_URL_MAPEX_INFO info = (LPHSE_URL_MAPEX_INFO) lpdwDataType;        char* test_uri = apr_pstrndup(r->pool, (char *)lpvBuffer, *lpdwSize);        subreq = ap_sub_req_lookup_uri(test_uri, r, NULL);        info->cchMatchingURL = strlen(test_uri);                info->cchMatchingPath = apr_cpystrn(info->lpszPath, subreq->filename,                                             MAX_PATH) - info->lpszPath;        /* Mapping started with assuming both strings matched.         * Now roll on the path_info as a mismatch and handle         * terminating slashes for directory matches.         */        if (subreq->path_info && *subreq->path_info) {            apr_cpystrn(info->lpszPath + info->cchMatchingPath,                         subreq->path_info, MAX_PATH - info->cchMatchingPath);            info->cchMatchingURL -= strlen(subreq->path_info);            if (subreq->finfo.filetype == APR_DIR                 && info->cchMatchingPath < MAX_PATH - 1) {                /* roll forward over path_info's first slash */                ++info->cchMatchingPath;                ++info->cchMatchingURL;            }        }        else if (subreq->finfo.filetype == APR_DIR                 && info->cchMatchingPath < MAX_PATH - 1) {            /* Add a trailing slash for directory */            info->lpszPath[info->cchMatchingPath++] = '/';            info->lpszPath[info->cchMatchingPath] = '\0';        }        /* If the matched isn't a file, roll match back to the prior slash */        if (subreq->finfo.filetype == APR_NOFILE) {            while (info->cchMatchingPath && info->cchMatchingURL) {                if (info->lpszPath[info->cchMatchingPath - 1] == '/')                     break;                --info->cchMatchingPath;                --info->cchMatchingURL;            }        }                /* Paths returned with back slashes */        for (test_uri = info->lpszPath; *test_uri; ++test_uri)            if (*test_uri == '/')                *test_uri = '\\';                /* is a combination of:         * HSE_URL_FLAGS_READ         0x001 Allow read         * HSE_URL_FLAGS_WRITE        0x002 Allow write         * HSE_URL_FLAGS_EXECUTE      0x004 Allow execute         * HSE_URL_FLAGS_SSL          0x008 Require SSL         * HSE_URL_FLAGS_DONT_CACHE   0x010 Don't cache (VRoot only)         * HSE_URL_FLAGS_NEGO_CERT    0x020 Allow client SSL cert         * HSE_URL_FLAGS_REQUIRE_CERT 0x040 Require client SSL cert         * HSE_URL_FLAGS_MAP_CERT     0x080 Map client SSL cert to account         * HSE_URL_FLAGS_SSL128       0x100 Require 128-bit SSL cert         * HSE_URL_FLAGS_SCRIPT       0x200 Allow script execution         *         * XxX: As everywhere, EXEC flags could use some work...         *      and this could go further with more flags, as desired.         */         info->dwFlags = (subreq->finfo.protection & APR_UREAD    ? 0x001 : 0)                      | (subreq->finfo.protection & APR_UWRITE   ? 0x002 : 0)                      | (subreq->finfo.protection & APR_UEXECUTE ? 0x204 : 0);        return TRUE;    }#endif    case 1014: /* HSE_REQ_ABORTIVE_CLOSE */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction HSE_REQ_ABORTIVE_CLOSE"                          " is not supported: %s", r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    case 1015: /* HSE_REQ_GET_CERT_INFO_EX  Added in ISAPI 4.0 */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction "                          "HSE_REQ_GET_CERT_INFO_EX "                          "is not supported: %s", r->filename);                SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;#ifdef HSE_REQ_SEND_RESPONSE_HEADER_EX    case 1016: /* HSE_REQ_SEND_RESPONSE_HEADER_EX  Added in ISAPI 4.0 */    {        LPHSE_SEND_HEADER_EX_INFO shi                                  = (LPHSE_SEND_HEADER_EX_INFO) lpvBuffer;        /* XXX: ignore shi->fKeepConn?  We shouldn't need the advise */        /* r->connection->keepalive = shi->fKeepConn; */        apr_off_t ate = SendResponseHeaderEx(cid, shi->pszStatus,                                              shi->pszHeader,                                             shi->cchStatus,                                              shi->cchHeader);        if (ate < 0) {            SetLastError(TODO_ERROR);            return FALSE;        }        else if (ate < (apr_off_t)shi->cchHeader) {            apr_bucket_brigade *bb;            apr_bucket *b;            bb = apr_brigade_create(cid->r->pool);	    b = apr_bucket_transient_create(shi->pszHeader + ate,                                            (apr_size_t)shi->cchHeader - ate);	    APR_BRIGADE_INSERT_TAIL(bb, b);            b = apr_bucket_eos_create();	    APR_BRIGADE_INSERT_TAIL(bb, b);	    ap_pass_brigade(cid->r->output_filters, bb);        }        return TRUE;    }#endif    case 1017: /* HSE_REQ_CLOSE_CONNECTION  Added after ISAPI 4.0 */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction "                          "HSE_REQ_CLOSE_CONNECTION "                          "is not supported: %s", r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    case 1018: /* HSE_REQ_IS_CONNECTED  Added after ISAPI 4.0 */        /* Returns True if client is connected c.f. MSKB Q188346         * assuming the identical return mechanism as HSE_REQ_IS_KEEP_CONN         */        *((LPBOOL) lpvBuffer) = (r->connection->aborted == 0);        return TRUE;    case 1020: /* HSE_REQ_EXTENSION_TRIGGER  Added after ISAPI 4.0 */        /*  Undocumented - defined by the Microsoft Jan '00 Platform SDK         */        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction "                          "HSE_REQ_EXTENSION_TRIGGER "                          "is not supported: %s", r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    default:        if (cid->sconf->LogNotSupported)            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,                          "ISAPI ServerSupportFunction (%d) not supported: "                          "%s", dwHSERequest, r->filename);        SetLastError(ERROR_INVALID_PARAMETER);        return FALSE;    }}/* * Command handler for the ISAPIReadAheadBuffer directive, which is TAKE1 */static const char *isapi_cmd_readaheadbuffer(cmd_parms *cmd, void *config,                                              char *arg){    isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,                                                   &isapi_module);    char *scan;    long val;    if (((val = strtol(arg, (char **) &scan, 10)) <= 0) || *scan)        return "ISAPIReadAheadBuffer must be a legitimate value.";        sconf->ReadAheadBuffer = val;    return NULL;}/* * Command handler for the ISAPIReadAheadBuffer directive, which is TAKE1 */static const char *isapi_cmd_lognotsupported(cmd_parms *cmd, void *config,                                              char *arg){    isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,                                               &isapi_module);    if (strcasecmp(arg, "on") == 0) {        sconf->LogNotSupported = -1;    }    else if (strcasecmp(arg, "off") == 0) {        sconf->LogNotSupported = 0;    }    else {        return "ISAPILogNotSupported must be on or off";    }    return NULL;}static const char *isapi_cmd_appendlogtoerrors(cmd_parms *cmd, void *config,                                                char *arg){    isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,                                                   &isapi_module);    if (strcasecmp(arg, "on") == 0) {        sconf->AppendLogToErrors = -1;    }    else if (strcasecmp(arg, "off") == 0) {        sconf->AppendLogToErrors = 0;    }    else {        return "ISAPIAppendLogToErrors must be on or off";    }    return NULL;}static const char *isapi_cmd_appendlogtoquery(cmd_parms *cmd, void *config,                                                char *arg){    isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,                                                   &isapi_module);    if (strcasecmp(arg, "on") == 0) {        sconf->AppendLogToQuery = -1;    }    else if (strcasecmp(arg, "off") == 0) {        sconf->AppendLogToQuery = 0;    }    else {        return "ISAPIAppendLogToQuery must be on or off";    }    return NULL;}static const char *isapi_cmd_cachefile(cmd_parms *cmd, void *dummy,                                        const char *filename){    isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,                                                     &isapi_module);    isapi_loaded *isa, **newisa;    apr_finfo_t tmp;    apr_status_t rv;    char *fspec;        fspec = ap_os_case_canonical_filename(cmd->pool, filename);    if (apr_stat(&tmp, fspec,                  APR_FINFO_TYPE, cmd->temp_pool) != APR_SUCCESS) { 	ap_log_error(APLOG_MARK, APLOG_WARNING, errno, cmd->server,	    "ISAPI: unable to stat(%s), skipping", filename);	return NULL;    }    if (tmp.filetype != APR_REG) {	ap_log_error(APLOG_MARK, APLOG_WARNING, errno, cmd->server,	    "ISAPI: %s isn't a regular file, skipping", filename);	return NULL;    }    /* Load the extention as cached (passing sconf) */    rv = isapi_load(cmd->pool, sconf, NULL, fspec, &isa);     if (rv != APR_SUCCESS) {        ap_log_error(APLOG_MARK, APLOG_WARNING, rv, cmd->server,                     "ISAPI: unable to cache %s, skipping", filename);	return NULL;    }    /* Add to cached list of loaded modules */    newisa = apr_array_push(sconf->loaded);    *newisa = isa;        return NULL;}static void isapi_hooks(apr_pool_t *cont){    ap_hook_post_config(isapi_post_config, NULL, NULL, APR_HOOK_MIDDLE);    ap_hook_handler(isapi_handler, NULL, NULL, APR_HOOK_MIDDLE);}static const command_rec isapi_cmds[] = {AP_INIT_TAKE1("ISAPIReadAheadBuffer", isapi_cmd_readaheadbuffer, NULL, RSRC_CONF,  "Maximum bytes to initially pass to the ISAPI handler"),AP_INIT_TAKE1("ISAPILogNotSupported", isapi_cmd_lognotsupported, NULL, RSRC_CONF,  "Log requests not supported by the ISAPI server"),AP_INIT_TAKE1("ISAPIAppendLogToErrors", isapi_cmd_appendlogtoerrors, NULL, RSRC_CONF,  "Send all Append Log requests to the error log"),AP_INIT_TAKE1("ISAPIAppendLogToQuery", isapi_cmd_appendlogtoquery, NULL, RSRC_CONF,  "Append Log requests are concatinated to the query args"),AP_INIT_ITERATE("ISAPICacheFile", isapi_cmd_cachefile, NULL, RSRC_CONF,  "Cache the specified ISAPI extension in-process"),{ NULL }};module isapi_module = {   STANDARD20_MODULE_STUFF,   NULL,                        /* create per-dir config */   NULL,                        /* merge per-dir config */   create_isapi_server_config,  /* server config */   NULL,                        /* merge server config */   isapi_cmds,                  /* command apr_table_t */   isapi_hooks                  /* register hooks */};

⌨️ 快捷键说明

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