@@ -61,102 +61,94 @@ BEGIN_EXTERN_C()
6161#define STREAM_ERROR_CODE_USERSPACE_START 160
6262#define STREAM_ERROR_CODE_USERSPACE_END 170
6363
64- /* X-macro defining all error codes */
65- #define PHP_STREAM_ERROR_CODES (V ) \
66- /* General errors */ \
67- V(NONE, None, 0) \
68- V(GENERIC, Generic, 1) \
69- /* I/O operation errors (10-29) */ \
70- V (READ_FAILED , ReadFailed , 10 ) \
71- V (WRITE_FAILED , WriteFailed , 11 ) \
72- V (SEEK_FAILED , SeekFailed , 12 ) \
73- V (SEEK_NOT_SUPPORTED , SeekNotSupported , 13 ) \
74- V (FLUSH_FAILED , FlushFailed , 14 ) \
75- V (TRUNCATE_FAILED , TruncateFailed , 15 ) \
76- V (CONNECT_FAILED , ConnectFailed , 16 ) \
77- V (BIND_FAILED , BindFailed , 17 ) \
78- V (LISTEN_FAILED , ListenFailed , 18 ) \
79- V (NOT_WRITABLE , NotWritable , 19 ) \
80- V (NOT_READABLE , NotReadable , 20 ) \
81- /* File system operations (30-69) */ \
82- V (DISABLED , Disabled , 30 ) \
83- V (NOT_FOUND , NotFound , 31 ) \
84- V (PERMISSION_DENIED , PermissionDenied , 32 ) \
85- V (ALREADY_EXISTS , AlreadyExists , 33 ) \
86- V (INVALID_PATH , InvalidPath , 34 ) \
87- V (PATH_TOO_LONG , PathTooLong , 35 ) \
88- V (OPEN_FAILED , OpenFailed , 36 ) \
89- V (CREATE_FAILED , CreateFailed , 37 ) \
90- V (DUP_FAILED , DupFailed , 38 ) \
91- V (UNLINK_FAILED , UnlinkFailed , 39 ) \
92- V (RENAME_FAILED , RenameFailed , 40 ) \
93- V (MKDIR_FAILED , MkdirFailed , 41 ) \
94- V (RMDIR_FAILED , RmdirFailed , 42 ) \
95- V (STAT_FAILED , StatFailed , 43 ) \
96- V (META_FAILED , MetaFailed , 44 ) \
97- V (CHMOD_FAILED , ChmodFailed , 45 ) \
98- V (CHOWN_FAILED , ChownFailed , 46 ) \
99- V (COPY_FAILED , CopyFailed , 47 ) \
100- V (TOUCH_FAILED , TouchFailed , 48 ) \
101- V (INVALID_MODE , InvalidMode , 49 ) \
102- V (INVALID_META , InvalidMeta , 50 ) \
103- V (MODE_NOT_SUPPORTED , ModeNotSupported , 51 ) \
104- V (READONLY , Readonly , 52 ) \
105- V (RECURSION_DETECTED , RecursionDetected , 53 ) \
106- /* Wrapper/protocol operations (70-89) */ \
107- V (NOT_IMPLEMENTED , NotImplemented , 70 ) \
108- V (NO_OPENER , NoOpener , 71 ) \
109- V (PERSISTENT_NOT_SUPPORTED , PersistentNotSupported , 72 ) \
110- V (WRAPPER_NOT_FOUND , WrapperNotFound , 73 ) \
111- V (WRAPPER_DISABLED , WrapperDisabled , 74 ) \
112- V (PROTOCOL_UNSUPPORTED , ProtocolUnsupported , 75 ) \
113- V (WRAPPER_REGISTRATION_FAILED , WrapperRegistrationFailed , 76 ) \
114- V (WRAPPER_UNREGISTRATION_FAILED , WrapperUnregistrationFailed , 77 ) \
115- V (WRAPPER_RESTORATION_FAILED , WrapperRestorationFailed , 78 ) \
116- /* Filter operations (90-99) */ \
117- V (FILTER_NOT_FOUND , FilterNotFound , 90 ) \
118- V (FILTER_FAILED , FilterFailed , 91 ) \
119- /* Cast/conversion operations (100-109) */ \
120- V (CAST_FAILED , CastFailed , 100 ) \
121- V (CAST_NOT_SUPPORTED , CastNotSupported , 101 ) \
122- V (MAKE_SEEKABLE_FAILED , MakeSeekableFailed , 102 ) \
123- V (BUFFERED_DATA_LOST , BufferedDataLost , 103 ) \
124- /* Network/socket operations (110-129) */ \
125- V (NETWORK_SEND_FAILED , NetworkSendFailed , 110 ) \
126- V (NETWORK_RECV_FAILED , NetworkRecvFailed , 111 ) \
127- V (SSL_NOT_SUPPORTED , SslNotSupported , 112 ) \
128- V (RESUMPTION_FAILED , ResumptionFailed , 113 ) \
129- V (SOCKET_PATH_TOO_LONG , SocketPathTooLong , 114 ) \
130- V (OOB_NOT_SUPPORTED , OobNotSupported , 115 ) \
131- V (PROTOCOL_ERROR , ProtocolError , 116 ) \
132- V (INVALID_URL , InvalidUrl , 117 ) \
133- V (INVALID_RESPONSE , InvalidResponse , 118 ) \
134- V (INVALID_HEADER , InvalidHeader , 119 ) \
135- V (INVALID_PARAM , InvalidParam , 120 ) \
136- V (REDIRECT_LIMIT , RedirectLimit , 121 ) \
137- V (AUTH_FAILED , AuthFailed , 122 ) \
138- /* Encoding/decoding/archiving operations (130-139) */ \
139- V (ARCHIVING_FAILED , ArchivingFailed , 130 ) \
140- V (ENCODING_FAILED , EncodingFailed , 131 ) \
141- V (DECODING_FAILED , DecodingFailed , 132 ) \
142- V (INVALID_FORMAT , InvalidFormat , 133 ) \
143- /* Resource/allocation operations (140-149) */ \
144- V (ALLOCATION_FAILED , AllocationFailed , 140 ) \
145- V (TEMPORARY_FILE_FAILED , TemporaryFileFailed , 141 ) \
146- /* Locking operations (150-159) */ \
147- V (LOCK_FAILED , LockFailed , 150 ) \
148- V (LOCK_NOT_SUPPORTED , LockNotSupported , 151 ) \
149- /* Userspace stream operations (160-169) */ \
150- V (USERSPACE_NOT_IMPLEMENTED , UserspaceNotImplemented , 160 ) \
151- V (USERSPACE_INVALID_RETURN , UserspaceInvalidReturn , 161 ) \
152- V (USERSPACE_CALL_FAILED , UserspaceCallFailed , 162 )
153-
154- /* Generate C enum for internal use */
155- typedef enum _StreamErrorCode {
156- #define V(uc_name, name, val) STREAM_ERROR_CODE_##uc_name = val,
157- PHP_STREAM_ERROR_CODES (V )
158- #undef V
159- } StreamErrorCode ;
64+ /* Error codes - exposed as StreamError::ERROR_CODE_* class constants */
65+ /* General errors */
66+ #define STREAM_ERROR_CODE_NONE 0
67+ #define STREAM_ERROR_CODE_GENERIC 1
68+ /* I/O operation errors (10-29) */
69+ #define STREAM_ERROR_CODE_READ_FAILED 10
70+ #define STREAM_ERROR_CODE_WRITE_FAILED 11
71+ #define STREAM_ERROR_CODE_SEEK_FAILED 12
72+ #define STREAM_ERROR_CODE_SEEK_NOT_SUPPORTED 13
73+ #define STREAM_ERROR_CODE_FLUSH_FAILED 14
74+ #define STREAM_ERROR_CODE_TRUNCATE_FAILED 15
75+ #define STREAM_ERROR_CODE_CONNECT_FAILED 16
76+ #define STREAM_ERROR_CODE_BIND_FAILED 17
77+ #define STREAM_ERROR_CODE_LISTEN_FAILED 18
78+ #define STREAM_ERROR_CODE_NOT_WRITABLE 19
79+ #define STREAM_ERROR_CODE_NOT_READABLE 20
80+ /* File system operations (30-69) */
81+ #define STREAM_ERROR_CODE_DISABLED 30
82+ #define STREAM_ERROR_CODE_NOT_FOUND 31
83+ #define STREAM_ERROR_CODE_PERMISSION_DENIED 32
84+ #define STREAM_ERROR_CODE_ALREADY_EXISTS 33
85+ #define STREAM_ERROR_CODE_INVALID_PATH 34
86+ #define STREAM_ERROR_CODE_PATH_TOO_LONG 35
87+ #define STREAM_ERROR_CODE_OPEN_FAILED 36
88+ #define STREAM_ERROR_CODE_CREATE_FAILED 37
89+ #define STREAM_ERROR_CODE_DUP_FAILED 38
90+ #define STREAM_ERROR_CODE_UNLINK_FAILED 39
91+ #define STREAM_ERROR_CODE_RENAME_FAILED 40
92+ #define STREAM_ERROR_CODE_MKDIR_FAILED 41
93+ #define STREAM_ERROR_CODE_RMDIR_FAILED 42
94+ #define STREAM_ERROR_CODE_STAT_FAILED 43
95+ #define STREAM_ERROR_CODE_META_FAILED 44
96+ #define STREAM_ERROR_CODE_CHMOD_FAILED 45
97+ #define STREAM_ERROR_CODE_CHOWN_FAILED 46
98+ #define STREAM_ERROR_CODE_COPY_FAILED 47
99+ #define STREAM_ERROR_CODE_TOUCH_FAILED 48
100+ #define STREAM_ERROR_CODE_INVALID_MODE 49
101+ #define STREAM_ERROR_CODE_INVALID_META 50
102+ #define STREAM_ERROR_CODE_MODE_NOT_SUPPORTED 51
103+ #define STREAM_ERROR_CODE_READONLY 52
104+ #define STREAM_ERROR_CODE_RECURSION_DETECTED 53
105+ /* Wrapper/protocol operations (70-89) */
106+ #define STREAM_ERROR_CODE_NOT_IMPLEMENTED 70
107+ #define STREAM_ERROR_CODE_NO_OPENER 71
108+ #define STREAM_ERROR_CODE_PERSISTENT_NOT_SUPPORTED 72
109+ #define STREAM_ERROR_CODE_WRAPPER_NOT_FOUND 73
110+ #define STREAM_ERROR_CODE_WRAPPER_DISABLED 74
111+ #define STREAM_ERROR_CODE_PROTOCOL_UNSUPPORTED 75
112+ #define STREAM_ERROR_CODE_WRAPPER_REGISTRATION_FAILED 76
113+ #define STREAM_ERROR_CODE_WRAPPER_UNREGISTRATION_FAILED 77
114+ #define STREAM_ERROR_CODE_WRAPPER_RESTORATION_FAILED 78
115+ /* Filter operations (90-99) */
116+ #define STREAM_ERROR_CODE_FILTER_NOT_FOUND 90
117+ #define STREAM_ERROR_CODE_FILTER_FAILED 91
118+ /* Cast/conversion operations (100-109) */
119+ #define STREAM_ERROR_CODE_CAST_FAILED 100
120+ #define STREAM_ERROR_CODE_CAST_NOT_SUPPORTED 101
121+ #define STREAM_ERROR_CODE_MAKE_SEEKABLE_FAILED 102
122+ #define STREAM_ERROR_CODE_BUFFERED_DATA_LOST 103
123+ /* Network/socket operations (110-129) */
124+ #define STREAM_ERROR_CODE_NETWORK_SEND_FAILED 110
125+ #define STREAM_ERROR_CODE_NETWORK_RECV_FAILED 111
126+ #define STREAM_ERROR_CODE_SSL_NOT_SUPPORTED 112
127+ #define STREAM_ERROR_CODE_RESUMPTION_FAILED 113
128+ #define STREAM_ERROR_CODE_SOCKET_PATH_TOO_LONG 114
129+ #define STREAM_ERROR_CODE_OOB_NOT_SUPPORTED 115
130+ #define STREAM_ERROR_CODE_PROTOCOL_ERROR 116
131+ #define STREAM_ERROR_CODE_INVALID_URL 117
132+ #define STREAM_ERROR_CODE_INVALID_RESPONSE 118
133+ #define STREAM_ERROR_CODE_INVALID_HEADER 119
134+ #define STREAM_ERROR_CODE_INVALID_PARAM 120
135+ #define STREAM_ERROR_CODE_REDIRECT_LIMIT 121
136+ #define STREAM_ERROR_CODE_AUTH_FAILED 122
137+ /* Encoding/decoding/archiving operations (130-139) */
138+ #define STREAM_ERROR_CODE_ARCHIVING_FAILED 130
139+ #define STREAM_ERROR_CODE_ENCODING_FAILED 131
140+ #define STREAM_ERROR_CODE_DECODING_FAILED 132
141+ #define STREAM_ERROR_CODE_INVALID_FORMAT 133
142+ /* Resource/allocation operations (140-149) */
143+ #define STREAM_ERROR_CODE_ALLOCATION_FAILED 140
144+ #define STREAM_ERROR_CODE_TEMPORARY_FILE_FAILED 141
145+ /* Locking operations (150-159) */
146+ #define STREAM_ERROR_CODE_LOCK_FAILED 150
147+ #define STREAM_ERROR_CODE_LOCK_NOT_SUPPORTED 151
148+ /* Userspace stream operations (160-169) */
149+ #define STREAM_ERROR_CODE_USERSPACE_NOT_IMPLEMENTED 160
150+ #define STREAM_ERROR_CODE_USERSPACE_INVALID_RETURN 161
151+ #define STREAM_ERROR_CODE_USERSPACE_CALL_FAILED 162
160152
161153/* Wrapper name for PHP errors */
162154#define PHP_STREAM_ERROR_WRAPPER_DEFAULT_NAME ":na"
@@ -166,7 +158,7 @@ typedef enum _StreamErrorCode {
166158/* Error entry in chain */
167159typedef struct _php_stream_error_entry {
168160 zend_string * message ;
169- StreamErrorCode code ;
161+ int code ;
170162 char * wrapper_name ;
171163 char * param ;
172164 char * docref ;
0 commit comments