php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
ftok.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: Andrew Sitnikov <sitnikov@infonet.ee> |
14 +----------------------------------------------------------------------+
15*/
16
17#include "php.h"
18
19#include <sys/types.h>
20
21#ifdef HAVE_SYS_IPC_H
22#include <sys/ipc.h>
23#endif
24
25#ifdef PHP_WIN32
26#include "win32/ipc.h"
27#endif
28
29#ifdef HAVE_FTOK
30/* {{{ Convert a pathname and a project identifier to a System V IPC key */
32{
33 char *pathname, *proj;
34 size_t pathname_len, proj_len;
35 key_t k;
36
38 Z_PARAM_PATH(pathname, pathname_len)
39 Z_PARAM_STRING(proj, proj_len)
41
42 if (pathname_len == 0){
45 }
46
47 if (proj_len != 1){
48 zend_argument_value_error(2, "must be a single character");
50 }
51
52 if (php_check_open_basedir(pathname)) {
53 RETURN_LONG(-1);
54 }
55
56 k = ftok(pathname, proj[0]);
57 if (k == -1) {
58 php_error_docref(NULL, E_WARNING, "ftok() failed - %s", strerror(errno));
59 }
60
61 RETURN_LONG(k);
62}
63/* }}} */
64#endif
ftok(string $filename, string $project_id)
PHPAPI int php_check_open_basedir(const char *path)
#define NULL
Definition gdcache.h:45
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
int key_t
Definition ipc.h:26
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
#define PHP_FUNCTION
Definition php.h:364
#define errno
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
Definition zend_API.c:443
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define Z_PARAM_STRING(dest, dest_len)
Definition zend_API.h:2071
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_THROWS()
Definition zend_API.h:1060
#define Z_PARAM_PATH(dest, dest_len)
Definition zend_API.h:2026
#define E_WARNING
Definition zend_errors.h:24