version 1.1, 2012/02/21 23:48:02
|
version 1.1.1.3, 2013/07/22 01:32:05
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 36
|
Line 36
|
#include "basic_functions.h" |
#include "basic_functions.h" |
#include "php_ext_syslog.h" |
#include "php_ext_syslog.h" |
|
|
static void start_syslog(TSRMLS_D); |
|
|
|
/* {{{ PHP_MINIT_FUNCTION |
/* {{{ PHP_MINIT_FUNCTION |
*/ |
*/ |
PHP_MINIT_FUNCTION(syslog) |
PHP_MINIT_FUNCTION(syslog) |
{ |
{ |
#if !SUHOSIN_PATCH |
|
/* error levels */ |
/* error levels */ |
REGISTER_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */ |
REGISTER_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */ |
REGISTER_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */ |
REGISTER_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */ |
Line 98 PHP_MINIT_FUNCTION(syslog)
|
Line 95 PHP_MINIT_FUNCTION(syslog)
|
/* AIX doesn't have LOG_PERROR */ |
/* AIX doesn't have LOG_PERROR */ |
REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/ |
REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/ |
#endif |
#endif |
#endif |
|
BG(syslog_device)=NULL; |
BG(syslog_device)=NULL; |
|
|
return SUCCESS; |
return SUCCESS; |
Line 107 PHP_MINIT_FUNCTION(syslog)
|
Line 103 PHP_MINIT_FUNCTION(syslog)
|
|
|
PHP_RINIT_FUNCTION(syslog) |
PHP_RINIT_FUNCTION(syslog) |
{ |
{ |
if (INI_INT("define_syslog_variables")) { |
|
start_syslog(TSRMLS_C); |
|
} else { |
|
BG(syslog_started)=0; |
|
} |
|
BG(syslog_device) = NULL; |
BG(syslog_device) = NULL; |
return SUCCESS; |
return SUCCESS; |
} |
} |
Line 134 PHP_MSHUTDOWN_FUNCTION(syslog)
|
Line 125 PHP_MSHUTDOWN_FUNCTION(syslog)
|
return SUCCESS; |
return SUCCESS; |
} |
} |
|
|
/* {{{ start_syslog |
|
*/ |
|
static void start_syslog(TSRMLS_D) |
|
{ |
|
/* error levels */ |
|
SET_VAR_LONG("LOG_EMERG", LOG_EMERG); /* system unusable */ |
|
SET_VAR_LONG("LOG_ALERT", LOG_ALERT); /* immediate action required */ |
|
SET_VAR_LONG("LOG_CRIT", LOG_CRIT); /* critical conditions */ |
|
SET_VAR_LONG("LOG_ERR", LOG_ERR); |
|
SET_VAR_LONG("LOG_WARNING", LOG_WARNING); |
|
SET_VAR_LONG("LOG_NOTICE", LOG_NOTICE); |
|
SET_VAR_LONG("LOG_INFO", LOG_INFO); |
|
SET_VAR_LONG("LOG_DEBUG", LOG_DEBUG); |
|
/* facility: type of program logging the message */ |
|
SET_VAR_LONG("LOG_KERN", LOG_KERN); |
|
SET_VAR_LONG("LOG_USER", LOG_USER); /* generic user level */ |
|
SET_VAR_LONG("LOG_MAIL", LOG_MAIL); /* log to email */ |
|
SET_VAR_LONG("LOG_DAEMON", LOG_DAEMON); /* other system daemons */ |
|
SET_VAR_LONG("LOG_AUTH", LOG_AUTH); |
|
#ifndef NETWARE |
|
SET_VAR_LONG("LOG_SYSLOG", LOG_SYSLOG); |
|
#endif |
|
SET_VAR_LONG("LOG_LPR", LOG_LPR); |
|
#ifdef LOG_NEWS |
|
/* No LOG_NEWS on HP-UX */ |
|
SET_VAR_LONG("LOG_NEWS", LOG_NEWS); /* usenet new */ |
|
#endif |
|
#ifdef LOG_UUCP |
|
/* No LOG_UUCP on HP-UX */ |
|
SET_VAR_LONG("LOG_UUCP", LOG_UUCP); |
|
#endif |
|
#ifdef LOG_CRON |
|
/* apparently some systems don't have this one */ |
|
SET_VAR_LONG("LOG_CRON", LOG_CRON); |
|
#endif |
|
#ifdef LOG_AUTHPRIV |
|
/* AIX doesn't have LOG_AUTHPRIV */ |
|
SET_VAR_LONG("LOG_AUTHPRIV", LOG_AUTHPRIV); |
|
#endif |
|
#if !defined(PHP_WIN32) && !defined(NETWARE) |
|
SET_VAR_LONG("LOG_LOCAL0", LOG_LOCAL0); |
|
SET_VAR_LONG("LOG_LOCAL1", LOG_LOCAL1); |
|
SET_VAR_LONG("LOG_LOCAL2", LOG_LOCAL2); |
|
SET_VAR_LONG("LOG_LOCAL3", LOG_LOCAL3); |
|
SET_VAR_LONG("LOG_LOCAL4", LOG_LOCAL4); |
|
SET_VAR_LONG("LOG_LOCAL5", LOG_LOCAL5); |
|
SET_VAR_LONG("LOG_LOCAL6", LOG_LOCAL6); |
|
SET_VAR_LONG("LOG_LOCAL7", LOG_LOCAL7); |
|
#endif |
|
/* options */ |
|
SET_VAR_LONG("LOG_PID", LOG_PID); |
|
SET_VAR_LONG("LOG_CONS", LOG_CONS); |
|
SET_VAR_LONG("LOG_ODELAY", LOG_ODELAY); |
|
SET_VAR_LONG("LOG_NDELAY", LOG_NDELAY); |
|
#ifdef LOG_NOWAIT |
|
/* BeOS doesn't have LOG_NOWAIT */ |
|
SET_VAR_LONG("LOG_NOWAIT", LOG_NOWAIT); |
|
#endif |
|
#ifdef LOG_PERROR |
|
/* AIX doesn't have LOG_PERROR */ |
|
SET_VAR_LONG("LOG_PERROR", LOG_PERROR); /*log to stderr*/ |
|
#endif |
|
|
|
BG(syslog_started)=1; |
|
} |
|
/* }}} */ |
|
|
|
/* {{{ proto void define_syslog_variables(void) |
|
Initializes all syslog-related variables */ |
|
PHP_FUNCTION(define_syslog_variables) |
|
{ |
|
if (zend_parse_parameters_none() == FAILURE) { |
|
return; |
|
} |
|
|
|
if (!BG(syslog_started)) { |
|
start_syslog(TSRMLS_C); |
|
} |
|
} |
|
/* }}} */ |
|
|
|
/* {{{ proto bool openlog(string ident, int option, int facility) |
/* {{{ proto bool openlog(string ident, int option, int facility) |
Open connection to system logger */ |
Open connection to system logger */ |
/* |
/* |
Line 236 PHP_FUNCTION(openlog)
|
Line 146 PHP_FUNCTION(openlog)
|
free(BG(syslog_device)); |
free(BG(syslog_device)); |
} |
} |
BG(syslog_device) = zend_strndup(ident, ident_len); |
BG(syslog_device) = zend_strndup(ident, ident_len); |
|
if(BG(syslog_device) == NULL) { |
|
RETURN_FALSE; |
|
} |
openlog(BG(syslog_device), option, facility); |
openlog(BG(syslog_device), option, facility); |
RETURN_TRUE; |
RETURN_TRUE; |
} |
} |