Skip to content

Commit 54b12bc

Browse files
SakiTakamachiGirgias
authored andcommitted
Unified function naming conventions
1 parent b035cb6 commit 54b12bc

File tree

3 files changed

+116
-116
lines changed

3 files changed

+116
-116
lines changed

ext/pdo_firebird/firebird_driver.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "php_pdo_firebird.h"
3232
#include "php_pdo_firebird_int.h"
3333

34-
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const zend_string*, XSQLDA*, isc_stmt_handle*,
34+
static int php_firebird_alloc_prepare_stmt(pdo_dbh_t*, const zend_string*, XSQLDA*, isc_stmt_handle*,
3535
HashTable*);
3636

3737
const char CHR_LETTER = 1;
@@ -173,7 +173,7 @@ static const char classes_array[] = {
173173
/* 127 */ 0
174174
};
175175

176-
static inline char classes(char idx)
176+
static inline char php_firebird_classes(char idx)
177177
{
178178
unsigned char uidx = (unsigned char) idx;
179179
if (uidx > 127) return 0;
@@ -191,7 +191,7 @@ typedef enum {
191191
ttOther
192192
} FbTokenType;
193193

194-
static FbTokenType getToken(const char** begin, const char* end)
194+
static FbTokenType php_firebird_get_token(const char** begin, const char* end)
195195
{
196196
FbTokenType ret = ttNone;
197197
const char* p = *begin;
@@ -259,27 +259,27 @@ static FbTokenType getToken(const char** begin, const char* end)
259259
break;
260260

261261
default:
262-
if (classes(c) & CHR_DIGIT)
262+
if (php_firebird_classes(c) & CHR_DIGIT)
263263
{
264-
while (p < end && (classes(*p) & CHR_DIGIT))
264+
while (p < end && (php_firebird_classes(*p) & CHR_DIGIT))
265265
p++;
266266
ret = ttOther;
267267
}
268-
else if (classes(c) & CHR_IDENT)
268+
else if (php_firebird_classes(c) & CHR_IDENT)
269269
{
270-
while (p < end && (classes(*p) & CHR_IDENT))
270+
while (p < end && (php_firebird_classes(*p) & CHR_IDENT))
271271
p++;
272272
ret = ttIdent;
273273
}
274-
else if (classes(c) & CHR_WHITE)
274+
else if (php_firebird_classes(c) & CHR_WHITE)
275275
{
276-
while (p < end && (classes(*p) & CHR_WHITE))
276+
while (p < end && (php_firebird_classes(*p) & CHR_WHITE))
277277
p++;
278278
ret = ttWhite;
279279
}
280280
else
281281
{
282-
while (p < end && !(classes(*p) & (CHR_DIGIT | CHR_IDENT | CHR_WHITE)) &&
282+
while (p < end && !(php_firebird_classes(*p) & (CHR_DIGIT | CHR_IDENT | CHR_WHITE)) &&
283283
(*p != '/') && (*p != '-') && (*p != ':') && (*p != '?') &&
284284
(*p != '\'') && (*p != '"'))
285285
{
@@ -293,21 +293,21 @@ static FbTokenType getToken(const char** begin, const char* end)
293293
return ret;
294294
}
295295

296-
int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
296+
static int php_firebird_preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
297297
{
298298
bool passAsIs = 1, execBlock = 0;
299299
zend_long pindex = -1;
300300
char pname[254], ident[253], ident2[253];
301301
unsigned int l;
302302
const char* p = ZSTR_VAL(sql), * end = ZSTR_VAL(sql) + ZSTR_LEN(sql);
303303
const char* start = p;
304-
FbTokenType tok = getToken(&p, end);
304+
FbTokenType tok = php_firebird_get_token(&p, end);
305305

306306
const char* i = start;
307307
while (p < end && (tok == ttComment || tok == ttWhite))
308308
{
309309
i = p;
310-
tok = getToken(&p, end);
310+
tok = php_firebird_get_token(&p, end);
311311
}
312312

313313
if (p >= end || tok != ttIdent)
@@ -331,11 +331,11 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
331331
/* For EXECUTE PROCEDURE and EXECUTE BLOCK statements, named parameters must be processed. */
332332
/* However, in EXECUTE BLOCK this is done in a special way. */
333333
const char* i2 = p;
334-
tok = getToken(&p, end);
334+
tok = php_firebird_get_token(&p, end);
335335
while (p < end && (tok == ttComment || tok == ttWhite))
336336
{
337337
i2 = p;
338-
tok = getToken(&p, end);
338+
tok = php_firebird_get_token(&p, end);
339339
}
340340
if (p >= end || tok != ttIdent)
341341
{
@@ -374,11 +374,11 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
374374
while (p < end)
375375
{
376376
start = p;
377-
tok = getToken(&p, end);
377+
tok = php_firebird_get_token(&p, end);
378378
switch (tok)
379379
{
380380
case ttParamMark:
381-
tok = getToken(&p, end);
381+
tok = php_firebird_get_token(&p, end);
382382
if (tok == ttIdent /*|| tok == ttString*/)
383383
{
384384
++pindex;
@@ -460,7 +460,7 @@ int preprocess(const zend_string* sql, char* sql_out, HashTable* named_params)
460460
}
461461

462462
/* map driver specific error message to PDO error */
463-
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *state, const size_t state_len,
463+
void php_firebird_set_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *state, const size_t state_len,
464464
const char *msg, const size_t msg_len) /* {{{ */
465465
{
466466
pdo_error_type *const error_code = stmt ? &stmt->error_code : &dbh->error_code;
@@ -529,17 +529,17 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
529529
if (dbh->in_txn) {
530530
if (dbh->auto_commit) {
531531
if (isc_commit_transaction(H->isc_status, &H->tr)) {
532-
firebird_error(dbh);
532+
php_firebird_error(dbh);
533533
}
534534
} else {
535535
if (isc_rollback_transaction(H->isc_status, &H->tr)) {
536-
firebird_error(dbh);
536+
php_firebird_error(dbh);
537537
}
538538
}
539539
}
540540

541541
if (isc_detach_database(H->isc_status, &H->db)) {
542-
firebird_error(dbh);
542+
php_firebird_error(dbh);
543543
}
544544

545545
if (H->date_format) {
@@ -582,7 +582,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
582582
zend_hash_init(np, 8, NULL, NULL, 0);
583583

584584
/* allocate and prepare statement */
585-
if (!firebird_alloc_prepare_stmt(dbh, sql, &num_sqlda, &s, np)) {
585+
if (!php_firebird_alloc_prepare_stmt(dbh, sql, &num_sqlda, &s, np)) {
586586
break;
587587
}
588588

@@ -603,7 +603,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
603603

604604
/* fill the output sqlda with information about the prepared query */
605605
if (isc_dsql_describe(H->isc_status, &s, PDO_FB_SQLDA_VERSION, &S->out_sqlda)) {
606-
firebird_error(dbh);
606+
php_firebird_error(dbh);
607607
break;
608608
}
609609

@@ -630,7 +630,7 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
630630

631631
} while (0);
632632

633-
firebird_error(dbh);
633+
php_firebird_error(dbh);
634634

635635
zend_hash_destroy(np);
636636
FREE_HASHTABLE(np);
@@ -662,21 +662,21 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /*
662662
out_sqlda.sqln = 1;
663663

664664
/* allocate and prepare statement */
665-
if (!firebird_alloc_prepare_stmt(dbh, sql, &out_sqlda, &stmt, 0)) {
665+
if (!php_firebird_alloc_prepare_stmt(dbh, sql, &out_sqlda, &stmt, 0)) {
666666
return -1;
667667
}
668668

669669
/* execute the statement */
670670
if (isc_dsql_execute2(H->isc_status, &H->tr, &stmt, PDO_FB_SQLDA_VERSION, &in_sqlda, &out_sqlda)) {
671-
firebird_error(dbh);
671+
php_firebird_error(dbh);
672672
ret = -1;
673673
goto free_statement;
674674
}
675675

676676
/* find out how many rows were affected */
677677
if (isc_dsql_sql_info(H->isc_status, &stmt, sizeof(info_count), const_cast(info_count),
678678
sizeof(result), result)) {
679-
firebird_error(dbh);
679+
php_firebird_error(dbh);
680680
ret = -1;
681681
goto free_statement;
682682
}
@@ -704,13 +704,13 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /*
704704

705705
/* commit if we're in auto_commit mode */
706706
if (dbh->auto_commit && isc_commit_retaining(H->isc_status, &H->tr)) {
707-
firebird_error(dbh);
707+
php_firebird_error(dbh);
708708
}
709709

710710
free_statement:
711711

712712
if (isc_dsql_free_statement(H->isc_status, &stmt, DSQL_drop)) {
713-
firebird_error(dbh);
713+
php_firebird_error(dbh);
714714
}
715715

716716
return ret;
@@ -802,7 +802,7 @@ static bool firebird_handle_begin(pdo_dbh_t *dbh) /* {{{ */
802802
}
803803
#endif
804804
if (isc_start_transaction(H->isc_status, &H->tr, 1, &H->db, (unsigned short)(ptpb-tpb), tpb)) {
805-
firebird_error(dbh);
805+
php_firebird_error(dbh);
806806
return false;
807807
}
808808
return true;
@@ -815,7 +815,7 @@ static bool firebird_handle_commit(pdo_dbh_t *dbh) /* {{{ */
815815
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
816816

817817
if (isc_commit_transaction(H->isc_status, &H->tr)) {
818-
firebird_error(dbh);
818+
php_firebird_error(dbh);
819819
return false;
820820
}
821821
return true;
@@ -828,15 +828,15 @@ static bool firebird_handle_rollback(pdo_dbh_t *dbh) /* {{{ */
828828
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
829829

830830
if (isc_rollback_transaction(H->isc_status, &H->tr)) {
831-
firebird_error(dbh);
831+
php_firebird_error(dbh);
832832
return false;
833833
}
834834
return true;
835835
}
836836
/* }}} */
837837

838838
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
839-
static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
839+
static int php_firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
840840
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params)
841841
{
842842
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -860,23 +860,23 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
860860

861861
/* allocate the statement */
862862
if (isc_dsql_allocate_statement(H->isc_status, &H->db, s)) {
863-
firebird_error(dbh);
863+
php_firebird_error(dbh);
864864
return 0;
865865
}
866866

867867
/* in order to support named params, which Firebird itself doesn't,
868868
we need to replace :foo by ?, and store the name we just replaced */
869869
new_sql = emalloc(ZSTR_LEN(sql)+1);
870870
new_sql[0] = '\0';
871-
if (!preprocess(sql, new_sql, named_params)) {
871+
if (!php_firebird_preprocess(sql, new_sql, named_params)) {
872872
strcpy(dbh->error_code, "07000");
873873
efree(new_sql);
874874
return 0;
875875
}
876876

877877
/* prepare the statement */
878878
if (isc_dsql_prepare(H->isc_status, &H->tr, s, 0, new_sql, H->sql_dialect, out_sqlda)) {
879-
firebird_error(dbh);
879+
php_firebird_error(dbh);
880880
efree(new_sql);
881881
return 0;
882882
}
@@ -886,7 +886,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const zend_string *sql,
886886
}
887887

888888
/* called by PDO to set a driver-specific dbh attribute */
889-
static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /* {{{ */
889+
static bool pdo_firebird_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /* {{{ */
890890
{
891891
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
892892
bool bval;
@@ -905,7 +905,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
905905
/* turning on auto_commit with an open transaction is illegal, because
906906
we won't know what to do with it */
907907
const char *msg = "Cannot enable auto-commit while a transaction is already open";
908-
firebird_error_with_info(dbh, "HY000", strlen("HY000"), msg, strlen(msg));
908+
php_firebird_error_with_info(dbh, "HY000", strlen("HY000"), msg, strlen(msg));
909909
return false;
910910
} else {
911911
/* close the transaction */
@@ -976,7 +976,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
976976
#define INFO_BUF_LEN 512
977977

978978
/* callback to used to report database server info */
979-
static void firebird_info_cb(void *arg, char const *s) /* {{{ */
979+
static void php_firebird_info_cb(void *arg, char const *s) /* {{{ */
980980
{
981981
if (arg) {
982982
if (*(char*)arg) { /* second call */
@@ -988,7 +988,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
988988
/* }}} */
989989

990990
/* called by PDO to get a driver-specific dbh attribute */
991-
static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /* {{{ */
991+
static int pdo_firebird_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) /* {{{ */
992992
{
993993
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
994994

@@ -1000,7 +1000,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *v
10001000
return 1;
10011001

10021002
case PDO_ATTR_CONNECTION_STATUS:
1003-
ZVAL_BOOL(val, !isc_version(&H->db, firebird_info_cb, NULL));
1003+
ZVAL_BOOL(val, !isc_version(&H->db, php_firebird_info_cb, NULL));
10041004
return 1;
10051005

10061006
case PDO_ATTR_CLIENT_VERSION: {
@@ -1030,7 +1030,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *v
10301030
case PDO_ATTR_SERVER_INFO:
10311031
*tmp = 0;
10321032

1033-
if (!isc_version(&H->db, firebird_info_cb, (void*)tmp)) {
1033+
if (!isc_version(&H->db, php_firebird_info_cb, (void*)tmp)) {
10341034
ZVAL_STRING(val, tmp);
10351035
return 1;
10361036
}
@@ -1066,10 +1066,10 @@ static const struct pdo_dbh_methods firebird_methods = { /* {{{ */
10661066
firebird_handle_begin,
10671067
firebird_handle_commit,
10681068
firebird_handle_rollback,
1069-
firebird_handle_set_attribute,
1069+
pdo_firebird_set_attribute,
10701070
NULL, /* last_id not supported */
10711071
pdo_firebird_fetch_error_func,
1072-
firebird_handle_get_attribute,
1072+
pdo_firebird_get_attribute,
10731073
NULL, /* check_liveness */
10741074
NULL, /* get driver methods */
10751075
NULL, /* request shutdown */

0 commit comments

Comments
 (0)