]> granicus.if.org Git - php/commitdiff
getParameters -> zend_get_parameters_ex.
authorIlia Alshanetsky <iliaa@php.net>
Tue, 21 Jan 2003 15:27:39 +0000 (15:27 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 21 Jan 2003 15:27:39 +0000 (15:27 +0000)
ext/odbc/birdstep.c

index cd0e04d452e7401de9b223c902bf51a76a8113ae..bf8c665da787ec553c012a995327cf91ae096003 100644 (file)
@@ -103,6 +103,10 @@ ZEND_GET_MODULE(birdstep)
 THREAD_LS birdstep_module php_birdstep_module;
 THREAD_LS static HENV henv;
 
+#define PHP_GET_BIRDSTEP_RES_IDX(id) convert_to_long_ex(id); if (!(res = birdstep_find_result(list, Z_LVAL_PP(id)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)", Z_LVAL_PP(id)); RETURN_FALSE; } 
+#define PHP_BIRDSTEP_CHK_LNK(id) convert_to_long_ex(id); if (!(conn = birdstep_find_conn(list,Z_LVAL_PP(id)))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)", Z_LVAL_PP(id)); RETURN_FALSE; }
+                                                        
+
 static void _close_birdstep_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
        VConn *conn = (VConn *)rsrc->ptr;
@@ -226,7 +230,7 @@ static void birdstep_del_result(HashTable *list,int ind)
  */
 PHP_FUNCTION(birdstep_connect)
 {
-       pval *serv,*user,*pass;
+       zval **serv,**user,**pass;
        char *Serv = NULL;
        char *User = NULL;
        char *Pass = NULL;
@@ -239,15 +243,15 @@ PHP_FUNCTION(birdstep_connect)
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Too many open connections (%d)",php_birdstep_module.num_links);
                RETURN_FALSE;
        }
-       if (ZEND_NUM_ARGS() != 3 || getParameters(ht,3,&serv,&user,&pass) == FAILURE ) {
+       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &serv, &user, &pass) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_string(serv);
-       convert_to_string(user);
-       convert_to_string(pass);
-       Serv = Z_STRVAL_P(serv);
-       User = Z_STRVAL_P(user);
-       Pass = Z_STRVAL_P(pass);
+       convert_to_string_ex(serv);
+       convert_to_string_ex(user);
+       convert_to_string_ex(pass);
+       Serv = Z_STRVAL_PP(serv);
+       User = Z_STRVAL_PP(user);
+       Pass = Z_STRVAL_PP(pass);
        stat = SQLAllocConnect(henv,&hdbc);
        if ( stat != SQL_SUCCESS ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Could not allocate connection handle");
@@ -270,21 +274,17 @@ PHP_FUNCTION(birdstep_connect)
  */
 PHP_FUNCTION(birdstep_close)
 {
-       pval *id;
+       zval **id;
        VConn *conn;
 
-       if (ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE) {
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        SQLDisconnect(conn->hdbc);
        SQLFreeConnect(conn->hdbc);
-       birdstep_del_conn(list,Z_LVAL_P(id));
+       birdstep_del_conn(list,Z_LVAL_PP(id));
        php_birdstep_module.num_links--;
        RETURN_TRUE;
 }
@@ -294,7 +294,7 @@ PHP_FUNCTION(birdstep_close)
  */
 PHP_FUNCTION(birdstep_exec)
 {
-       pval *ind,*exec_str;
+       zval **ind, **exec_str;
        char *query = NULL;
        int indx;
        VConn *conn;
@@ -303,17 +303,13 @@ PHP_FUNCTION(birdstep_exec)
        SWORD cols,i,colnamelen;
        SDWORD rows,coldesc;
 
-       if (ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&exec_str) == FAILURE) {
+       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &exec_str) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       conn = birdstep_find_conn(list,Z_LVAL_P(ind));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
-       convert_to_string(exec_str);
-       query = Z_STRVAL_P(exec_str);
+       PHP_BIRDSTEP_CHK_LNK(ind);
+
+       convert_to_string_ex(exec_str);
+       query = Z_STRVAL_PP(exec_str);
 
        res = (Vresult *)emalloc(sizeof(Vresult));
        stat = SQLAllocStmt(conn->hdbc,&res->hstmt);
@@ -368,11 +364,7 @@ PHP_FUNCTION(birdstep_exec)
                        SQLColAttributes(res->hstmt,i+1,SQL_COLUMN_DISPLAY_SIZE,
                           NULL,0,NULL,&coldesc);
                        res->values[i].value = (char *)emalloc(coldesc+1);
-                       if ( res->values[i].value != NULL ) {
-                               SQLBindCol(res->hstmt,i+1,SQL_C_CHAR,
-                                  res->values[i].value,coldesc+1,
-                                  &res->values[i].vallen);
-                       }
+                       SQLBindCol(res->hstmt,i+1,SQL_C_CHAR, res->values[i].value,coldesc+1, &res->values[i].vallen);
                }
        }
        res->fetched = 0;
@@ -385,31 +377,27 @@ PHP_FUNCTION(birdstep_exec)
  */
 PHP_FUNCTION(birdstep_fetch)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
        RETCODE stat;
        UDWORD  row;
        UWORD   RowStat[1];
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
        if ( stat == SQL_NO_DATA_FOUND ) {
                SQLFreeStmt(res->hstmt,SQL_DROP);
-               birdstep_del_result(list,Z_LVAL_P(ind));
+               birdstep_del_result(list,Z_LVAL_PP(ind));
                RETURN_FALSE;
        }
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
                SQLFreeStmt(res->hstmt,SQL_DROP);
-               birdstep_del_result(list,Z_LVAL_P(ind));
+               birdstep_del_result(list,Z_LVAL_PP(ind));
                RETURN_FALSE;
        }
        res->fetched = 1;
@@ -421,7 +409,7 @@ PHP_FUNCTION(birdstep_fetch)
  */
 PHP_FUNCTION(birdstep_result)
 {
-       pval *ind,*col;
+       zval **ind, **col;
        Vresult *res;
        RETCODE stat;
        int i,sql_c_type;
@@ -430,20 +418,16 @@ PHP_FUNCTION(birdstep_result)
        SWORD indx = -1;
        char *field = NULL;
 
-       if ( ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &col) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
-       if ( Z_TYPE_P(col) == IS_STRING ) {
-               field = Z_STRVAL_P(col);
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
+       if ( Z_TYPE_PP(col) == IS_STRING ) {
+               field = Z_STRVAL_PP(col);
        } else {
-               convert_to_long(col);
-               indx = Z_LVAL_P(col);
+               convert_to_long_ex(col);
+               indx = Z_LVAL_PP(col);
        }
        if ( field ) {
                for ( i = 0; i < res->numcols; i++ ) {
@@ -466,13 +450,13 @@ PHP_FUNCTION(birdstep_result)
                stat = SQLExtendedFetch(res->hstmt,SQL_FETCH_NEXT,1,&row,RowStat);
                if ( stat == SQL_NO_DATA_FOUND ) {
                        SQLFreeStmt(res->hstmt,SQL_DROP);
-                       birdstep_del_result(list,Z_LVAL_P(ind));
+                       birdstep_del_result(list,Z_LVAL_PP(ind));
                        RETURN_FALSE;
                }
                if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLFetch return error");
                        SQLFreeStmt(res->hstmt,SQL_DROP);
-                       birdstep_del_result(list,Z_LVAL_P(ind));
+                       birdstep_del_result(list,Z_LVAL_PP(ind));
                        RETURN_FALSE;
                }
                res->fetched = 1;
@@ -491,13 +475,13 @@ l1:
                                res->values[indx].value,4095,&res->values[indx].vallen);
                        if ( stat == SQL_NO_DATA_FOUND ) {
                                SQLFreeStmt(res->hstmt,SQL_DROP);
-                               birdstep_del_result(list,Z_LVAL_P(ind));
+                               birdstep_del_result(list,Z_LVAL_PP(ind));
                                RETURN_FALSE;
                        }
                        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: SQLGetData return error");
                                SQLFreeStmt(res->hstmt,SQL_DROP);
-                               birdstep_del_result(list,Z_LVAL_P(ind));
+                               birdstep_del_result(list,Z_LVAL_PP(ind));
                                RETURN_FALSE;
                        }
                        if ( res->values[indx].valtype == SQL_LONGVARCHAR ) {
@@ -517,20 +501,16 @@ l1:
  */
 PHP_FUNCTION(birdstep_freeresult)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d)",Z_LVAL_P(ind));
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        SQLFreeStmt(res->hstmt,SQL_DROP);
-       birdstep_del_result(list,Z_LVAL_P(ind));
+       birdstep_del_result(list,Z_LVAL_PP(ind));
        RETURN_TRUE;
 }
 /* }}} */
@@ -539,19 +519,15 @@ PHP_FUNCTION(birdstep_freeresult)
  */
 PHP_FUNCTION(birdstep_autocommit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_on option failure");
@@ -565,19 +541,15 @@ PHP_FUNCTION(birdstep_autocommit)
  */
 PHP_FUNCTION(birdstep_off_autocommit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLSetConnectOption(conn->hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
        if ( stat != SQL_SUCCESS && stat != SQL_SUCCESS_WITH_INFO ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Set autocommit_off option failure");
@@ -591,19 +563,15 @@ PHP_FUNCTION(birdstep_off_autocommit)
  */
 PHP_FUNCTION(birdstep_commit)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id)
+
        stat = SQLTransact(NULL,conn->hdbc,SQL_COMMIT);
        if ( stat != SQL_SUCCESS ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Commit failure");
@@ -617,19 +585,15 @@ PHP_FUNCTION(birdstep_commit)
  */
 PHP_FUNCTION(birdstep_rollback)
 {
-       pval *id;
+       zval **id;
        RETCODE stat;
        VConn *conn;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&id) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &id) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(id);
-       conn = birdstep_find_conn(list,Z_LVAL_P(id));
-       if ( !conn ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not connection index (%d)",Z_LVAL_P(id));
-               RETURN_FALSE;
-       }
+       PHP_BIRDSTEP_CHK_LNK(id);
+
        stat = SQLTransact(NULL,conn->hdbc,SQL_ROLLBACK);
        if ( stat != SQL_SUCCESS ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Rollback failure");
@@ -643,21 +607,17 @@ PHP_FUNCTION(birdstep_rollback)
  */
 PHP_FUNCTION(birdstep_fieldname)
 {
-       pval *ind,*col;
+       zval **ind, **col;
        Vresult *res;
        SWORD indx;
 
-       if ( ZEND_NUM_ARGS() != 2 || getParameters(ht,2,&ind,&col) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &ind, &col) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
-       convert_to_long(col);
-       indx = Z_LVAL_P(col);
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
+       convert_to_long_ex(col);
+       indx = Z_LVAL_PP(col);
        if ( indx < 0 || indx >= res->numcols ) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Field index not in range");
                RETURN_FALSE;
@@ -670,18 +630,14 @@ PHP_FUNCTION(birdstep_fieldname)
  */
 PHP_FUNCTION(birdstep_fieldnum)
 {
-       pval *ind;
+       zval **ind;
        Vresult *res;
 
-       if ( ZEND_NUM_ARGS() != 1 || getParameters(ht,1,&ind) == FAILURE ) {
+       if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ind) == FAILURE ) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(ind);
-       res = birdstep_find_result(list,Z_LVAL_P(ind));
-       if ( !res ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Birdstep: Not result index (%d),Z_LVAL_P(ind)");
-               RETURN_FALSE;
-       }
+       PHP_GET_BIRDSTEP_RES_IDX(ind);
+
        RETURN_LONG(res->numcols);
 }
 /* }}} */