本文整理汇总了C++中php_request_startup函数的典型用法代码示例。如果您正苦于以下问题:C++ php_request_startup函数的具体用法?C++ php_request_startup怎么用?C++ php_request_startup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_request_startup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: malloc
engine_context *context_new(php_engine *engine, void *parent) {
engine_context *context;
#ifdef ZTS
void ***tsrm_ls = engine->tsrm_ls;
#endif
// Initialize context.
context = (engine_context *) malloc((sizeof(engine_context)));
if (context == NULL) {
return_multi(NULL, 1);
}
context->engine = engine;
context->parent = parent;
SG(server_context) = (void *) context;
// Initialize request lifecycle.
if (php_request_startup(TSRMLS_C) == FAILURE) {
SG(server_context) = NULL;
free(context);
return_multi(NULL, 1);
}
return_multi(context, 0);
}
开发者ID:deuill,项目名称:sigil,代码行数:28,代码来源:context.c
示例2: apache_php_module_main
/* {{{ apache_php_module_main
*/
int apache_php_module_main(request_rec *r, int display_source_mode)
{
zend_file_handle file_handle;
if (php_request_startup() == FAILURE) {
return FAILURE;
}
/* sending a file handle to another dll is not working
so let zend open it. */
if (display_source_mode) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
php_get_highlight_struct(&syntax_highlighter_ini);
if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini)){
return OK;
} else {
return NOT_FOUND;
}
} else {
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.handle.fd = 0;
file_handle.filename = SG(request_info).path_translated;
file_handle.opened_path = NULL;
file_handle.free_filename = 0;
(void) php_execute_script(&file_handle);
}
AP(in_request) = 0;
return (OK);
}
开发者ID:chosen1,项目名称:php-src,代码行数:33,代码来源:sapi_apache.c
示例3: lsapi_module_main
static int lsapi_module_main(int show_source)
{
zend_file_handle file_handle = {0};
if (php_request_startup() == FAILURE ) {
return -1;
}
if (parse_user_ini && lsapi_activate_user_ini() == FAILURE) {
return -1;
}
if (show_source) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
php_get_highlight_struct(&syntax_highlighter_ini);
highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini);
} else {
lsapi_execute_script( &file_handle);
}
zend_try {
php_request_shutdown(NULL);
memset( argv0, 0, 46 );
} zend_end_try();
return 0;
}
开发者ID:stamhe,项目名称:php-src,代码行数:26,代码来源:lsapi_main.c
示例4: mlfi_close
/* {{{ mlfi_close()
*/
static sfsistat mlfi_close(SMFICTX *ctx)
{
int ret = SMFIS_CONTINUE;
zval function_name, retval;
int status;
TSRMLS_FETCH();
if (!SG(sapi_started) && SUCCESS != php_request_startup(TSRMLS_C)) {
return ret;
}
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_close", 0);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CLOSE;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:KomaBeyond,项目名称:php-src,代码行数:33,代码来源:php_milter.c
示例5: mlfi_connect
/* {{{ mlfi_connect()
*/
static sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
{
zend_file_handle file_handle;
zval function_name, retval, *param[1];
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return SMFIS_TEMPFAIL;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
INIT_PZVAL(param[0]);
ZVAL_STRING(&function_name, "milter_connect", 0);
ZVAL_STRING(param[0], hostname, 1);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CONNECT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(param);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:62,代码来源:php_milter.c
示例6: PQDBG_LVL_START
void *PlastiQThreadCreator::get_tsrmls_cache(QThread *thread)
{
void *tsrmls_cache = threads.value(thread, Q_NULLPTR);
//QThread *old_thread = this->thread();
if(!tsrmls_cache) {
#ifdef PQDEBUG
PQDBG_LVL_START(__FUNCTION__);
#endif
//void *old_tsrmls_cache = tsrm_get_ls_cache();
//this->moveToThread(thread);
PQDBGLPUP("tsrm_new_interpreter_context");
tsrmls_cache = tsrm_new_interpreter_context();
//PQDBGLPUP("tsrm_set_interpreter_context");
//tsrm_set_interpreter_context(tsrmls_cache);
PQDBGLPUP("php_request_startup");
php_request_startup();
connect(thread, SIGNAL(destroyed(QObject*)), this, SLOT(free_tsrmls_cache(QObject*)));
threads.insert(thread, tsrmls_cache);
//this->moveToThread(old_thread);
//PQDBGLPUP("tsrm_set_interpreter_context");
//tsrm_set_interpreter_context(old_tsrmls_cache);
PQDBG_LVL_DONE();
}
开发者ID:wxmaper,项目名称:PQEngine,代码行数:32,代码来源:plastiqthreadcreator.cpp
示例7: exec_php
/**
* Gets the contents of the BLOB b and offers it to Zend for parsing/execution
*/
void exec_php(BLOBCALLBACK b, PARAMDSC *res, ISC_SHORT *init)
{
int result, remaining = b->blob_total_length, i = 0;
char *code = pemalloc(remaining+1, 1);
ISC_USHORT read;
for (code[remaining] = '\0'; remaining > 0; remaining -= read)
b->blob_get_segment(b->blob_handle, &code[i++<<16],min(0x10000,remaining), &read);
LOCK();
switch (init && *init) {
default:
#ifdef PHP_EMBED
php_request_shutdown(NULL);
if (FAILURE == (result = php_request_startup(TSRMLS_C))) {
break;
}
case 0:
#endif
/* feed it to the parser */
zend_first_try {
result = zend_eval_stringl(code, b->blob_total_length, NULL, "Firebird Embedded PHP engine" TSRMLS_CC);
} zend_end_try();
}
UNLOCK();
free(code);
res->dsc_dtype = dtype_long;
*(ISC_LONG*)res->dsc_address = (result == SUCCESS);
}
开发者ID:1HLtd,项目名称:php-src,代码行数:37,代码来源:php_ibase_udf.c
示例8: mlfi_init
/* {{{ Init Milter
*/
static int mlfi_init()
{
int ret = 0;
zend_file_handle file_handle;
zval function_name, retval;
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return -1;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_init", 0);
/* set the milter context for possible use in API functions */
MG(state) = MLFI_INIT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
MG(initialized) = 1;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:61,代码来源:php_milter.c
示例9: webjames_module_main
static void webjames_module_main(void)
{
zend_file_handle file_handle;
FILE *fp=NULL;
char *path;
/* Convert filename to Unix format*/
__riscosify_control|=__RISCOSIFY_STRICT_UNIX_SPECS;
path = __unixify(WG(conn)->filename,0,NULL,1024,0);
if (path) SG(request_info).path_translated = estrdup(path);
SG(request_info).query_string = WG(conn)->args;
SG(request_info).request_uri = WG(conn)->requesturi;
SG(request_info).request_method = WG(conn)->methodstr;
if (WG(conn)->method==METHOD_HEAD) {
SG(request_info).headers_only = 1;
} else {
SG(request_info).headers_only = 0;
}
SG(sapi_headers).http_response_code = 200;
SG(request_info).content_type = WG(conn)->type;
SG(request_info).content_length = WG(conn)->bodysize;
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
if (WG(conn)->authorization) {
char *colon=strchr(WG(conn)->authorization,':');
if (colon) {
SG(request_info).auth_user = emalloc(colon-WG(conn)->authorization+1);
if (SG(request_info).auth_user) {
memcpy(SG(request_info).auth_user,WG(conn)->authorization,colon-WG(conn)->authorization);
SG(request_info).auth_user[colon-WG(conn)->authorization]='\0';
SG(request_info).auth_password = estrdup(colon+1);
}
}
}
/*ensure that syslog calls get logged separately from WebJames' main log */
openlog("PHP",0,0);
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
if (php_request_startup() == FAILURE) {
return;
}
php_execute_script(&file_handle);
php_request_shutdown(NULL);
}
开发者ID:chosen1,项目名称:php-src,代码行数:52,代码来源:webjames.c
示例10: capi_module_main
int capi_module_main(NSLS_D)
{
zend_file_handle file_handle;
if (php_request_startup() == FAILURE) {
return FAILURE;
}
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle);
php_request_shutdown(NULL);
return SUCCESS;
}
开发者ID:slusarz,项目名称:php-src,代码行数:17,代码来源:capi.c
示例11: execPhpScript
int
execPhpScript( char *scrFile, int scrArgc, char **scrArgv ) {
zend_file_handle file_handle;
int status = 0;
int lineno = 0;
if ( ( status = php_seek_file_begin( &file_handle, scrFile, &lineno TSRMLS_CC ) )
< 0 ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_seek_file_begin error for %s", scrFile );
return status;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.opened_path = NULL;
file_handle.free_filename = 0;
SG( request_info ).argc = scrArgc;
SG( request_info ).path_translated = file_handle.filename;
SG( request_info ).argv = scrArgv;
if ( php_request_startup( TSRMLS_C ) == FAILURE ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_request_startup error for %s", scrFile );
fclose( file_handle.handle.fp );
return PHP_REQUEST_STARTUP_ERR;
}
CG( start_lineno ) = lineno;
zend_is_auto_global( "_SERVER", sizeof( "_SERVER" ) - 1 TSRMLS_CC );
PG( during_request_startup ) = 0;
php_execute_script( &file_handle TSRMLS_CC );
status = EG( exit_status );
if ( status != SUCCESS ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_execute_script error for %s", scrFile );
status = PHP_EXEC_SCRIPT_ERR;
}
php_request_shutdown( ( void * ) 0 );
return status;
}
开发者ID:bpow,项目名称:irods,代码行数:43,代码来源:phptest.cpp
示例12: php_ns_module_main
static int
php_ns_module_main(void)
{
zend_file_handle file_handle;
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_ns_config(global_context, 0);
if (php_request_startup() == FAILURE) {
return NS_ERROR;
}
php_execute_script(&file_handle);
php_request_shutdown(NULL);
return NS_OK;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:20,代码来源:aolserver.c
示例13: php_apache_request_ctor
static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx)
{
char *content_type;
char *content_length;
const char *auth;
PG(during_request_startup) = 0;
SG(sapi_headers).http_response_code = !f->r->status ? HTTP_OK : f->r->status;
SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type");
#undef safe_strdup
#define safe_strdup(x) ((x)?strdup((x)):NULL)
SG(request_info).query_string = safe_strdup(f->r->args);
SG(request_info).request_method = f->r->method;
SG(request_info).proto_num = f->r->proto_num;
SG(request_info).request_uri = safe_strdup(f->r->uri);
SG(request_info).path_translated = safe_strdup(f->r->filename);
f->r->no_local_copy = 1;
content_type = sapi_get_default_content_type();
f->r->content_type = apr_pstrdup(f->r->pool, content_type);
efree(content_type);
content_length = (char *) apr_table_get(f->r->headers_in, "Content-Length");
SG(request_info).content_length = (content_length ? atol(content_length) : 0);
apr_table_unset(f->r->headers_out, "Content-Length");
apr_table_unset(f->r->headers_out, "Last-Modified");
apr_table_unset(f->r->headers_out, "Expires");
apr_table_unset(f->r->headers_out, "ETag");
auth = apr_table_get(f->r->headers_in, "Authorization");
php_handle_auth_data(auth);
if (SG(request_info).auth_user == NULL && f->r->user) {
SG(request_info).auth_user = estrdup(f->r->user);
}
ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user);
php_request_startup();
}
开发者ID:chosen1,项目名称:php-src,代码行数:41,代码来源:sapi_apache2.c
示例14: php_apache_request_ctor
static int php_apache_request_ctor(request_rec *r, php_struct *ctx)
{
char *content_length;
const char *auth;
SG(sapi_headers).http_response_code = !r->status ? HTTP_OK : r->status;
SG(request_info).content_type = apr_table_get(r->headers_in, "Content-Type");
SG(request_info).query_string = apr_pstrdup(r->pool, r->args);
SG(request_info).request_method = r->method;
SG(request_info).proto_num = r->proto_num;
SG(request_info).request_uri = apr_pstrdup(r->pool, r->uri);
SG(request_info).path_translated = apr_pstrdup(r->pool, r->filename);
r->no_local_copy = 1;
content_length = (char *) apr_table_get(r->headers_in, "Content-Length");
if (content_length) {
ZEND_ATOL(SG(request_info).content_length, content_length);
} else {
SG(request_info).content_length = 0;
}
apr_table_unset(r->headers_out, "Content-Length");
apr_table_unset(r->headers_out, "Last-Modified");
apr_table_unset(r->headers_out, "Expires");
apr_table_unset(r->headers_out, "ETag");
auth = apr_table_get(r->headers_in, "Authorization");
php_handle_auth_data(auth);
if (SG(request_info).auth_user == NULL && r->user) {
SG(request_info).auth_user = estrdup(r->user);
}
ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user);
return php_request_startup();
}
开发者ID:SammyK,项目名称:php-src,代码行数:37,代码来源:sapi_apache2.c
示例15: apache_php_module_main
/* {{{ apache_php_module_main
*/
int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
{
int retval = OK;
zend_file_handle file_handle;
if (php_request_startup(TSRMLS_C) == FAILURE) {
return FAILURE;
}
/* sending a file handle to another dll is not working
so let zend open it. */
if (display_source_mode) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
php_get_highlight_struct(&syntax_highlighter_ini);
if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC) != SUCCESS) {
retval = NOT_FOUND;
}
} else {
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.handle.fd = 0;
file_handle.filename = SG(request_info).path_translated;
file_handle.opened_path = NULL;
file_handle.free_filename = 0;
(void) php_execute_script(&file_handle TSRMLS_CC);
}
AP(in_request) = 0;
zend_try {
php_request_shutdown(NULL);
} zend_end_try();
return retval;
}
开发者ID:austintgriffith,项目名称:php7,代码行数:38,代码来源:sapi_apache.c
示例16: malloc
engine_context *context_new() {
engine_context *context;
// Initialize context.
context = malloc((sizeof(engine_context)));
if (context == NULL) {
errno = 1;
return NULL;
}
SG(server_context) = context;
// Initialize request lifecycle.
if (php_request_startup() == FAILURE) {
SG(server_context) = NULL;
free(context);
errno = 1;
return NULL;
}
errno = 0;
return context;
}
开发者ID:alash3al,项目名称:go-php,代码行数:24,代码来源:context.c
示例17: TSRMLS_FETCH
int MaPhp4Handler::run(MaRequest *rq)
{
MaDataStream *dynBuf;
MprHashTable *env;
MprStringHashEntry *vp;
int flags, contentLength;
hitCount++;
flags= rq->getFlags();
dynBuf = rq->getDynBuf();
rq->insertDataStream(dynBuf);
rq->setResponseCode(200);
rq->setHeaderFlags(MPR_HTTP_DONT_CACHE);
rq->setPullPost();
//
// Initialize PHP
//
TSRMLS_FETCH();
zend_first_try {
phpInitialized = 0;
func_data = rq;
var_array = 0;
SG(server_context) = rq;
SG(request_info).path_translated = rq->getFileName();
SG(request_info).request_method = rq->getMethod();
SG(request_info).request_uri = rq->getUri();
SG(request_info).query_string = rq->getQueryString();
SG(request_info).content_type = rq->getRequestContentMimeType();
SG(request_info).content_length = rq->getContentLength();
SG(sapi_headers).http_response_code = 200;
SG(request_info).auth_user = rq->getUser();
SG(request_info).auth_password = rq->getPassword();
php_request_startup(TSRMLS_C);
CG(zend_lineno) = 0;
} zend_catch {
mprLog(1, log, "PHP startup failed\n");
zend_try {
php_request_shutdown(0);
} zend_end_try();
rq->requestError(MPR_HTTP_INTERNAL_SERVER_ERROR,
"PHP initialization failed");
return MPR_HTTP_HANDLER_FINISHED_PROCESSING;
} zend_end_try();
phpInitialized = 1;
//
// Copy the environment variables to the PHP script engine
//
env = rq->getEnv();
vp = (MprStringHashEntry*) env->getFirst();
while (vp) {
php_register_variable(vp->getKey(), vp->getValue(),
var_array TSRMLS_CC);
vp = (MprStringHashEntry*) env->getNext(vp);
}
//
// Execute the PHP script
//
if (execScript(rq) < 0) {
zend_try {
php_request_shutdown(0);
} zend_end_try();
rq->requestError(MPR_HTTP_INTERNAL_SERVER_ERROR,
"PHP script execution failed");
return MPR_HTTP_HANDLER_FINISHED_PROCESSING;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:78,代码来源:php4Handler.cpp
示例18: main
//.........这里部分代码省略.........
case 'C': /* don't chdir to the script directory */
/* This is default so NOP */
break;
case 'd': /* define ini entries on command line */
define_command_line_ini_entry(ap_php_optarg);
break;
case 'D': /* daemon */
dofork = 1;
break;
case 'e': /* enable extended info output */
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
break;
case 'f': /* parse file */
filename = ap_php_optarg;
break;
case 'h': /* help & quit */
case '?':
php_output_tearup();
SG(headers_sent) = 1;
php_milter_usage(argv[0]);
php_output_teardown();
exit(1);
break;
case 'p': /* socket */
sock = strdup(ap_php_optarg);
break;
case 'v': /* show php version & quit */
if (php_request_startup()==FAILURE) {
zend_ini_deactivate();
php_module_shutdown();
sapi_shutdown();
tsrm_shutdown();
exit(1);
}
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
php_output_teardown();
exit(1);
break;
case 'V': /* verbose */
flag_debug = atoi(ap_php_optarg);
break;
case 'z': /* load extension file */
zend_load_extension(ap_php_optarg);
break;
default:
break;
}
}
if (param_error) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
PUTS(param_error);
exit(1);
开发者ID:AmesianX,项目名称:php-src,代码行数:67,代码来源:php_milter.c
示例19: setThreadNotRunning
//.........这里部分代码省略.........
return;
}
if(exitCode) *exitCode = -1;
if(!GD::bl->io.fileExists(path))
{
GD::out.printError("Error: PHP script \"" + path + "\" does not exist.");
setThreadNotRunning(threadId);
return;
}
ts_resource_ex(0, NULL); //Replaces TSRMLS_FETCH()
try
{
zend_file_handle script;
/* Set up a File Handle structure */
script.type = ZEND_HANDLE_FILENAME;
script.filename = path.c_str();
script.opened_path = NULL;
script.free_filename = 0;
zend_homegear_globals* globals = php_homegear_get_globals();
if(!globals)
{
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
globals->output = output.get();
globals->commandLine = true;
globals->cookiesParsed = true;
if(!tsrm_get_ls_cache() || !((sapi_globals_struct *) (*((void ***) tsrm_get_ls_cache()))[((sapi_globals_id)-1)]) || !((php_core_globals *) (*((void ***) tsrm_get_ls_cache()))[((core_globals_id)-1)]))
{
GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists.");
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
PG(register_argc_argv) = 1;
SG(server_context) = (void*)output.get(); //Must be defined! Otherwise php_homegear_activate is not called.
SG(options) |= SAPI_OPTION_NO_CHDIR;
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
SG(default_mimetype) = nullptr;
SG(default_charset) = nullptr;
SG(request_info).path_translated = estrndup(path.c_str(), path.size());
if (php_request_startup(TSRMLS_C) == FAILURE) {
GD::bl->out.printError("Error calling php_request_startup...");
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
std::vector<std::string> argv = getArgs(path, arguments);
php_homegear_build_argv(argv);
SG(request_info).argc = argv.size();
SG(request_info).argv = (char**)malloc((argv.size() + 1) * sizeof(char*));
for(uint32_t i = 0; i < argv.size(); ++i)
{
SG(request_info).argv[i] = (char*)argv[i].c_str(); //Value is not modified.
}
SG(request_info).argv[argv.size()] = nullptr;
php_execute_script(&script);
if(exitCode) *exitCode = EG(exit_status);
php_request_shutdown(NULL);
if(output->size() > 0)
{
std::string outputString(&output->at(0), output->size());
if(BaseLib::HelperFunctions::trim(outputString).size() > 0) GD::out.printMessage("Script output:\n" + outputString);
}
}
catch(const std::exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(BaseLib::Exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
if(SG(request_info).path_translated)
{
efree(SG(request_info).query_string);
SG(request_info).query_string = nullptr;
}
if(SG(request_info).argv)
{
free(SG(request_info).argv);
SG(request_info).argv = nullptr;
}
SG(request_info).argc = 0;
ts_free_thread();
setThreadNotRunning(threadId);
}
开发者ID:pauxus,项目名称:Homegear,代码行数:101,代码来源:ScriptEngine.cpp
示例20: do_cli
static int do_cli(int argc, char **argv) /* {{{ */
{
int c;
zend_file_handle file_handle;
int behavior = PHP_MODE_STANDARD;
char *reflection_what = NULL;
volatile int request_started = 0;
volatile int exit_status = 0;
char *php_optarg = NULL, *orig_optarg = NULL;
int php_optind = 1, orig_optind = 1;
char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
char *arg_free=NULL, **arg_excp=&arg_free;
char *script_file=NULL, *translated_path = NULL;
int interactive=0;
int lineno = 0;
const char *param_error=NULL;
int hide_argv = 0;
zend_try {
CG(in_compilation) = 0; /* not initialized but needed for several options */
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'i': /* php info & quit */
if (php_request_startup()==FAILURE) {
goto err;
}
request_started = 1;
php_print_info(0xFFFFFFFF);
php_output_end_all();
exit_status = (c == '?' && argc > 1 && !strchr(argv[1], c));
goto out;
case 'v': /* show php version & quit */
php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) 1997-2016 The PHP Group\n%s",
PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__,
#if ZTS
"ZTS "
#else
"NTS "
#endif
#if ZEND_DEBUG
"DEBUG "
#endif
#ifdef HAVE_GCOV
"GCOV "
#endif
,
get_zend_version()
);
sapi_deactivate();
goto out;
case 'm': /* list compiled in modules */
if (php_request_startup()==FAILURE) {
goto err;
}
request_started = 1;
php_printf("[PHP Modules]\n");
print_modules();
php_printf("\n[Zend Modules]\n");
print_extensions();
php_printf("\n");
php_output_end_all();
exit_status=0;
goto out;
default:
break;
}
}
/* Set some CLI defaults */
SG(options) |= SAPI_OPTION_NO_CHDIR;
php_optind = orig_optind;
php_optarg = orig_optarg;
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
case 'a': /* interactive mode */
if (!interactive) {
if (behavior != PHP_MODE_STANDARD) {
param_error = param_mode_conflict;
break;
}
interactive=1;
}
break;
case 'C': /* don't chdir to the script directory */
/* This is default so NOP */
break;
case 'F':
if (behavior == PHP_MODE_PROCESS_STDIN) {
if (exec_run || script_file) {
//.........这里部分代码省略.........
开发者ID:EleTeam,项目名称:php-src,代码行数:101,代码来源:php_cli.c
注:本文中的php_request_startup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论