22
22
#include "config.h"
23
23
#endif
24
24
25
+ #define _GNU_SOURCE
26
+
25
27
#include "php.h"
26
28
#include "php_ini.h"
27
29
#include "ext/standard/info.h"
30
32
#include "php_pdo_firebird.h"
31
33
#include "php_pdo_firebird_int.h"
32
34
33
- #define _GNU_SOURCE
34
-
35
35
/* map driver specific error message to PDO error */
36
36
void _firebird_error (pdo_dbh_t * dbh , pdo_stmt_t * stmt , char const * file , long line TSRMLS_DC ) /* {{{ */
37
37
{
38
38
pdo_firebird_db_handle * H = stmt ? ((pdo_firebird_stmt * )stmt -> driver_data )-> H
39
39
: (pdo_firebird_db_handle * )dbh -> driver_data ;
40
- long * error_code = stmt ? & stmt -> error_code : & dbh -> error_code ;
40
+ enum pdo_error_type * error_code = stmt ? & stmt -> error_code : & dbh -> error_code ;
41
41
42
42
switch (isc_sqlcode (H -> isc_status )) {
43
43
@@ -273,14 +273,13 @@ static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len T
273
273
static int firebird_handle_quoter (pdo_dbh_t * dbh , const char * unquoted , int unquotedlen , /* {{{ */
274
274
char * * quoted , int * quotedlen TSRMLS_DC )
275
275
{
276
- pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
277
276
int qcount = 0 ;
278
277
char const * c ;
279
278
280
279
/* Firebird only requires single quotes to be doubled if string lengths are used */
281
280
282
281
/* count the number of ' characters */
283
- for (c = unquoted ; c = strchr (c ,'\'' ); qcount ++ , c ++ );
282
+ for (c = unquoted ; ( c = strchr (c ,'\'' ) ); qcount ++ , c ++ );
284
283
285
284
if (!qcount ) {
286
285
return 0 ;
@@ -292,7 +291,7 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unqu
292
291
* quoted = c = emalloc (* quotedlen + 1 );
293
292
294
293
/* foreach (chunk that ends in a quote) */
295
- for (l = unquoted ; r = strchr (l ,'\'' ); l = r + 1 ) {
294
+ for (l = unquoted ; ( r = strchr (l ,'\'' ) ); l = r + 1 ) {
296
295
297
296
/* copy the chunk */
298
297
strncpy (c , l , r - l );
@@ -362,7 +361,7 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
362
361
/* if (the value is really being changed and a transaction is open) */
363
362
if ((Z_LVAL_P (val )?1 :0 ) ^ dbh -> auto_commit && dbh -> in_txn ) {
364
363
365
- if (dbh -> auto_commit = Z_BVAL_P (val )) {
364
+ if (( dbh -> auto_commit = Z_BVAL_P (val ) )) {
366
365
/* just keep the running transaction but commit it */
367
366
if (isc_commit_retaining (H -> isc_status , & H -> tr )) {
368
367
RECORD_ERROR (dbh );
@@ -401,8 +400,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
401
400
pdo_firebird_db_handle * H = (pdo_firebird_db_handle * )dbh -> driver_data ;
402
401
403
402
switch (attr ) {
404
- char tmp [200 ] = "Firebird 1.0/Interbase 6" ;
405
- info_func_t info_func ;
403
+ char tmp [200 ];
406
404
407
405
case PDO_ATTR_AUTOCOMMIT :
408
406
ZVAL_LONG (val ,dbh -> auto_commit );
@@ -414,20 +412,23 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
414
412
415
413
case PDO_ATTR_CLIENT_VERSION : {
416
414
#if defined(__GNUC__ ) || defined(PHP_WIN32 )
415
+ info_func_t info_func = NULL ;
417
416
#ifdef __GNUC__
418
- info_func_t info_func = (info_func_t )dlsym (RTLD_DEFAULT , "isc_get_client_version" );
417
+ info_func = (info_func_t )dlsym (RTLD_DEFAULT , "isc_get_client_version" );
419
418
#else
420
419
HMODULE l = GetModuleHandle ("fbclient" );
421
420
422
421
if (!l && !(l = GetModuleHandle ("gds32" ))) {
423
- return 0 ;
422
+ break ;
424
423
}
425
424
info_func = (info_func_t )GetProcAddress (l , "isc_get_client_version" );
426
425
#endif
427
426
if (info_func ) {
428
427
info_func (tmp );
428
+ ZVAL_STRING (val ,tmp ,1 );
429
+ } else {
430
+ ZVAL_STRING (val ,"Firebird 1.0/Interbase 6" ,1 );
429
431
}
430
- ZVAL_STRING (val ,tmp ,1 );
431
432
#else
432
433
ZVAL_NULL (val );
433
434
#endif
@@ -458,7 +459,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
458
459
if (sqlcode ) {
459
460
add_next_index_long (info , sqlcode );
460
461
461
- while (l = isc_interprete (& buf [i ],& s )) {
462
+ while (( l = isc_interprete (& buf [i ],& s ) )) {
462
463
i += l ;
463
464
strcpy (& buf [i ++ ], " " );
464
465
}
@@ -504,7 +505,6 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
504
505
isc_dpb_user_name , isc_dpb_password , isc_dpb_lc_ctype , isc_dpb_sql_role_name };
505
506
char const * dpb_values [] = { dbh -> username , dbh -> password , vars [1 ].optval , vars [2 ].optval };
506
507
char dpb_buffer [256 ] = { isc_dpb_version1 }, * dpb ;
507
- short len ;
508
508
509
509
dpb = dpb_buffer + 1 ;
510
510
0 commit comments