php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
syslog.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Stig Sæther Bakken <ssb@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#include "php.h"
18
19#ifdef HAVE_SYSLOG_H
20#include "php_ini.h"
21#include "zend_globals.h"
22
23#include <stdlib.h>
24#ifdef HAVE_UNISTD_H
25#include <unistd.h>
26#endif
27
28#include <string.h>
29#include <errno.h>
30
31#include <stdio.h>
32#include "basic_functions.h"
33#include "php_ext_syslog.h"
34
35/* {{{ PHP_MINIT_FUNCTION */
37{
38 return SUCCESS;
39}
40/* }}} */
41
43{
45 if (BG(syslog_device)) {
46 free(BG(syslog_device));
47 BG(syslog_device) = NULL;
48 }
49 return SUCCESS;
50}
51
52
53/* {{{ Open connection to system logger */
54/*
55 ** OpenLog("nettopp", $LOG_PID, $LOG_LOCAL1);
56 ** Syslog($LOG_EMERG, "help me!")
57 ** CloseLog();
58 */
60{
61 char *ident;
62 zend_long option, facility;
63 size_t ident_len;
64
66 Z_PARAM_STRING(ident, ident_len)
67 Z_PARAM_LONG(option)
68 Z_PARAM_LONG(facility)
70
71 if (BG(syslog_device)) {
72 free(BG(syslog_device));
73 }
74 BG(syslog_device) = zend_strndup(ident, ident_len);
75 php_openlog(BG(syslog_device), option, facility);
77}
78/* }}} */
79
80/* {{{ Close connection to system logger */
82{
84
86 if (BG(syslog_device)) {
87 free(BG(syslog_device));
88 BG(syslog_device)=NULL;
89 }
91}
92/* }}} */
93
94/* {{{ Generate a system log message */
96{
97 zend_long priority;
98 zend_string *message;
99
101 Z_PARAM_LONG(priority)
102 Z_PARAM_STR(message)
104
105 php_syslog_str(priority, message);
107}
108/* }}} */
109
110#endif
#define BG(v)
syslog(int $priority, string $message)
openlog(string $prefix, int $flags, int $facility)
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
#define PHP_FUNCTION
Definition php.h:364
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
void php_openlog(const char *ident, int option, int facility)
Definition php_syslog.c:74
PHPAPI void php_syslog_str(int priority, const zend_string *message)
Definition php_syslog.c:35
void php_closelog(void)
Definition php_syslog.c:80
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623
#define Z_PARAM_STRING(dest, dest_len)
Definition zend_API.h:2071
#define Z_PARAM_STR(dest)
Definition zend_API.h:2086
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define Z_PARAM_LONG(dest)
Definition zend_API.h:1896
#define RETURN_TRUE
Definition zend_API.h:1059
ZEND_API char *ZEND_FASTCALL zend_strndup(const char *s, size_t length)
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string