xref: /PHP-8.3/main/rfc1867.h (revision 6f63d4b2)
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:                                                              |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef RFC1867_H
18 #define RFC1867_H
19 
20 #include "SAPI.h"
21 
22 #define MULTIPART_CONTENT_TYPE "multipart/form-data"
23 #define MULTIPART_EVENT_START		0
24 #define MULTIPART_EVENT_FORMDATA	1
25 #define MULTIPART_EVENT_FILE_START	2
26 #define MULTIPART_EVENT_FILE_DATA	3
27 #define MULTIPART_EVENT_FILE_END	4
28 #define MULTIPART_EVENT_END		5
29 
30 /* Errors */
31 #define PHP_UPLOAD_ERROR_OK   0  /* File upload successful */
32 #define PHP_UPLOAD_ERROR_A    1  /* Uploaded file exceeded upload_max_filesize */
33 #define PHP_UPLOAD_ERROR_B    2  /* Uploaded file exceeded MAX_FILE_SIZE */
34 #define PHP_UPLOAD_ERROR_C    3  /* Partially uploaded */
35 #define PHP_UPLOAD_ERROR_D    4  /* No file uploaded */
36 #define PHP_UPLOAD_ERROR_E    6  /* Missing /tmp or similar directory */
37 #define PHP_UPLOAD_ERROR_F    7  /* Failed to write file to disk */
38 #define PHP_UPLOAD_ERROR_X    8  /* File upload stopped by extension */
39 
40 typedef struct _multipart_event_start {
41 	size_t	content_length;
42 } multipart_event_start;
43 
44 typedef struct _multipart_event_formdata {
45 	size_t	post_bytes_processed;
46 	char	*name;
47 	char	**value;
48 	size_t	length;
49 	size_t	*newlength;
50 } multipart_event_formdata;
51 
52 typedef struct _multipart_event_file_start {
53 	size_t	post_bytes_processed;
54 	char	*name;
55 	char	**filename;
56 } multipart_event_file_start;
57 
58 typedef struct _multipart_event_file_data {
59 	size_t	post_bytes_processed;
60 	zend_off_t	offset;
61 	char	*data;
62 	size_t	length;
63 	size_t	*newlength;
64 } multipart_event_file_data;
65 
66 typedef struct _multipart_event_file_end {
67 	size_t	post_bytes_processed;
68 	char	*temp_filename;
69 	int	cancel_upload;
70 } multipart_event_file_end;
71 
72 typedef struct _multipart_event_end {
73 	size_t	post_bytes_processed;
74 } multipart_event_end;
75 
76 typedef int (*php_rfc1867_encoding_translation_t)(void);
77 typedef void (*php_rfc1867_get_detect_order_t)(const zend_encoding ***list, size_t *list_size);
78 typedef void (*php_rfc1867_set_input_encoding_t)(const zend_encoding *encoding);
79 typedef char* (*php_rfc1867_getword_t)(const zend_encoding *encoding, char **line, char stop);
80 typedef char* (*php_rfc1867_getword_conf_t)(const zend_encoding *encoding, char *str);
81 typedef char* (*php_rfc1867_basename_t)(const zend_encoding *encoding, char *str);
82 
83 SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
84 
85 PHPAPI void destroy_uploaded_files_hash(void);
86 extern PHPAPI zend_result (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra);
87 
88 SAPI_API void php_rfc1867_set_multibyte_callbacks(
89 					php_rfc1867_encoding_translation_t encoding_translation,
90 					php_rfc1867_get_detect_order_t get_detect_order,
91 					php_rfc1867_set_input_encoding_t set_input_encoding,
92 					php_rfc1867_getword_t getword,
93 					php_rfc1867_getword_conf_t getword_conf,
94 					php_rfc1867_basename_t basename);
95 
96 #endif /* RFC1867_H */
97