Added a new file so that the extension can be used in other extensions
[phpCairo.git] / src / cairo / Cairo.c
bloba8195562448760c06f2d1f7a7359bc97fe780af5
1 /*
2 +----------------------------------------------------------------------+
3 | This source file is subject to version 3.0 of the PHP license, |
4 | that is bundled with this package in the file LICENSE, and is |
5 | available through the world-wide-web at the following url: |
6 | http://www.php.net/license/3_0.txt. |
7 | If you did not receive a copy of the PHP license and are unable to |
8 | obtain it through the world-wide-web, please send a note to |
9 | license@php.net so we can mail you a copy immediately. |
10 +----------------------------------------------------------------------+
11 | Authors: Akshat Gupta <g.akshat@gmail.com> |
12 +----------------------------------------------------------------------+
15 /* $ Id: 1.0.1$ */
17 #include "phpCairo_api.h"
18 #include "php_cairo.h"
19 #include "CairoExceptionMacro.c"
20 #include "CairoException.c"
21 #include "CairoFont.c"
22 #include "CairoMatrix.c"
23 #include "CairoPath.c"
24 #include "CairoSurface.c"
25 #include "CairoPattern.c"
26 #include "CairoContext.c"
27 #if HAVE_CAIRO
29 /* {{{ Class definitions */
30 /* }}} Class definitions*/
32 /* {{{ cairo_functions[] */
33 function_entry cairo_functions[] = {
34 PHP_FE(cairoVersion , cairo_version_arg_info)
35 PHP_FE(cairoVersionString, cairo_version_string_arg_info)
36 { NULL, NULL, NULL }
38 /* }}} */
41 /* {{{ cairo_module_entry
43 zend_module_entry cairo_module_entry = {
44 STANDARD_MODULE_HEADER,
45 "cairo",
46 cairo_functions,
47 PHP_MINIT(cairo), /* Replace with NULL if there is nothing to do at php startup */
48 PHP_MSHUTDOWN(cairo), /* Replace with NULL if there is nothing to do at php shutdown */
49 PHP_RINIT(cairo), /* Replace with NULL if there is nothing to do at request start */
50 PHP_RSHUTDOWN(cairo), /* Replace with NULL if there is nothing to do at request end */
51 PHP_MINFO(cairo),
52 "1.0.1",
53 STANDARD_MODULE_PROPERTIES
55 /* }}} */
57 #ifdef COMPILE_DL_CAIRO
58 ZEND_GET_MODULE(cairo)
59 #endif
62 /* {{{ PHP_MINIT_FUNCTION */
63 PHP_MINIT_FUNCTION(cairo)
65 class_init_CairoContext();
66 class_init_CairoFontFace();
67 class_init_CairoFontOptions();
68 class_init_CairoMatrix();
69 class_init_CairoPath();
70 class_init_CairoPattern();
71 class_init_CairoGradient();
72 class_init_CairoLinearGradient();
73 class_init_CairoRadialGradient();
74 class_init_CairoSolidPattern();
75 class_init_CairoSurfacePattern();
76 class_init_CairoScaledFont();
77 class_init_CairoSurface();
78 class_init_CairoImageSurface();
79 class_init_CairoPDFSurface();
80 class_init_CairoPSSurface();
81 class_init_CairoQuartzSurface();
82 class_init_CairoSVGSurface();
83 class_init_CairoWin32Surface();
84 class_init_CairoXlibSurface();
85 class_init_CairoException();
87 /* add your stuff here */
89 /* constants */
90 #if HAS_ATSUI_FONT
91 REGISTER_LONG_CONSTANT( "HAS_ATSUI_FONT", 1, CONST_CS | CONST_PERSISTENT);
92 #else
93 REGISTER_LONG_CONSTANT( "HAS_ATSUI_FONT", 0, CONST_CS | CONST_PERSISTENT);
94 #endif
95 #if HAS_FT_FONT
96 REGISTER_LONG_CONSTANT( "HAS_FT_FONT", 1, CONST_CS | CONST_PERSISTENT);
97 #else
98 REGISTER_LONG_CONSTANT( "HAS_FT_FONT", 0, CONST_CS | CONST_PERSISTENT);
99 #endif
100 #if HAS_GLITZ_SURFACE
101 REGISTER_LONG_CONSTANT( "HAS_GLITZ_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
102 #else
103 REGISTER_LONG_CONSTANT( "HAS_GLITZ_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
104 #endif
105 #if HAS_PDF_SURFACE
106 REGISTER_LONG_CONSTANT( "HAS_PDF_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
107 #else
108 REGISTER_LONG_CONSTANT( "HAS_PDF_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
109 #endif
110 #if HAS_PNG_FUNCTIONS
111 REGISTER_LONG_CONSTANT( "HAS_PNG_FUNCTIONS", 1, CONST_CS | CONST_PERSISTENT);
112 #else
113 REGISTER_LONG_CONSTANT( "HAS_PNG_FUNCTIONS", 0, CONST_CS | CONST_PERSISTENT);
114 #endif
115 #if HAS_PS_SURFACE
116 REGISTER_LONG_CONSTANT( "HAS_PS_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
117 #else
118 REGISTER_LONG_CONSTANT( "HAS_PS_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
119 #endif
120 #if HAS_SVG_SURFACE
121 REGISTER_LONG_CONSTANT( "HAS_SVG_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
122 #else
123 REGISTER_LONG_CONSTANT( "HAS_SVG_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
124 #endif
125 #if HAS_QUARTZ_SURFACE
126 REGISTER_LONG_CONSTANT( "HAS_QUARTZ_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
127 #else
128 REGISTER_LONG_CONSTANT( "HAS_QUARTZ_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
129 #endif
130 #if HAS_WIN32_FONT
131 REGISTER_LONG_CONSTANT( "HAS_WIN32_FONT", 1, CONST_CS | CONST_PERSISTENT);
132 #else
133 REGISTER_LONG_CONSTANT( "HAS_WIN32_FONT", 0, CONST_CS | CONST_PERSISTENT);
134 #endif
135 #if HAS_WIN32_SURFACE
136 REGISTER_LONG_CONSTANT( "HAS_WIN32_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
137 #else
138 REGISTER_LONG_CONSTANT( "HAS_WIN32_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
139 #endif
140 #if HAS_XCB_SURFACE
141 REGISTER_LONG_CONSTANT( "HAS_XCB_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
142 #else
143 REGISTER_LONG_CONSTANT( "HAS_XCB_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
144 #endif
145 #if HAS_XLIB_SURFACE
146 REGISTER_LONG_CONSTANT( "HAS_XLIB_SURFACE", 1, CONST_CS | CONST_PERSISTENT);
147 #else
148 REGISTER_LONG_CONSTANT( "HAS_XLIB_SURFACE", 0, CONST_CS | CONST_PERSISTENT);
149 #endif
151 #define CONSTANT(x) REGISTER_LONG_CONSTANT( #x, CAIRO_##x, CONST_CS | CONST_PERSISTENT)
152 CONSTANT(ANTIALIAS_DEFAULT);
153 CONSTANT(ANTIALIAS_NONE);
154 CONSTANT(ANTIALIAS_GRAY);
155 CONSTANT(ANTIALIAS_SUBPIXEL);
157 CONSTANT(CONTENT_COLOR);
158 CONSTANT(CONTENT_ALPHA);
159 CONSTANT(CONTENT_COLOR_ALPHA);
161 CONSTANT(EXTEND_NONE);
162 CONSTANT(EXTEND_REPEAT);
163 CONSTANT(EXTEND_REFLECT);
164 CONSTANT(EXTEND_PAD);
166 CONSTANT(FILL_RULE_WINDING);
167 CONSTANT(FILL_RULE_EVEN_ODD);
169 CONSTANT(FILTER_FAST);
170 CONSTANT(FILTER_GOOD);
171 CONSTANT(FILTER_BEST);
172 CONSTANT(FILTER_NEAREST);
173 CONSTANT(FILTER_BILINEAR);
174 CONSTANT(FILTER_GAUSSIAN);
176 CONSTANT(FONT_WEIGHT_NORMAL);
177 CONSTANT(FONT_WEIGHT_BOLD);
179 CONSTANT(FONT_SLANT_NORMAL);
180 CONSTANT(FONT_SLANT_ITALIC);
181 CONSTANT(FONT_SLANT_OBLIQUE);
183 CONSTANT(FORMAT_ARGB32);
184 CONSTANT(FORMAT_RGB24);
185 CONSTANT(FORMAT_A8);
186 CONSTANT(FORMAT_A1);
187 CONSTANT(FORMAT_RGB16_565);
189 CONSTANT(HINT_METRICS_DEFAULT);
190 CONSTANT(HINT_METRICS_OFF);
191 CONSTANT(HINT_METRICS_ON);
193 CONSTANT(HINT_STYLE_DEFAULT);
194 CONSTANT(HINT_STYLE_NONE);
195 CONSTANT(HINT_STYLE_SLIGHT);
196 CONSTANT(HINT_STYLE_MEDIUM);
197 CONSTANT(HINT_STYLE_FULL);
199 CONSTANT(LINE_CAP_BUTT);
200 CONSTANT(LINE_CAP_ROUND);
201 CONSTANT(LINE_CAP_SQUARE);
203 CONSTANT(LINE_JOIN_MITER);
204 CONSTANT(LINE_JOIN_ROUND);
205 CONSTANT(LINE_JOIN_BEVEL);
207 CONSTANT(OPERATOR_CLEAR);
209 CONSTANT(OPERATOR_SOURCE);
210 CONSTANT(OPERATOR_OVER);
211 CONSTANT(OPERATOR_IN);
212 CONSTANT(OPERATOR_OUT);
213 CONSTANT(OPERATOR_ATOP);
215 CONSTANT(OPERATOR_DEST);
216 CONSTANT(OPERATOR_DEST_OVER);
217 CONSTANT(OPERATOR_DEST_IN);
218 CONSTANT(OPERATOR_DEST_OUT);
219 CONSTANT(OPERATOR_DEST_ATOP);
221 CONSTANT(OPERATOR_XOR);
222 CONSTANT(OPERATOR_ADD);
223 CONSTANT(OPERATOR_SATURATE);
225 CONSTANT(PATH_MOVE_TO);
226 CONSTANT(PATH_LINE_TO);
227 CONSTANT(PATH_CURVE_TO);
228 CONSTANT(PATH_CLOSE_PATH);
230 CONSTANT(SUBPIXEL_ORDER_DEFAULT);
231 CONSTANT(SUBPIXEL_ORDER_RGB);
232 CONSTANT(SUBPIXEL_ORDER_BGR);
233 CONSTANT(SUBPIXEL_ORDER_VRGB);
234 CONSTANT(SUBPIXEL_ORDER_VBGR);
235 #undef CONSTANT
239 return SUCCESS;
241 /* }}} */
244 /* {{{ PHP_MSHUTDOWN_FUNCTION */
245 PHP_MSHUTDOWN_FUNCTION(cairo)
248 /* add your stuff here */
250 return SUCCESS;
252 /* }}} */
255 /* {{{ PHP_RINIT_FUNCTION */
256 PHP_RINIT_FUNCTION(cairo)
258 /* add your stuff here */
260 return SUCCESS;
262 /* }}} */
265 /* {{{ PHP_RSHUTDOWN_FUNCTION */
266 PHP_RSHUTDOWN_FUNCTION(cairo)
268 /* add your stuff here */
270 return SUCCESS;
272 /* }}} */
275 /* {{{ PHP_MINFO_FUNCTION */
276 PHP_MINFO_FUNCTION(cairo)
278 php_info_print_box_start(0);
279 php_printf("<p>PHP bindings for Cairo Graphic Library</p>\n");
280 php_printf("<p>Version 1.0.1devel (2008-05-22)</p>\n");
281 php_printf("<p><b>Authors:</b></p>\n");
282 php_printf("<p>Akshat Gupta &lt;g.akshat@gmail.com&gt; (lead)</p>\n");
283 php_info_print_box_end();
284 /* add your stuff here */
287 /* }}} */
290 /* {{{ proto int cairoVersion()
292 PHP_FUNCTION(cairoVersion)
297 if (ZEND_NUM_ARGS()>0) {
298 WRONG_PARAM_COUNT;
302 RETURN_LONG(cairo_version());
304 /* }}} cairo_version */
307 /* {{{ proto string cairVersionString()
309 PHP_FUNCTION(cairoVersionString)
312 char *a;
314 if (ZEND_NUM_ARGS()>0) {
315 WRONG_PARAM_COUNT;
318 RETURN_STRING(cairo_version_string(), 1);
320 /* }}} cairo_version_string */
322 #endif /* HAVE_CAIRO */
326 * Local variables:
327 * tab-width: 4
328 * c-basic-offset: 4
329 * End:
330 * vim600: noet sw=4 ts=4 fdm=marker
331 * vim<600: noet sw=4 ts=4