Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 41461f237e0ab3eb228df45ecdc3530bae8793ee @arraypad committed
Showing with 226 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +2 −0 CREDITS
  3. 0 EXPERIMENTAL
  4. +32 −0 config.m4
  5. +8 −0 config.w32
  6. +60 −0 php_re2.h
  7. +112 −0 re2.cpp
12 .gitignore
@@ -0,0 +1,12 @@
+.deps
+*.lo
+*.o
+*.la
+*.swp
+*.swo
+tests/*.diff
+tests/*.exp
+tests/*.log
+tests/*.out
+tests/*.php
+tests/*.sh
2 CREDITS
@@ -0,0 +1,2 @@
+re2
+Arpad Ray
0 EXPERIMENTAL
No changes.
32 config.m4
@@ -0,0 +1,32 @@
+dnl config.m4 for extension re2
+
+PHP_ARG_WITH(re2, for re2 support,
+[ --with-re2 Include re2 support])
+
+if test "$PHP_RE2" != "no"; then
+ SEARCH_PATH="/usr/local /usr"
+ SEARCH_FOR="/include/re2/re2.h"
+ if test -r $PHP_RE2/$SEARCH_FOR; then
+ RE2_DIR=$PHP_RE2
+ else
+ AC_MSG_CHECKING([for re2 files in default path])
+ for i in $SEARCH_PATH ; do
+ if test -r $i/$SEARCH_FOR; then
+ RE2_DIR=$i
+ AC_MSG_RESULT(found in $i)
+ fi
+ done
+ fi
+ if test -z "$RE2_DIR"; then
+ AC_MSG_RESULT([not found])
+ AC_MSG_ERROR([Please reinstall the re2 distribution])
+ fi
+
+ PHP_ADD_INCLUDE($RE2_DIR/include/re2)
+ PHP_ADD_LIBRARY(re2)
+
+ PHP_REQUIRE_CXX()
+ PHP_SUBST(RE2_SHARED_LIBADD)
+ PHP_ADD_LIBRARY(stdc++, 1, RE2_SHARED_LIBADD)
+ PHP_NEW_EXTENSION(re2, re2.cpp, $ext_shared)
+fi
8 config.w32
@@ -0,0 +1,8 @@
+// vim:ft=javascript
+
+ARG_WITH("re2", "for re2 support", "no");
+
+if (PHP_RE2 != "no") {
+ EXTENSION("re2", "re2.cpp");
+}
+
60 php_re2.h
@@ -0,0 +1,60 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2011 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: |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef PHP_RE2_H
+#define PHP_RE2_H
+
+#define PHP_RE2_EXTVER "0.0.1-dev"
+
+extern zend_module_entry re2_module_entry;
+#define phpext_re2_ptr &re2_module_entry
+
+#ifdef PHP_WIN32
+# define PHP_RE2_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_RE2_API __attribute__ ((visibility("default")))
+#else
+# define PHP_RE2_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+PHP_MINIT_FUNCTION(re2);
+PHP_MSHUTDOWN_FUNCTION(re2);
+PHP_RINIT_FUNCTION(re2);
+PHP_RSHUTDOWN_FUNCTION(re2);
+PHP_MINFO_FUNCTION(re2);
+
+#ifdef ZTS
+#define RE2_G(v) TSRMG(re2_globals_id, zend_re2_globals *, v)
+#else
+#define RE2_G(v) (re2_globals.v)
+#endif
+
+#endif /* PHP_RE2_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
+ */
112 re2.cpp
@@ -0,0 +1,112 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2011 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: Arpad Ray <arpad@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_re2.h"
+
+#include <re2.h>
+
+/* {{{ re2_functions[]
+ */
+const zend_function_entry re2_functions[] = {
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
+/* {{{ re2_module_entry
+ */
+zend_module_entry re2_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ "re2",
+ re2_functions,
+ PHP_MINIT(re2),
+ PHP_MSHUTDOWN(re2),
+ PHP_RINIT(re2),
+ PHP_RSHUTDOWN(re2),
+ PHP_MINFO(re2),
+#if ZEND_MODULE_API_NO >= 20010901
+ PHP_RE2_EXTVER,
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_RE2
+ZEND_GET_MODULE(re2)
+#endif
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(re2)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+PHP_MSHUTDOWN_FUNCTION(re2)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(re2)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+PHP_RSHUTDOWN_FUNCTION(re2)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
+PHP_MINFO_FUNCTION(re2)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "re2 support", "enabled");
+ php_info_print_table_row(2, "re2 version", PHP_RE2_EXTVER);
+ php_info_print_table_end();
+}
+/* }}} */
+
+
+/*
+ * 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 41461f2

Please sign in to comment.
Something went wrong with that request. Please try again.