|
| 1 | +/* |
| 2 | + +----------------------------------------------------------------------+ |
| 3 | + | PHP version 4.0 | |
| 4 | + +----------------------------------------------------------------------+ |
| 5 | + | Copyright (c) 1997-2001 The PHP Group | |
| 6 | + +----------------------------------------------------------------------+ |
| 7 | + | This source file is subject to version 2.02 of the PHP license, | |
| 8 | + | that is bundled with this package in the file LICENSE, and is | |
| 9 | + | available at through the world-wide-web at | |
| 10 | + | http://www.php.net/license/2_02.txt. | |
| 11 | + | If you did not receive a copy of the PHP license and are unable to | |
| 12 | + | obtain it through the world-wide-web, please send a note to | |
| 13 | + | license@php.net so we can mail you a copy immediately. | |
| 14 | + +----------------------------------------------------------------------+ |
| 15 | + | Authors: Andrew Sitnikov <sitnikov@infonet.ee | |
| 16 | + +----------------------------------------------------------------------+ |
| 17 | +*/ |
| 18 | + |
| 19 | +/* $Id$ */ |
| 20 | + |
| 21 | +#include "php.h" |
| 22 | + |
| 23 | +#if HAVE_SYSVSEM || HAVE_SYSVSHM || HAVE_SHMOP |
| 24 | + |
| 25 | +#include <sys/types.h> |
| 26 | +#include <sys/ipc.h> |
| 27 | + |
| 28 | +/* {{{ proto int ftok(string pathname, char proj) |
| 29 | + convert a pathname and a project identifier to a System V IPC key */ |
| 30 | +PHP_FUNCTION(ftok) |
| 31 | +{ |
| 32 | + pval **pathname, **proj; |
| 33 | + |
| 34 | + key_t k; |
| 35 | + |
| 36 | + if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pathname, &proj) == FAILURE) { |
| 37 | + WRONG_PARAM_COUNT; |
| 38 | + } |
| 39 | + |
| 40 | + convert_to_string_ex(pathname); |
| 41 | + convert_to_string_ex(proj); |
| 42 | + |
| 43 | + if (Z_STRLEN_PP(pathname)==0){ |
| 44 | + php_error(E_WARNING, "Invalid argument 1 in ftok"); |
| 45 | + RETURN_LONG(-1); |
| 46 | + } |
| 47 | + |
| 48 | + if (Z_STRLEN_PP(proj)!=1){ |
| 49 | + php_error(E_WARNING, "Invalid argument 2 in ftok"); |
| 50 | + RETURN_LONG(-1); |
| 51 | + } |
| 52 | + |
| 53 | + k = ftok(Z_STRVAL_PP(pathname),Z_STRVAL_PP(proj)[0]); |
| 54 | + |
| 55 | + RETURN_LONG(k); |
| 56 | +} |
| 57 | +/* }}} */ |
| 58 | + |
| 59 | +#endif |
| 60 | + |
| 61 | +/* |
| 62 | + * Local variables: |
| 63 | + * tab-width: 4 |
| 64 | + * c-basic-offset: 4 |
| 65 | + * End: |
| 66 | + */ |
0 commit comments