Commit Graph

103 Commits

Author SHA1 Message Date
Peter Kokot
cf3b9fca8f
Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined:
- __GNUC__
- DBA_CDB_BUILTIN
- DBA_GDBM
- HAVE_FORK
- HAVE_PUTENV
- HAVE_SETENV
- HAVE_SYS_SELECT_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_WAIT_H
- HAVE_UNSETENV
- RFC3678_API
- ZEND_ENABLE_ZVAL_LONG64
- ZTS

Follow-up of GH-5526
2024-06-24 19:37:07 +02:00
Peter Kokot
a82d86479c
Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462)
* Replace WIN32 conditions with _WIN32 or PHP_WIN32

WIN32 is defined by the SDK and not defined all the time on Windows by
compilers or the environment. _WIN32 is defined as 1 when the
compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise,
undefined.

This syncs these usages one step further.

Upstream libgd has replaced WIN32 with _WIN32 via
c60d9fe577

PHP_WIN32 is added to ext/sockets/sockets.stub.php as done in other
*.stub.php files at this point.

* Use PHP_WIN32 in ext/random

* Use PHP_WIN32 in ext/sockets

* Use _WIN32 in xxhash.h as done upstream

See https://github.com/Cyan4973/xxHash/pull/931

* Update end comment with PHP_WIN32
2024-06-10 21:59:41 +02:00
Peter Kokot
84a0da1574
Sync #if/ifdef/defined (#14508)
This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
2024-06-09 14:23:41 +02:00
Peter Kokot
da86eec3db
Sync #if/ifdef/defined (#14371)
These are either undefined or defined to value 1 in Autotools and
Windows:
- HAVE_COMMONCRYPTO_COMMONRANDOM_H
- HAVE_EXIF
- HAVE_FOPENCOOKIE
- HAVE_IF_NAMETOINDEX
- HAVE_LIBICONV
- HAVE_SOCKETS
- HAVE_STRUCT_STAT_ST_RDEV
- HAVE_STRUCT_TM_TM_GMTOFF
- HAVE_STRUCT_TM_TM_ZONE

Follow up of GH-5526 (-Wundef)
2024-06-07 23:45:17 +02:00
Peter Kokot
b5c3cbf94b
Check sockaddr_storage.ss_family with AC_CHECK_MEMBERS (#13407)
This simplifies the check. On AIX 6 and newer, the ss_family is
available, if compiled without defining COMPAT_43 (BSD 4.3
compatibility).
2024-02-16 14:24:55 +01:00
George Peter Banyard
3eb9dd47e0 Use bool and zend_result where it makes sense in sockets extension 2023-01-30 16:05:30 +00:00
Bruce Dou
9f7e27a86b
Fix: sockets constants
Closes GH-9533.
2022-09-14 15:27:29 +02:00
Máté Kocsis
98e5c4e3a3
Declare ext/sockets constants in stubs (#9349) 2022-08-16 13:18:31 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Christoph M. Becker
95cf7a0358 Fix Windows build for shared ext/sockets
We can't use `PHPAPI` for extensions which may be built shared.  Thus,
we introduce `PHP_SOCKETS_API`.
2020-09-08 22:54:21 +02:00
Remi Collet
4c43806b61 add socket_ce and socket_import_file_descriptor in public API 2020-09-08 17:26:22 +02:00
Máté Kocsis
77172c220a Convert resources to objects in ext/sockets
Closes GH-5900.
2020-08-03 23:26:38 +02:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Peter Kokot
1ad08256f3 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:56:38 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Anatol Belski
9d4da80e90 Implemented winsock info import/export 2018-05-17 11:36:23 +02:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
David Walker
7373ce9149 Fix #72733: Expose getaddrinfo C function, and supporting connect/bind
Feature request was to expose getaddrinfo().  I accomplish this
by having an array of resources that are the addrinfo structures.
The resources can be used in new functions to connect/bind, and
one function to examine the contents of the resource.
2016-08-12 11:29:34 -06:00
James Titcumb
c4b188871e Fix bug #71575 removing extra semicolons outside macros 2016-03-03 16:41:03 +01:00
Lior Kaplan
ed35de784f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Happy new year (Update copyright to 2016)
2016-01-01 19:48:25 +02:00
Lior Kaplan
49493a2dcf Happy new year (Update copyright to 2016) 2016-01-01 19:21:47 +02:00
Anatol Belski
4e66cce87c switch to the unified globals accessor where appropriate 2015-07-29 13:26:35 +02:00
Anatol Belski
663074b6b1 cleanup mod version macros and mod defs, round x 2015-03-23 21:30:22 +01:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Xinchen Hui
0579e8278d bump year 2015-01-15 23:26:37 +08:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Anatol Belski
3ca0ca1548 Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (102 commits)
  fix dir separator in test
  fix TS build
  fix TS build
  Better fix for bug #68446
  Revert "Merge remote-tracking branch 'origin/PHP-5.6'"
  Revert NEWS and set test to XFAIL
  Revert "Fix bug #68446 (bug with constant defaults and type hints)"
  Improved zend_hash_clean() and added new optimized zend_symtable_clean()
  Use inline version of zval_ptr_dtor()
  Added new optimized zend_array_destroy() function
  Moved i_zval_ptr_dtor() from zend_execute.h to zend_variables.h
  fix REGISTER_NS_*_CONSTANT macros
  Removed useless assert. EG(uninitialized_zval) can't be refcounted.
  Use specialized destructors when types of zvals are known.
  move tests into proper place
  Improved assignment to object property
  Reuse zend_assign_to_variable() in zend_std_write_property()
  cleanup comments from svn/cvs era
  fix dir separator in test
  fork test for windows
  ...
2014-11-26 08:17:35 +01:00
Mathieu CARBONNEAUX
a0909f0a12 add php_create_socket/php_destroy_socket PHP_SOCKETS_API to abel to create socket ressource in other ext 2014-11-10 12:31:21 +01:00
Anatol Belski
08b2638275 convert ext/sockets to work with the static tsrm cache pointer 2014-10-05 20:48:32 +02:00
Johannes Schlüter
d0cb715373 s/PHP 5/PHP 7/ 2014-09-19 18:33:14 +02:00
Xinchen Hui
489da59b08 Refactoring socket (only compilable now) 2014-05-17 10:23:46 +08:00
Xinchen Hui
c081ce628f Bump year 2014-01-03 11:08:10 +08:00
Felipe Pena
5967fb194f - Fixed bug #66381 (__ss_family was changed on AIX 5.3) 2014-01-01 09:55:14 -02:00
Xinchen Hui
3f67d5ae43 Revert "Fixed Bug #64340 (sockets tests failed) Patch by Reeze"
build break, will only leave the test script fix first

This reverts commit f2246f352f.
2013-03-05 13:58:20 +08:00
Xinchen Hui
f2246f352f Fixed Bug #64340 (sockets tests failed) Patch by Reeze
Add __APPLE_USE_RFC_3542 for OS X 10.7 because IPv6 options are incompatible with RFC 2292.
2013-03-03 10:51:04 +08:00
Gustavo Lopes
189fbfd53b Fix ext/sockets build with phpize
Fixes bug #64285
2013-02-24 00:49:25 +01:00
Gustavo Lopes
af1b90d62b Fix bug and hopefully build on WinSDK 6.1
There build was failing on rmtools on the sockets extension for two reasons:

  1. IPV6_TCLASS and IPV6_RECVTCLASS not being defined. These are probably
  recent additions to SDK. Windows 7 doesn't event seem to have complete
  support for IPV6_TCLASS, not accepting in WSASendMsg(). The parts that
  needed this constant were not guarded by #ifdefs. They are now.

  2. The constants EWOULDBLOCK and EINPROGRESS not being defined. These
  were only defined in php_network.h, outside of the extension, and not
  all source files included this header. Nevertheless, a macro defined in
  php_sockets.h needed these constants. When this macro was used in files
  that did not include php_network.h, the compilation would fail.
  Surprisingly, the build did not fail when using the 7.1 Windows SDK
  (more likely, the CRT headers used in VC10), as somehow errno.h was
  being included through some other standard header. This would make the
  constant EWOULDBLOCK defined; however, it would be defined to the wrong
  value. In the winsock context, WSAEWOULDBLOCK should be used instead.
  Because we have difficulty using Windows-only constants in the code, we
  (re)define EWOULDBLOCK to WSAEWOULDBLOCK. This has the obvious
  disavantage we may miss problems like this again in the future.
2013-02-03 01:36:14 +01:00
Gustavo Lopes
03b1da5d7a php_strerror in ext/sockets renamed in 5.5 2013-02-02 18:39:47 +01:00
Gustavo Lopes
b11777ca2a Merge branch 'sendrecvmsg_rebase_55' into PHP-5.5
* sendrecvmsg_rebase_55: (31 commits)
  Fix multicast.c not defining errno on Windows
  Fix non-Windows build
  send/recvmsg() support for Windows
  Remove some pre-vista code
  Revert "Payload of HOPLIMIT/TCLASS are 8-bit"
  Ensure memory is initialized
  Payload of HOPLIMIT/TCLASS are 8-bit
  Fix buf in string -> int conv.
  Build fixes; accept names for if_index
  Refactoring: move stuff to new conversions.c
  Support sticky IPV6_PKTINFO
  Rename some functions for consistency
  Destroy ancillary registry on shutdown
  Move some multicast stuff to multicast.c
  Fix mcast_ipv6_send test
  Check return of fstat()
  Fix build on Mac OS X
  Register extra MSG_* constants
  Add test for CMSG_RIGHTS
  Add test for CMSG_CREDENTIALS message
  ...
2013-02-02 16:50:38 +01:00
Gustavo Lopes
7066cc7267 send/recvmsg() support for Windows 2013-02-02 16:38:09 +01:00
Gustavo Lopes
51394f76a5 Move some multicast stuff to multicast.c 2013-02-02 16:38:07 +01:00
Gustavo Lopes
131245474b Redactor to expose socket_import_file_descriptor() 2013-02-02 16:38:06 +01:00
Gustavo Lopes
5e51c85143 Wrap recvmsg() and sendmsg()
This introduces two new functions:

int socket_recvmsg(resource $socket, array &$msghdr, int $flags)
int socket_sendmsg(resource $socket, array $msghdr, int $flags)

The arrays representing struct msghdr follow the native counterpart
closely: structs are mapped to arrays, fields to array elements whose
key is the name of the field without the prefix (e.g. "name" instead
of "msg_name") and array are mapped to sequential numeric PHP arrays.

Right now the only type of ancillary data supported is fot the
level/type pair IPPROTO_IPV6/IPV6_PKTINFO.

I also refactored out the name resolution functions and made
sockets_strerror() a global function.
2013-02-02 16:38:05 +01:00
Gustavo Lopes
ac47448abb Ignore warnings on EAGAIN/EWOULDBLOCK/EINPROGRESS
See bug #63570
2013-02-02 15:43:05 +01:00
Gustavo Lopes
9283b8aea4 Move & improve PHP_SOCKET_ERROR def 2013-02-02 15:29:11 +01:00
Gustavo Lopes
97d656fc82 Move some declarations to sockets.c 2013-02-02 14:06:23 +01:00
Xinchen Hui
0a7395e009 Happy New Year 2013-01-01 16:28:54 +08:00