Permalink
Browse files

Initial commit

  • Loading branch information...
mgdm committed Nov 17, 2009
0 parents commit 1cf00e1b3e9841882d07586a0fc85cfd80d85420
Showing with 343 additions and 0 deletions.
  1. +3 −0 .cvsignore
  2. +2 −0 CREDITS
  3. +78 −0 config.m4
  4. +13 −0 config.w32
  5. +164 −0 pango.c
  6. +83 −0 php_pango.h
@@ -0,0 +1,3 @@
+.deps
+*.lo
+*.la
@@ -0,0 +1,2 @@
+PHP Pango text rendering library bindings
+Michael Maclean
@@ -0,0 +1,78 @@
+dnl
+dnl $ Id: pango 1.0.1$
+dnl
+
+PHP_ARG_WITH(pango, for Cairo graphics library support,
+[ --with-pango Enable Cairo support], yes)
+
+if test "$PHP_PANGO" != "no"; then
+ export OLD_CPPFLAGS="$CPPFLAGS"
+ export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_PANGO"
+
+ AC_MSG_CHECKING(PHP version)
+ AC_TRY_COMPILE([#include <php_version.h>], [
+#if PHP_VERSION_ID < 50200
+#error this extension requires at least PHP version 5.2.0
+#endif
+],
+[AC_MSG_RESULT(ok)],
+[AC_MSG_ERROR([need at least PHP 5.2.0])])
+
+ export CPPFLAGS="$OLD_CPPFLAGS"
+
+ PHP_SUBST(PANGO_SHARED_LIBADD)
+ AC_DEFINE(HAVE_PANGO, 1, [ ])
+
+ PHP_NEW_EXTENSION(pango, pango.c, $ext_shared)
+
+ EXT_PANGO_HEADERS="php_pango_api.h"
+
+ ifdef([PHP_INSTALL_HEADERS], [
+ PHP_INSTALL_HEADERS(ext/pango, $EXT_PANGO_HEADERS)
+ ])
+
+ if test "$PHP_PANGO" != "no"; then
+ PANGO_CHECK_DIR=$PHP_PANGO
+ PANGO_TEST_FILE=/include/pango.h
+ PANGO_LIBNAME=pango
+ fi
+ condition="$PANGO_CHECK_DIR$PANGO_TEST_FILE"
+
+ if test -r $condition; then
+ PANGO_DIR=$PANGO_CHECK_DIR
+ CFLAGS="$CFLAGS -I$PANGO_DIR/include"
+ LDFLAGS=`$PANGO_DIR/bin/pango-config --libs`
+ else
+ AC_MSG_CHECKING(for pkg-config)
+
+ if test ! -f "$PKG_CONFIG"; then
+ PKG_CONFIG=`which pkg-config`
+ fi
+
+ if test -f "$PKG_CONFIG"; then
+ AC_MSG_RESULT(found)
+ AC_MSG_CHECKING(for pango)
+
+ if $PKG_CONFIG --exists pango; then
+ if $PKG_CONFIG --atleast-version=1.20 pango; then
+ pango_version_full=`$PKG_CONFIG --modversion pango`
+ AC_MSG_RESULT([found $pango_version_full])
+ PANGO_LIBS="$LDFLAGS `$PKG_CONFIG --libs pango`"
+ PANGO_INCS="$CFLAGS `$PKG_CONFIG --cflags-only-I pango`"
+ PHP_EVAL_INCLINE($PANGO_INCS)
+ PHP_EVAL_LIBLINE($PANGO_LIBS, PANGO_SHARED_LIBADD)
+ AC_DEFINE(HAVE_PANGO, 1, [whether pango exists in the system])
+ else
+ AC_MSG_RESULT(too old)
+ AC_MSG_ERROR(Ooops ! You need at least pango 1.20)
+ fi
+ else
+ AC_MSG_RESULT(not found)
+ AC_MSG_ERROR(Ooops ! no pango detected in the system)
+ fi
+ else
+ AC_MSG_RESULT(not found)
+ AC_MSG_ERROR(Ooops ! no pkg-config found .... )
+ fi
+ fi
+fi
@@ -0,0 +1,13 @@
+// $Id$
+// vim:ft=javascript
+
+// If your extension references something external, use ARG_WITH
+// ARG_WITH("pango", "for pango support", "no");
+
+// Otherwise, use ARG_ENABLE
+// ARG_ENABLE("pango", "enable pango support", "no");
+
+if (PHP_PANGO != "no") {
+ EXTENSION("pango", "pango.c");
+}
+
164 pango.c
@@ -0,0 +1,164 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2008 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Michael Maclean <mgdm@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: header 252479 2008-02-07 19:39:50Z iliaa $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_pango.h"
+
+/* If you declare any globals in php_pango.h uncomment this:
+ZEND_DECLARE_MODULE_GLOBALS(pango)
+*/
+
+zend_class_entry *pango_ce_pango;
+zend_object_handlers *pango_std_object_handlers;
+
+/* proto int pango_version(void)
+ returns the Pango version */
+PHP_FUNCTION(pango_version)
+{
+ if(zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ RETURN_LONG(pango_version());
+}
+
+/* {{{ pango_functions[]
+ *
+ * Every user visible function must have an entry in pango_functions[].
+ */
+const zend_function_entry pango_functions[] = {
+ PHP_FE(pango_version, NULL)
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
+/* {{{ pango_module_entry
+ */
+zend_module_entry pango_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ "pango",
+ pango_functions,
+ PHP_MINIT(pango),
+ PHP_MSHUTDOWN(pango),
+ NULL,
+ NULL,
+ PHP_MINFO(pango),
+#if ZEND_MODULE_API_NO >= 20010901
+ "0.1", /* Replace with version number for your extension */
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_PANGO
+ZEND_GET_MODULE(pango)
+#endif
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(pango)
+{
+ /* If you have INI entries, uncomment these lines
+ REGISTER_INI_ENTRIES();
+ */
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+PHP_MSHUTDOWN_FUNCTION(pango)
+{
+ /* uncomment this line if you have INI entries
+ UNREGISTER_INI_ENTRIES();
+ */
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
+PHP_MINFO_FUNCTION(pango)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Pango text rendering support", "enabled");
+ php_info_print_table_colspan_header(2,
+#ifdef COMPILE_DL_CAIRO
+ "compiled as dynamic module"
+#else
+ "compiled as static module"
+#endif
+ );
+ php_info_print_table_row(2, "Pango version", PANGO_VERSION_STRING);
+ php_info_print_table_row(2, "Extension version", PHP_PANGO_VERSION);
+ php_info_print_table_end();
+
+ /* Remove comments if you have entries in php.ini
+ DISPLAY_INI_ENTRIES();
+ */
+}
+/* }}} */
+
+
+/* Remove the following function when you have succesfully modified config.m4
+ so that your module can be compiled into PHP, it exists only for testing
+ purposes. */
+
+/* Every user-visible function in PHP should document itself in the source */
+/* {{{ proto string confirm_pango_compiled(string arg)
+ Return a string to confirm that the module is compiled in */
+PHP_FUNCTION(confirm_pango_compiled)
+{
+ char *arg = NULL;
+ int arg_len, len;
+ char *strg;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
+ }
+
+ len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "pango", arg);
+ RETURN_STRINGL(strg, len, 0);
+}
+/* }}} */
+/* The previous line is meant for vim and emacs, so it can correctly fold and
+ unfold functions in source code. See the corresponding marks just before
+ function definition, where the functions purpose is also documented. Please
+ follow this convention for the convenience of others editing your code.
+*/
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
@@ -0,0 +1,83 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2008 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id: header 252479 2008-02-07 19:39:50Z iliaa $ */
+
+#ifndef PHP_PANGO_H
+#define PHP_PANGO_H
+
+#define PHP_PANGO_VERSION "0.1.0-dev"
+
+extern zend_module_entry pango_module_entry;
+#define phpext_pango_ptr &pango_module_entry
+
+#ifdef PHP_WIN32
+# define PHP_PANGO_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_PANGO_API __attribute__ ((visibility("default")))
+#else
+# define PHP_PANGO_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+PHP_MINIT_FUNCTION(pango);
+PHP_MSHUTDOWN_FUNCTION(pango);
+PHP_MINFO_FUNCTION(pango);
+
+PHP_FUNCTION(pango_version);
+
+/*
+ Declare any global variables you may need between the BEGIN
+ and END macros here:
+
+ZEND_BEGIN_MODULE_GLOBALS(pango)
+ long global_value;
+ char *global_string;
+ZEND_END_MODULE_GLOBALS(pango)
+*/
+
+/* In every utility function you add that needs to use variables
+ in php_pango_globals, call TSRMLS_FETCH(); after declaring other
+ variables used by that function, or better yet, pass in TSRMLS_CC
+ after the last function argument and declare your utility function
+ with TSRMLS_DC after the last declared argument. Always refer to
+ the globals in your function as PANGO_G(variable). You are
+ encouraged to rename these macros something shorter, see
+ examples in any other php module directory.
+*/
+
+#ifdef ZTS
+#define PANGO_G(v) TSRMG(pango_globals_id, zend_pango_globals *, v)
+#else
+#define PANGO_G(v) (pango_globals.v)
+#endif
+
+#endif /* PHP_PANGO_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */

0 comments on commit 1cf00e1

Please sign in to comment.