Skip to Content.
Sympa Menu

freetds - Re: [PHP-DEV] Patch: conflicting defines in PHP extensions should be made private

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Andi Gutmans <andi AT zend.com>
  • To: Steve Langasek <vorlon AT netexpress.net>,<php-dev AT lists.php.net>, TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: [PHP-DEV] Patch: conflicting defines in PHP extensions should be made private
  • Date: Tue, 04 Sep 2001 07:06:39 +0300


Steve,

I commited your patch. Please check out the latest CVS and test that it's OK. I can't check it.

Andi

At 06:52 PM 9/3/2001 -0500, Steve Langasek wrote:
Hello,

It's come to my attention that it's not possible to the Sybase extension and
the IBM DB2 extension into PHP at the same time because they have conflicting
declarations of `RETCODE'.

Both of these extensions are built on top of legacy, proprietary APIs which
it's not possible to change, so the respective RETCODE declarations must be
respected. However, there's no technical reason two extensions should *ever*
conflict unless the corresponding libraries use identical symbol names.

The below patch cleans up ext/sybase so that the namespace in
main/internal_functions.c isn't cluttered by header files internal to this
extension. With this change, it should be possible to statically include both
the IBM DB2 and Sybase extensions in a single PHP build.

Regards,
Steve Langasek
postmodern programmer


Index: ext/sybase/php_sybase_db.c
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v
retrieving revision 1.28
diff -u -w -r1.28 php_sybase_db.c
--- ext/sybase/php_sybase_db.c 11 Aug 2001 12:02:15 -0000 1.28
+++ ext/sybase/php_sybase_db.c 4 Sep 2001 03:02:49 -0000
@@ -43,6 +43,43 @@
#include "http_log.h"
#endif

+/* Move these structures/defines into the .c file (or into a *private* header),
+ because leaving them in php_sybase_db.h causes namespace pollution in
+ main/internal_functions.c. */
+
+#define coltype(j) dbcoltype(sybase_ptr->link,j)
+#define intcol(i) ((int) *(DBINT *) dbdata(sybase_ptr->link,i))
+#define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(sybase_ptr->link,i))
+#define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(sybase_ptr->link,i))
+#define anyintcol(j) (coltype(j)==SYBINT4?intcol(j):(coltype(j)==SYBINT2?smallintcol(j):tinyintcol(j)))
+#define charcol(i) ((DBCHAR *) dbdata(sybase_ptr->link,i))
+#define floatcol(i) ((float) *(DBFLT8 *) dbdata(sybase_ptr->link,i))
+
+typedef struct sybase_link_struct sybase_link;
+
+struct sybase_link_struct {
+ LOGINREC *login;
+ DBPROCESS *link;
+ int valid;
+};
+
+#define SYBASE_ROWS_BLOCK 128
+
+typedef struct {
+ char *name,*column_source;
+ int max_length, numeric;
+ int type;
+} sybase_field;
+
+typedef struct {
+ pval ***data;
+ sybase_field *fields;
+ sybase_link *sybase_ptr;
+ int cur_row,cur_field;
+ int num_rows,num_fields;
+} sybase_result;
+
+
function_entry sybase_functions[] = {
PHP_FE(sybase_connect, NULL)
PHP_FE(sybase_pconnect, NULL)
Index: ext/sybase/php_sybase_db.h
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.h,v
retrieving revision 1.5
diff -u -w -r1.5 php_sybase_db.h
--- ext/sybase/php_sybase_db.h 16 Mar 2001 01:21:31 -0000 1.5
+++ ext/sybase/php_sybase_db.h 4 Sep 2001 03:02:49 -0000
@@ -63,21 +63,6 @@
PHP_FUNCTION(sybase_field_flags);


-
-#include <sybfront.h>
-#include <sybdb.h>
-#include <syberror.h>
-
-#define coltype(j) dbcoltype(sybase_ptr->link,j)
-#define intcol(i) ((int) *(DBINT *) dbdata(sybase_ptr->link,i))
-#define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(sybase_ptr->link,i))
-#define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(sybase_ptr->link,i))
-#define anyintcol(j) (coltype(j)==SYBINT4?intcol(j):(coltype(j)==SYBINT2?smallintcol(j):tinyintcol(j)))
-#define charcol(i) ((DBCHAR *) dbdata(sybase_ptr->link,i))
-#define floatcol(i) ((float) *(DBFLT8 *) dbdata(sybase_ptr->link,i))
-
-typedef struct sybase_link_struct sybase_link;
-
typedef struct {
long default_link;
long num_links,num_persistent;
@@ -90,29 +75,6 @@
long cfg_min_error_severity,cfg_min_message_severity;
long compatability_mode;
} sybase_module;
-
-struct sybase_link_struct {
- LOGINREC *login;
- DBPROCESS *link;
- int valid;
-};
-
-#define SYBASE_ROWS_BLOCK 128
-
-typedef struct {
- char *name,*column_source;
- int max_length, numeric;
- int type;
-} sybase_field;
-
-typedef struct {
- pval ***data;
- sybase_field *fields;
- sybase_link *sybase_ptr;
- int cur_row,cur_field;
- int num_rows,num_fields;
-} sybase_result;
-

extern sybase_module php_sybase_module;



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe AT lists.php.net
For additional commands, e-mail: php-dev-help AT lists.php.net
To contact the list administrators, e-mail: php-list-admin AT lists.php.net





Archive powered by MHonArc 2.6.24.

Top of Page