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 */
31
PHP_FUNCTION
(
ftok
)
32
{
33
char
*pathname, *proj;
34
size_t
pathname_len, proj_len;
35
key_t
k;
36
37
ZEND_PARSE_PARAMETERS_START
(2, 2)
38
Z_PARAM_PATH
(pathname, pathname_len)
39
Z_PARAM_STRING
(proj, proj_len)
40
ZEND_PARSE_PARAMETERS_END
();
41
42
if
(pathname_len == 0){
43
zend_argument_must_not_be_empty_error
(1);
44
RETURN_THROWS
();
45
}
46
47
if
(proj_len != 1){
48
zend_argument_value_error
(2,
"must be a single character"
);
49
RETURN_THROWS
();
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
ftok(string $filename, string $project_id)
Definition
basic_functions.stub.php:2181
php_check_open_basedir
PHPAPI int php_check_open_basedir(const char *path)
Definition
fopen_wrappers.c:285
NULL
#define NULL
Definition
gdcache.h:45
if
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
Definition
html_table_gen.php:449
ipc.h
key_t
int key_t
Definition
ipc.h:26
php_error_docref
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition
main.c:1173
php.h
PHP_FUNCTION
#define PHP_FUNCTION
Definition
php.h:364
errno
#define errno
Definition
windows_common.h:29
zend_argument_must_not_be_empty_error
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
Definition
zend_API.c:443
zend_argument_value_error
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition
zend_API.c:433
ZEND_PARSE_PARAMETERS_END
#define ZEND_PARSE_PARAMETERS_END()
Definition
zend_API.h:1641
Z_PARAM_STRING
#define Z_PARAM_STRING(dest, dest_len)
Definition
zend_API.h:2071
ZEND_PARSE_PARAMETERS_START
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition
zend_API.h:1620
RETURN_LONG
#define RETURN_LONG(l)
Definition
zend_API.h:1037
RETURN_THROWS
#define RETURN_THROWS()
Definition
zend_API.h:1060
Z_PARAM_PATH
#define Z_PARAM_PATH(dest, dest_len)
Definition
zend_API.h:2026
E_WARNING
#define E_WARNING
Definition
zend_errors.h:24
ext
standard
ftok.c
Generated on Sat Aug 23 2025 01:46:12 for php-internal-docs by
1.13.2