xref: /imagick/php_imagick_file.h (revision 41856e90)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5 / Imagick	                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 2006-2013 Mikko Koppanen, Scott MacVicar               |
6    | ImageMagick (c) ImageMagick Studio LLC                               |
7    +----------------------------------------------------------------------+
8    | This source file is subject to version 3.01 of the PHP license,      |
9    | that is bundled with this package in the file LICENSE, and is        |
10    | available through the world-wide-web at the following url:           |
11    | http://www.php.net/license/3_01.txt                                  |
12    | If you did not receive a copy of the PHP license and are unable to   |
13    | obtain it through the world-wide-web, please send a note to          |
14    | license@php.net so we can mail you a copy immediately.               |
15    +----------------------------------------------------------------------+
16    | Author: Mikko Kopppanen <mkoppanen@php.net>                          |
17    |         Scott MacVicar <scottmac@php.net>                            |
18    +----------------------------------------------------------------------+
19 */
20 #ifndef PHP_IMAGICK_FILE_H
21 # define PHP_IMAGICK_FILE_H
22 
23 #include "php_imagick.h"
24 #include "php_imagick_defs.h"
25 
26 typedef enum {
27 	ImagickUndefinedType, /* Don't know */
28 	ImagickFile,          /* Use ImageMagick to read the file */
29 	ImagickUri,           /* Use PHP streams to read the file */
30 	ImagickVirtualFormat, /* The file is a virtual, use ImageMagick */
31 } ImagickFileType;
32 
33 struct php_imagick_file_t {
34 	/* The file type */
35 	ImagickFileType type;
36 
37 	/* Absolute path to the file, emalloced */
38 	char *absolute_path;
39 	size_t absolute_path_len;
40 
41 	/* Original filename */
42 	char filename[MaxTextExtent];
43 	size_t filename_len;
44 };
45 
46 typedef enum {
47 	ImagickUndefinedOperation,
48 	ImagickReadImage,
49 	ImagickPingImage,
50 	ImagickWriteImage,
51 	ImagickWriteImages,
52 
53 	ImagickWriteImageFile,
54 	ImagickWriteImagesFile,
55 
56 	ImagickReadImageFile,
57 	ImagickPingImageFile,
58 } ImagickOperationType;
59 
60 
61 zend_bool php_imagick_file_init(struct php_imagick_file_t *file, const char *filename, size_t filename_len TSRMLS_DC);
62 
63 void php_imagick_file_deinit(struct php_imagick_file_t *file);
64 
65 int php_imagick_safe_mode_check(const char *filename TSRMLS_DC);
66 
67 /* Read operations */
68 php_imagick_rw_result_t php_imagick_read_file(php_imagick_object *intern, struct php_imagick_file_t *file, ImagickOperationType type TSRMLS_DC);
69 
70 /* Write operations */
71 php_imagick_rw_result_t php_imagick_write_file(php_imagick_object *intern, struct php_imagick_file_t *file, ImagickOperationType type, zend_bool adjoin TSRMLS_DC);
72 
73 /* Handle streams */
74 zend_bool php_imagick_stream_handler(php_imagick_object *intern, php_stream *stream, ImagickOperationType type TSRMLS_DC);
75 
76 #endif /* PHP_IMAGICK_FILE_H */