1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Move constants from dir.c to stub file (#13312)

This commit is contained in:
haszi
2024-02-13 22:07:15 +01:00
committed by GitHub
parent 5941cdaaad
commit e957e25c1c
4 changed files with 174 additions and 68 deletions

View File

@@ -20,6 +20,7 @@
#include "fopen_wrappers.h"
#include "file.h"
#include "php_dir.h"
#include "php_dir_int.h"
#include "php_string.h"
#include "php_scandir.h"
#include "basic_functions.h"
@@ -35,15 +36,6 @@
#include "win32/readdir.h"
#endif
#ifdef HAVE_GLOB
#ifndef PHP_WIN32
#include <glob.h>
#else
#include "win32/glob.h"
#endif
#endif
typedef struct {
zend_resource *default_dir;
} php_dir_globals;
@@ -117,6 +109,8 @@ PHP_MINIT_FUNCTION(dir)
{
static char dirsep_str[2], pathsep_str[2];
register_dir_symbols(module_number);
dir_class_entry_ptr = register_class_Directory();
#ifdef ZTS
@@ -131,64 +125,6 @@ PHP_MINIT_FUNCTION(dir)
pathsep_str[1] = '\0';
REGISTER_STRING_CONSTANT("PATH_SEPARATOR", pathsep_str, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SCANDIR_SORT_ASCENDING", PHP_SCANDIR_SORT_ASCENDING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SCANDIR_SORT_DESCENDING", PHP_SCANDIR_SORT_DESCENDING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SCANDIR_SORT_NONE", PHP_SCANDIR_SORT_NONE, CONST_PERSISTENT);
#ifdef HAVE_GLOB
#ifdef GLOB_BRACE
REGISTER_LONG_CONSTANT("GLOB_BRACE", GLOB_BRACE, CONST_PERSISTENT);
#else
# define GLOB_BRACE 0
#endif
#ifdef GLOB_MARK
REGISTER_LONG_CONSTANT("GLOB_MARK", GLOB_MARK, CONST_PERSISTENT);
#else
# define GLOB_MARK 0
#endif
#ifdef GLOB_NOSORT
REGISTER_LONG_CONSTANT("GLOB_NOSORT", GLOB_NOSORT, CONST_PERSISTENT);
#else
# define GLOB_NOSORT 0
#endif
#ifdef GLOB_NOCHECK
REGISTER_LONG_CONSTANT("GLOB_NOCHECK", GLOB_NOCHECK, CONST_PERSISTENT);
#else
# define GLOB_NOCHECK 0
#endif
#ifdef GLOB_NOESCAPE
REGISTER_LONG_CONSTANT("GLOB_NOESCAPE", GLOB_NOESCAPE, CONST_PERSISTENT);
#else
# define GLOB_NOESCAPE 0
#endif
#ifdef GLOB_ERR
REGISTER_LONG_CONSTANT("GLOB_ERR", GLOB_ERR, CONST_PERSISTENT);
#else
# define GLOB_ERR 0
#endif
#ifndef GLOB_ONLYDIR
# define GLOB_ONLYDIR (1<<30)
# define GLOB_EMULATE_ONLYDIR
# define GLOB_FLAGMASK (~GLOB_ONLYDIR)
#else
# define GLOB_FLAGMASK (~0)
#endif
/* This is used for checking validity of passed flags (passing invalid flags causes segfault in glob()!! */
#define GLOB_AVAILABLE_FLAGS (0 | GLOB_BRACE | GLOB_MARK | GLOB_NOSORT | GLOB_NOCHECK | GLOB_NOESCAPE | GLOB_ERR | GLOB_ONLYDIR)
REGISTER_LONG_CONSTANT("GLOB_ONLYDIR", GLOB_ONLYDIR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GLOB_AVAILABLE_FLAGS", GLOB_AVAILABLE_FLAGS, CONST_PERSISTENT);
#endif /* HAVE_GLOB */
return SUCCESS;
}
/* }}} */

View File

@@ -2,6 +2,80 @@
/** @generate-class-entries */
#ifdef HAVE_GLOB
#if (defined(GLOB_BRACE) && GLOB_BRACE != 0)
/**
* @var int
* @cvalue GLOB_BRACE
*/
const GLOB_BRACE = UNKNOWN;
#endif
#if (defined(GLOB_ERR) && GLOB_ERR != 0)
/**
* @var int
* @cvalue GLOB_ERR
*/
const GLOB_ERR = UNKNOWN;
#endif
#if (defined(GLOB_MARK) && GLOB_MARK != 0)
/**
* @var int
* @cvalue GLOB_MARK
*/
const GLOB_MARK = UNKNOWN;
#endif
#if (defined(GLOB_NOCHECK) && GLOB_NOCHECK != 0)
/**
* @var int
* @cvalue GLOB_NOCHECK
*/
const GLOB_NOCHECK = UNKNOWN;
#endif
#if (defined(GLOB_NOESCAPE) && GLOB_NOESCAPE != 0)
/**
* @var int
* @cvalue GLOB_NOESCAPE
*/
const GLOB_NOESCAPE = UNKNOWN;
#endif
#if (defined(GLOB_NOSORT) && GLOB_NOSORT != 0)
/**
* @var int
* @cvalue GLOB_NOSORT
*/
const GLOB_NOSORT = UNKNOWN;
#endif
#ifdef GLOB_ONLYDIR
/**
* @var int
* @cvalue GLOB_ONLYDIR
*/
const GLOB_ONLYDIR = UNKNOWN;
#endif
#ifdef GLOB_AVAILABLE_FLAGS
/**
* @var int
* @cvalue GLOB_AVAILABLE_FLAGS
*/
const GLOB_AVAILABLE_FLAGS = UNKNOWN;
#endif
#endif
/**
* @var int
* @cvalue PHP_SCANDIR_SORT_ASCENDING
*/
const SCANDIR_SORT_ASCENDING = UNKNOWN;
/**
* @var int
* @cvalue PHP_SCANDIR_SORT_DESCENDING
*/
const SCANDIR_SORT_DESCENDING = UNKNOWN;
/**
* @var int
* @cvalue PHP_SCANDIR_SORT_NONE
*/
const SCANDIR_SORT_NONE = UNKNOWN;
class Directory
{
public readonly string $path;

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: b3890e798e609e306027b4717ce0c5e782884087 */
* Stub hash: f2571fbbcff57095abcb846f148644e10b2db2e8 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
@@ -22,6 +22,37 @@ static const zend_function_entry class_Directory_methods[] = {
ZEND_FE_END
};
static void register_dir_symbols(int module_number)
{
#if defined(HAVE_GLOB) && (defined(GLOB_BRACE) && GLOB_BRACE != 0)
REGISTER_LONG_CONSTANT("GLOB_BRACE", GLOB_BRACE, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && (defined(GLOB_ERR) && GLOB_ERR != 0)
REGISTER_LONG_CONSTANT("GLOB_ERR", GLOB_ERR, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && (defined(GLOB_MARK) && GLOB_MARK != 0)
REGISTER_LONG_CONSTANT("GLOB_MARK", GLOB_MARK, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && (defined(GLOB_NOCHECK) && GLOB_NOCHECK != 0)
REGISTER_LONG_CONSTANT("GLOB_NOCHECK", GLOB_NOCHECK, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && (defined(GLOB_NOESCAPE) && GLOB_NOESCAPE != 0)
REGISTER_LONG_CONSTANT("GLOB_NOESCAPE", GLOB_NOESCAPE, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && (defined(GLOB_NOSORT) && GLOB_NOSORT != 0)
REGISTER_LONG_CONSTANT("GLOB_NOSORT", GLOB_NOSORT, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && defined(GLOB_ONLYDIR)
REGISTER_LONG_CONSTANT("GLOB_ONLYDIR", GLOB_ONLYDIR, CONST_PERSISTENT);
#endif
#if defined(HAVE_GLOB) && defined(GLOB_AVAILABLE_FLAGS)
REGISTER_LONG_CONSTANT("GLOB_AVAILABLE_FLAGS", GLOB_AVAILABLE_FLAGS, CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("SCANDIR_SORT_ASCENDING", PHP_SCANDIR_SORT_ASCENDING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SCANDIR_SORT_DESCENDING", PHP_SCANDIR_SORT_DESCENDING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SCANDIR_SORT_NONE", PHP_SCANDIR_SORT_NONE, CONST_PERSISTENT);
}
static zend_class_entry *register_class_Directory(void)
{
zend_class_entry ce, *class_entry;

View File

@@ -0,0 +1,65 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef PHP_DIR_INT_H
#define PHP_DIR_INT_H
#ifdef HAVE_GLOB
#ifndef PHP_WIN32
#include <glob.h>
#else
#include "win32/glob.h"
#endif
#endif
#ifdef HAVE_GLOB
#ifndef GLOB_BRACE
#define GLOB_BRACE 0
#endif
#ifndef GLOB_ERR
#define GLOB_ERR 0
#endif
#ifndef GLOB_MARK
#define GLOB_MARK 0
#endif
#ifndef GLOB_NOCHECK
#define GLOB_NOCHECK 0
#endif
#ifndef GLOB_NOESCAPE
#define GLOB_NOESCAPE 0
#endif
#ifndef GLOB_NOSORT
#define GLOB_NOSORT 0
#endif
#ifndef GLOB_ONLYDIR
#define GLOB_ONLYDIR (1<<30)
#define GLOB_EMULATE_ONLYDIR
#define GLOB_FLAGMASK (~GLOB_ONLYDIR)
#else
#define GLOB_FLAGMASK (~0)
#endif
/* This is used for checking validity of passed flags (passing invalid flags causes segfault in glob()!! */
#define GLOB_AVAILABLE_FLAGS (0 | GLOB_BRACE | GLOB_MARK | GLOB_NOSORT | GLOB_NOCHECK | GLOB_NOESCAPE | GLOB_ERR | GLOB_ONLYDIR)
#endif /* HAVE_GLOB */
#endif /* PHP_DIR_INT_H */