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: Anatol Belski <ab@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#include "php.h"
18#include "ipc.h"
19
20#include <windows.h>
21#include <sys/stat.h>
22
23#include "ioutil.h"
24
26ftok(const char *pathname, int proj_id)
27{/*{{{*/
28 HANDLE fh;
29 struct _stat st;
30 BY_HANDLE_FILE_INFORMATION bhfi;
31 key_t ret;
33
34 if (!pathw) {
35 return (key_t)-1;
36 }
37
38 if (_wstat(pathw, &st) < 0) {
40 return (key_t)-1;
41 }
42
43 if ((fh = CreateFileW(pathw, FILE_GENERIC_READ, PHP_WIN32_IOUTIL_DEFAULT_SHARE_MODE, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
45 return (key_t)-1;
46 }
47
48 if (!GetFileInformationByHandle(fh, &bhfi)) {
50 CloseHandle(fh);
51 return (key_t)-1;
52 }
53
54 ret = (key_t) ((proj_id & 0xff) << 24 | (st.st_dev & 0xff) << 16 | (bhfi.nFileIndexLow & 0xffff));
55
56 CloseHandle(fh);
58
59 return ret;
60}/*}}}*/
ftok(string $filename, string $project_id)
#define PHP_WIN32_IOUTIL_INIT_W(path)
Definition ioutil.h:143
#define PHP_WIN32_IOUTIL_CLEANUP_W()
Definition ioutil.h:146
#define PHP_WIN32_IOUTIL_DEFAULT_SHARE_MODE
Definition ioutil.h:141
int key_t
Definition ipc.h:26
#define PHP_WIN32_IPC_API
Definition ipc.h:23
zval * ret