本文整理汇总了C++中code函数的典型用法代码示例。如果您正苦于以下问题:C++ code函数的具体用法?C++ code怎么用?C++ code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了code函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ngx_http_index_handler
static ngx_int_t
ngx_http_index_handler(ngx_http_request_t *r)
{
u_char *p, *name;
size_t len, root, reserve, allocated;
ngx_int_t rc;
ngx_str_t path, uri;
ngx_uint_t i, dir_tested;
ngx_http_index_t *index;
ngx_open_file_info_t of;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e;
ngx_http_core_loc_conf_t *clcf;
ngx_http_index_loc_conf_t *ilcf;
ngx_http_script_len_code_pt lcode;
if (r->uri.data[r->uri.len - 1] != '/') {
return NGX_DECLINED;
}
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
return NGX_DECLINED;
}
ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
allocated = 0;
root = 0;
dir_tested = 0;
name = NULL;
/* suppress MSVC warning */
path.data = NULL;
index = ilcf->indices->elts;
for (i = 0; i < ilcf->indices->nelts; i++) {
if (index[i].lengths == NULL) {
if (index[i].name.data[0] == '/') {
return ngx_http_internal_redirect(r, &index[i].name, &r->args);
}
reserve = ilcf->max_index_len;
len = index[i].name.len;
} else {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
e.ip = index[i].lengths->elts;
e.request = r;
e.flushed = 1;
/* 1 is for terminating '\0' as in static names */
len = 1;
while (*(uintptr_t *) e.ip) {
lcode = *(ngx_http_script_len_code_pt *) e.ip;
len += lcode(&e);
}
/* 16 bytes are preallocation */
reserve = len + 16;
}
if (reserve > allocated) {
name = ngx_http_map_uri_to_path(r, &path, &root, reserve);
if (name == NULL) {
return NGX_ERROR;
}
allocated = path.data + path.len - name;
}
if (index[i].values == NULL) {
/* index[i].name.len includes the terminating '\0' */
ngx_memcpy(name, index[i].name.data, index[i].name.len);
path.len = (name + index[i].name.len - 1) - path.data;
} else {
e.ip = index[i].values->elts;
e.pos = name;
while (*(uintptr_t *) e.ip) {
code = *(ngx_http_script_code_pt *) e.ip;
code((ngx_http_script_engine_t *) &e);
}
if (*name == '/') {
uri.len = len - 1;
uri.data = name;
return ngx_http_internal_redirect(r, &uri, &r->args);
}
path.len = e.pos - path.data;
//.........这里部分代码省略.........
示例2: Q_ASSERT
//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
IDebugEvent::Message PlatformEvent::error_description() const {
Q_ASSERT(is_error());
const edb::address_t fault_address = reinterpret_cast<edb::address_t>(fault_address_);
switch(code()) {
case SIGSEGV:
return Message(
tr("Illegal Access Fault"),
tr(
"<p>The debugged application encountered a segmentation fault.<br />The address <strong>0x%1</strong> could not be accessed.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>").arg(edb::v1::format_pointer(fault_address))
);
case SIGILL:
return Message(
tr("Illegal Instruction Fault"),
tr(
"<p>The debugged application attempted to execute an illegal instruction.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
case SIGFPE:
switch(fault_code_) {
case FPE_INTDIV:
return Message(
tr("Divide By Zero"),
tr(
"<p>The debugged application tried to divide an integer value by an integer divisor of zero.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
default:
return Message(
tr("Floating Point Exception"),
tr(
"<p>The debugged application encountered a floating-point exception.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
}
case SIGABRT:
return Message(
tr("Application Aborted"),
tr(
"<p>The debugged application has aborted.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
case SIGBUS:
return Message(
tr("Bus Error"),
tr(
"<p>The debugged application tried to read or write data that is misaligned.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
#ifdef SIGSTKFLT
case SIGSTKFLT:
return Message(
tr("Stack Fault"),
tr(
"<p>The debugged application encountered a stack fault.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
#endif
case SIGPIPE:
return Message(
tr("Broken Pipe Fault"),
tr(
"<p>The debugged application encountered a broken pipe fault.</p>"
"<p>If you would like to pass this exception to the application press Shift+[F7/F8/F9]</p>")
);
default:
return Message();
}
}
示例3: TEST
TEST(CollectionOptions, UnknownOptionRejectedIfCreateOptionNotPresent) {
CollectionOptions options;
auto status = options.parse(fromjson("{invalidOption: 1}"));
ASSERT_NOT_OK(status);
ASSERT_EQ(status.code(), ErrorCodes::InvalidOptions);
}
示例4: repairDatabasesAndCheckVersion
//.........这里部分代码省略.........
}
const repl::ReplSettings& replSettings =
repl::ReplicationCoordinator::get(opCtx)->getSettings();
// On replica set members we only clear temp collections on DBs other than "local" during
// promotion to primary. On pure slaves, they are only cleared when the oplog tells them
// to. The local DB is special because it is not replicated. See SERVER-10927 for more
// details.
const bool shouldClearNonLocalTmpCollections =
!(hasReplSetConfigDoc(opCtx) || replSettings.usingReplSets());
// To check whether a featureCompatibilityVersion document exists.
bool fcvDocumentExists = false;
// To check whether we have databases other than local.
bool nonLocalDatabases = false;
// Refresh list of database names to include newly-created admin, if it exists.
dbNames = storageEngine->listDatabases();
for (const auto& dbName : dbNames) {
if (dbName != "local") {
nonLocalDatabases = true;
}
LOG(1) << " Recovering database: " << dbName;
auto db = databaseHolder->openDb(opCtx, dbName);
invariant(db);
// First thing after opening the database is to check for file compatibility,
// otherwise we might crash if this is a deprecated format.
auto status = storageEngine->currentFilesCompatible(opCtx);
if (!status.isOK()) {
if (status.code() == ErrorCodes::CanRepairToDowngrade) {
// Convert CanRepairToDowngrade statuses to MustUpgrade statuses to avoid logging a
// potentially confusing and inaccurate message.
//
// TODO SERVER-24097: Log a message informing the user that they can start the
// current version of mongod with --repair and then proceed with normal startup.
status = {ErrorCodes::MustUpgrade, status.reason()};
}
severe() << "Unable to start mongod due to an incompatibility with the data files and"
" this version of mongod: "
<< redact(status);
severe() << "Please consult our documentation when trying to downgrade to a previous"
" major release";
quickExit(EXIT_NEED_UPGRADE);
MONGO_UNREACHABLE;
}
// If the server configuration collection already contains a valid
// featureCompatibilityVersion document, cache it in-memory as a server parameter.
if (dbName == "admin") {
if (Collection* versionColl =
db->getCollection(opCtx, NamespaceString::kServerConfigurationNamespace)) {
BSONObj featureCompatibilityVersion;
if (Helpers::findOne(
opCtx,
versionColl,
BSON("_id" << FeatureCompatibilityVersionParser::kParameterName),
featureCompatibilityVersion)) {
auto swVersion =
FeatureCompatibilityVersionParser::parse(featureCompatibilityVersion);
// Note this error path captures all cases of an FCV document existing,
// but with any value other than "4.0" or "4.2". This includes unexpected
示例5: stopped
//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
bool PlatformEvent::is_stop() const {
return stopped() && code() == SIGSTOP;
}
示例6: set
//! Assign bit value at given square
//! @param sq square to assign value at
//! @param val boolean value to assign
void set(Square sq, bool val) {
if (val)
data_ |= data_type(1) << code(sq);
else
data_ &= ~(data_type(1) << code(sq));
}
示例7: assert
// Inform CodeBuffer that incoming code and relocation will be code
// Should not be called if start_a_stub() returned NULL
void AbstractAssembler::end_a_stub() {
assert(_code_section == code()->stubs(), "not in stubs?");
sync();
set_code_section(code()->insts());
}
示例8: DtoInlineAsmExpr
DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments)
{
Logger::println("DtoInlineAsmExpr @ %s", loc.toChars());
LOG_SCOPE;
TemplateInstance* ti = fd->toParent()->isTemplateInstance();
assert(ti && "invalid inline __asm expr");
assert(arguments->dim >= 2 && "invalid __asm call");
// get code param
Expression* e = static_cast<Expression*>(arguments->data[0]);
Logger::println("code exp: %s", e->toChars());
StringExp* se = static_cast<StringExp*>(e);
if (e->op != TOKstring || se->sz != 1)
{
e->error("__asm code argument is not a char[] string literal");
fatal();
}
std::string code(static_cast<char*>(se->string), se->len);
// get constraints param
e = static_cast<Expression*>(arguments->data[1]);
Logger::println("constraint exp: %s", e->toChars());
se = static_cast<StringExp*>(e);
if (e->op != TOKstring || se->sz != 1)
{
e->error("__asm constraints argument is not a char[] string literal");
fatal();
}
std::string constraints(static_cast<char*>(se->string), se->len);
// build runtime arguments
size_t n = arguments->dim;
LLSmallVector<llvm::Value*, 8> args;
args.reserve(n-2);
std::vector<LLType*> argtypes;
argtypes.reserve(n-2);
for (size_t i = 2; i < n; i++)
{
e = static_cast<Expression*>(arguments->data[i]);
args.push_back(e->toElem(gIR)->getRVal());
argtypes.push_back(args.back()->getType());
}
// build asm function type
Type* type = fd->type->nextOf()->toBasetype();
LLType* ret_type = DtoType(type);
llvm::FunctionType* FT = llvm::FunctionType::get(ret_type, argtypes, false);
// build asm call
bool sideeffect = true;
llvm::InlineAsm* ia = llvm::InlineAsm::get(FT, code, constraints, sideeffect);
llvm::Value* rv = gIR->ir->CreateCall(ia, args, "");
// work around missing tuple support for users of the return value
if (type->ty == Tstruct)
{
// make a copy
llvm::Value* mem = DtoAlloca(type, ".__asm_tuple_ret");
TypeStruct* ts = static_cast<TypeStruct*>(type);
size_t n = ts->sym->fields.dim;
for (size_t i = 0; i < n; i++)
{
llvm::Value* v = gIR->ir->CreateExtractValue(rv, i, "");
llvm::Value* gep = DtoGEPi(mem, 0, i);
DtoStore(v, gep);
}
return new DVarValue(fd->type->nextOf(), mem);
}
// return call as im value
return new DImValue(fd->type->nextOf(), rv);
}
示例9: codeToTree
bool codeToTree()
{
std::string code(
"?C1LDOPU<C4U!ALDOPU?aDOPU<a5O!EBO!N"
);
std::stringstream ss;
ss << std::setprecision(4) << std::fixed;
ss << "?V";
ss << 10.0f;
ss << "=V";
ss << 11.0f;
ss << "!AU!N";
std::string predefineValue(ss.str());
std::string errorNodeCode(
"VNTREZ"
);
std::string errorExtractorCode(
"?V10=Vab"
);
try
{
auto tree = Factory::treeFromCode(code);
std::string treeCode(tree.getIaCode());
if (treeCode != code)
{
std::cout << "IACode is different !!" << std::endl;
return false;
}
}
catch (Factory::FactoryException& fe)
{
std::cout << fe.what() << std::endl;
return false;
}
try
{
auto tree = Factory::treeFromCode(predefineValue);
auto treeCode = tree.getIaCode();
if (treeCode != predefineValue)
{
std::cout << "IACode is different for predefine value" << std::endl;
return false;
}
}
catch (Factory::FactoryException& fe)
{
std::cout << fe.what() << std::endl;
return false;
}
try
{
auto tree = Factory::treeFromCode(errorNodeCode);
std::cout << "No error found in error node code" << std::endl;
return false;
}
catch (Factory::FactoryException&)
{
std::cout << "Error found in error node code (it's normal)" << std::endl;
}
try
{
auto tree = Factory::treeFromCode(errorExtractorCode);
std::cout << "No error found in error extractor code" << std::endl;
return false;
}
catch (Factory::FactoryException&)
{
std::cout << "Error found in error extractor code (it's normal)" << std::endl;
}
return true;
}
示例10: strerror_r
String SystemException::message(){
char buf[XVR2_ERRNO_DESCRIPTION_MAXLEN];
strerror_r(code(), buf, XVR2_ERRNO_DESCRIPTION_MAXLEN);
return String(buf);
}
示例11: _runCommandForAddShard
StatusWith<ShardType> ShardingCatalogManagerImpl::_validateHostAsShard(
OperationContext* txn,
std::shared_ptr<RemoteCommandTargeter> targeter,
const std::string* shardProposedName,
const ConnectionString& connectionString) {
// Check whether any host in the connection is already part of the cluster.
Grid::get(txn)->shardRegistry()->reload(txn);
for (const auto& hostAndPort : connectionString.getServers()) {
std::shared_ptr<Shard> shard;
shard = Grid::get(txn)->shardRegistry()->getShardNoReload(hostAndPort.toString());
if (shard) {
return {ErrorCodes::OperationFailed,
str::stream() << "'" << hostAndPort.toString() << "' "
<< "is already a member of the existing shard '"
<< shard->getConnString().toString()
<< "' ("
<< shard->getId()
<< ")."};
}
}
// Check for mongos and older version mongod connections, and whether the hosts
// can be found for the user specified replset.
auto swCommandResponse =
_runCommandForAddShard(txn, targeter.get(), "admin", BSON("isMaster" << 1));
if (!swCommandResponse.isOK()) {
if (swCommandResponse.getStatus() == ErrorCodes::RPCProtocolNegotiationFailed) {
// Mongos to mongos commands are no longer supported in the wire protocol
// (because mongos does not support OP_COMMAND), similarly for a new mongos
// and an old mongod. So the call will fail in such cases.
// TODO: If/When mongos ever supports opCommands, this logic will break because
// cmdStatus will be OK.
return {ErrorCodes::RPCProtocolNegotiationFailed,
str::stream() << targeter->connectionString().toString()
<< " does not recognize the RPC protocol being used. This is"
<< " likely because it contains a node that is a mongos or an old"
<< " version of mongod."};
} else {
return swCommandResponse.getStatus();
}
}
// Check for a command response error
auto resIsMasterStatus = std::move(swCommandResponse.getValue().commandStatus);
if (!resIsMasterStatus.isOK()) {
return {resIsMasterStatus.code(),
str::stream() << "Error running isMaster against "
<< targeter->connectionString().toString()
<< ": "
<< causedBy(resIsMasterStatus)};
}
auto resIsMaster = std::move(swCommandResponse.getValue().response);
// Check whether there is a master. If there isn't, the replica set may not have been
// initiated. If the connection is a standalone, it will return true for isMaster.
bool isMaster;
Status status = bsonExtractBooleanField(resIsMaster, "ismaster", &isMaster);
if (!status.isOK()) {
return Status(status.code(),
str::stream() << "isMaster returned invalid 'ismaster' "
<< "field when attempting to add "
<< connectionString.toString()
<< " as a shard: "
<< status.reason());
}
if (!isMaster) {
return {ErrorCodes::NotMaster,
str::stream()
<< connectionString.toString()
<< " does not have a master. If this is a replica set, ensure that it has a"
<< " healthy primary and that the set has been properly initiated."};
}
const string providedSetName = connectionString.getSetName();
const string foundSetName = resIsMaster["setName"].str();
// Make sure the specified replica set name (if any) matches the actual shard's replica set
if (providedSetName.empty() && !foundSetName.empty()) {
return {ErrorCodes::OperationFailed,
str::stream() << "host is part of set " << foundSetName << "; "
<< "use replica set url format "
<< "<setname>/<server1>,<server2>, ..."};
}
if (!providedSetName.empty() && foundSetName.empty()) {
return {ErrorCodes::OperationFailed,
str::stream() << "host did not return a set name; "
<< "is the replica set still initializing? "
<< resIsMaster};
}
// Make sure the set name specified in the connection string matches the one where its hosts
// belong into
if (!providedSetName.empty() && (providedSetName != foundSetName)) {
return {ErrorCodes::OperationFailed,
str::stream() << "the provided connection string (" << connectionString.toString()
<< ") does not match the actual set name "
<< foundSetName};
}
//.........这里部分代码省略.........
示例12: ATF_TC_BODY
ATF_TC_BODY(bpfjit_copx_ret_preinited_mem, tc)
{
static struct bpf_insn insns[] = {
BPF_STMT(BPF_LD+BPF_IMM, 13),
BPF_STMT(BPF_ST, 2),
BPF_STMT(BPF_LD+BPF_IMM, 137),
BPF_STMT(BPF_ST, 1),
BPF_STMT(BPF_LDX+BPF_IMM, 0), // retM
BPF_STMT(BPF_MISC+BPF_COPX, 0),
BPF_STMT(BPF_RET+BPF_A, 0)
};
bpfjit_func_t code;
uint8_t pkt[1] = { 0 };
uint32_t mem[ctx.extwords];
void *arg = (void*)(uintptr_t)3;
/* Pre-inited words. */
mem[0] = 0;
mem[3] = 3;
bpf_args_t args = {
.pkt = pkt,
.buflen = sizeof(pkt),
.wirelen = sizeof(pkt),
.arg = arg,
.mem = mem,
};
size_t insn_count = sizeof(insns) / sizeof(insns[0]);
RZ(rump_init());
rump_schedule();
code = rumpns_bpfjit_generate_code(&ctx, insns, insn_count);
rump_unschedule();
ATF_REQUIRE(code != NULL);
ATF_CHECK(code(&ctx, &args) == 3);
rump_schedule();
rumpns_bpfjit_free_code(code);
rump_unschedule();
}
ATF_TP_ADD_TCS(tp)
{
/*
* For every new test please also add a similar test
* to ../../lib/libbpfjit/t_extmem.c
*/
//ATF_TP_ADD_TC(tp, bpfjit_extmem_load_default);
ATF_TP_ADD_TC(tp, bpfjit_extmem_load_preinited);
ATF_TP_ADD_TC(tp, bpfjit_extmem_invalid_load);
ATF_TP_ADD_TC(tp, bpfjit_extmem_store);
ATF_TP_ADD_TC(tp, bpfjit_extmem_side_effect);
ATF_TP_ADD_TC(tp, bpfjit_extmem_invalid_store);
ATF_TP_ADD_TC(tp, bpfjit_cop_ret_mem);
ATF_TP_ADD_TC(tp, bpfjit_cop_ret_preinited_mem);
ATF_TP_ADD_TC(tp, bpfjit_copx_ret_mem);
ATF_TP_ADD_TC(tp, bpfjit_copx_ret_preinited_mem);
return atf_no_error();
}
示例13: code
std::string Patch::patchCode() const
{
return code(_table_name);
}
示例14: create_request
static ngx_int_t
create_request(ngx_http_request_t *r)
{
u_char ch;
const char * helper_agent_request_socket_password_data;
unsigned int helper_agent_request_socket_password_len;
u_char buf[sizeof("4294967296")];
size_t len, size, key_len, val_len, content_length;
const u_char *app_type_string;
size_t app_type_string_len;
int server_name_len;
ngx_str_t escaped_uri;
ngx_str_t *union_station_filters = NULL;
u_char min_instances_string[12];
u_char max_requests_string[12];
u_char max_preloader_idle_time_string[12];
u_char *end;
void *tmp;
ngx_uint_t i, n;
ngx_buf_t *b;
ngx_chain_t *cl, *body;
ngx_list_part_t *part;
ngx_table_elt_t *header;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
ngx_http_core_srv_conf_t *cscf;
passenger_loc_conf_t *slcf;
passenger_context_t *context;
ngx_http_script_len_code_pt lcode;
#if (NGX_HTTP_SSL)
ngx_http_ssl_srv_conf_t *ssl_conf;
#endif
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
slcf = ngx_http_get_module_loc_conf(r, ngx_http_passenger_module);
context = ngx_http_get_module_ctx(r, ngx_http_passenger_module);
if (context == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
switch (context->app_type) {
case AP_CLASSIC_RAILS:
app_type_string = (const u_char *) "classic-rails";
app_type_string_len = sizeof("classic-rails");
break;
case AP_RACK:
app_type_string = (const u_char *) "rack";
app_type_string_len = sizeof("rack");
break;
case AP_WSGI:
app_type_string = (const u_char *) "wsgi";
app_type_string_len = sizeof("wsgi");
break;
default:
app_type_string = (const u_char *) "rack";
app_type_string_len = sizeof("rack");
break;
}
/*
* Nginx unescapes URI's before passing them to Phusion Passenger,
* but backend processes expect the escaped version.
* http://code.google.com/p/phusion-passenger/issues/detail?id=404
*/
escaped_uri.len =
2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len, NGX_ESCAPE_URI)
+ r->uri.len;
escaped_uri.data = ngx_pnalloc(r->pool, escaped_uri.len + 1);
escaped_uri.data[escaped_uri.len] = '\0';
ngx_escape_uri(escaped_uri.data, r->uri.data, r->uri.len, NGX_ESCAPE_URI);
/**************************************************
* Determine the request header length.
**************************************************/
/* Length of the Content-Length header. */
if (r->headers_in.content_length_n < 0) {
content_length = 0;
} else {
content_length = r->headers_in.content_length_n;
}
uint_to_str(content_length, buf, sizeof(buf));
/* +1 for trailing null */
len = sizeof("CONTENT_LENGTH") + ngx_strlen(buf) + 1;
/* DOCUMENT_ROOT, SCRIPT_NAME, RAILS_RELATIVE_URL_ROOT, PATH_INFO and REQUEST_URI. */
len += sizeof("DOCUMENT_ROOT") + context->public_dir.len + 1;
if (context->base_uri.len > 0) {
len += sizeof("SCRIPT_NAME") + context->base_uri.len + 1;
len += sizeof("RAILS_RELATIVE_URL_ROOT") +
context->base_uri.len + 1;
len += sizeof("PATH_INFO") + escaped_uri.len - context->base_uri.len + 1;
} else {
len += sizeof("SCRIPT_NAME") + sizeof("");
len += sizeof("PATH_INFO") + escaped_uri.len + 1;
}
len += sizeof("REQUEST_URI") + escaped_uri.len + 1;
if (r->args.len > 0) {
//.........这里部分代码省略.........
示例15: ngx_http_internal_redirect_handler
static ngx_int_t
ngx_http_internal_redirect_handler(ngx_http_request_t *r)
{
u_char *p;
ngx_uint_t i;
ngx_str_t uri, args;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e;
ngx_http_variable_value_t stack[10];
ngx_http_internal_redirect_entry_t *redirects;
ngx_http_internal_redirect_main_conf_t *imcf;
ngx_http_internal_redirect_loc_conf_t *ilcf;
ngx_http_core_main_conf_t *cmcf;
ngx_http_phase_handler_t *ph, *cur_ph, *last_ph, tmp;
imcf = ngx_http_get_module_main_conf(r, ngx_http_internal_redirect_module);
if (!imcf->postponed) {
imcf->postponed = 1;
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
ph = cmcf->phase_engine.handlers;
cur_ph = &ph[r->phase_handler];
last_ph = &ph[cur_ph->next - 1];
if (cur_ph < last_ph) {
tmp = *cur_ph;
ngx_memmove(cur_ph, cur_ph + 1,
(last_ph - cur_ph) * sizeof(ngx_http_phase_handler_t));
*last_ph = tmp;
r->phase_handler--; /* redo the current ph */
return NGX_DECLINED;
}
}
ilcf = ngx_http_get_module_loc_conf(r, ngx_http_internal_redirect_module);
if (ilcf->redirects == NULL) {
return NGX_DECLINED;
}
redirects = ilcf->redirects->elts;
for (i = 0; i < ilcf->redirects->nelts; i++) {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
ngx_memzero(&stack, sizeof(stack));
e.sp = stack;
e.ip = redirects[i].codes->elts;
e.request = r;
e.quote = 1;
e.log = 1;
e.status = NGX_DECLINED;
while (*(uintptr_t *) e.ip) {
code = *(ngx_http_script_code_pt *) e.ip;
code(&e);
}
e.sp--;
if (e.sp->len && (e.sp->len != 1 || e.sp->data[0] != '0')) {
break;
}
}
if (i == ilcf->redirects->nelts) {
return NGX_DECLINED;
}
if (redirects[i].code) {
return redirects[i].code;
}
if (redirects[i].lengths) {
if (ngx_http_script_run(r, &uri, redirects[i].lengths->elts, 0,
redirects->values->elts)
== NULL)
{
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
} else {
uri = redirects[i].name;
}
if (uri.data[0] == '@') {
(void) ngx_http_named_location(r, &uri);
} else {
if (uri.data[0] != '/') {
p = ngx_pcalloc(r->pool, uri.len + 1);
if (p == NULL) {
//.........这里部分代码省略.........