RPA Toolkit
work on the PHP extension.
authorMartin Stoilov <martin@rpasearch.com>
Wed, 15 Jun 2011 05:14:19 +0000 (22:14 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Wed, 15 Jun 2011 05:14:19 +0000 (22:14 -0700)
phpext/prpa/php_prpa.h
phpext/prpa/prpa.c
phpext/prpa/tests/003.phpt

index 434dca5..5774489 100644 (file)
@@ -48,6 +48,8 @@ PHP_FUNCTION(rpa_dbex_close);
 PHP_FUNCTION(rpa_dbex_load);
 PHP_FUNCTION(rpa_dbex_compile);
 PHP_FUNCTION(rpa_dbex_lookup);
+PHP_FUNCTION(rpa_dbex_first);
+PHP_FUNCTION(rpa_dbex_last);
 PHP_FUNCTION(rpa_stat_create);
 PHP_FUNCTION(rpa_stat_scan);
 PHP_FUNCTION(rpa_stat_match);
index 8a04868..29b66c3 100644 (file)
@@ -81,6 +81,8 @@ zend_function_entry prpa_functions[] = {
     PHP_FE(rpa_dbex_load, NULL)
     PHP_FE(rpa_dbex_compile, NULL)
     PHP_FE(rpa_dbex_lookup, NULL)
+    PHP_FE(rpa_dbex_first, NULL)
+    PHP_FE(rpa_dbex_last, NULL)
     PHP_FE(rpa_stat_create, NULL)
     PHP_FE(rpa_stat_match, NULL)
 
@@ -342,6 +344,40 @@ PHP_FUNCTION(rpa_dbex_lookup)
 }
 
 
+PHP_FUNCTION(rpa_dbex_first)
+{
+       zval *zres;
+    php_rpa_dbex *pPhpDbex;
+       long ret;
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres) == FAILURE) {
+               RETURN_LONG(-1);
+    }
+
+    ZEND_FETCH_RESOURCE(pPhpDbex, php_rpa_dbex*, &zres, -1, PHP_RPA_DBEX_RES_NAME, le_rpa_dbex);
+
+    ret = rpa_dbex_first(pPhpDbex->hDbex);
+       RETURN_LONG(ret);
+}
+
+
+PHP_FUNCTION(rpa_dbex_last)
+{
+       zval *zres;
+    php_rpa_dbex *pPhpDbex;
+       long ret;
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres) == FAILURE) {
+               RETURN_LONG(-1);
+    }
+
+    ZEND_FETCH_RESOURCE(pPhpDbex, php_rpa_dbex*, &zres, -1, PHP_RPA_DBEX_RES_NAME, le_rpa_dbex);
+
+    ret = rpa_dbex_last(pPhpDbex->hDbex);
+       RETURN_LONG(ret);
+}
+
+
 PHP_FUNCTION(rpa_dbex_compile)
 {
        zval *zres;
index f27d628..582ddee 100644 (file)
@@ -16,6 +16,7 @@ rpa_dbex_match($hDbex, $pattern, $myname)
       $pattern = rpa_dbex_lookup($hDbex, "name");
       $myname = "Martin Stoilov";
       $stat = rpa_stat_create($hDbex, 0);
+      $pattern = rpa_dbex_first($hDbex);
       $ret = rpa_stat_match($stat, $pattern, RPA_ENCODING_ICASE_UTF8, $myname);
       $matched = "matched: " . substr($myname, 0, $ret) . "\n";
       echo($matched);