[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] cvs: php4 /ext/mssql php_mssql.c php_mssql.h
From: "Frank M. Kromann" <frank () frontbase ! com>
Date: 2001-06-28 16:59:17
[Download RAW message or body]
fmk Thu Jun 28 12:59:17 2001 EDT
Modified files:
/php4/ext/mssql php_mssql.h php_mssql.c
Log:
Adding new function to convert from binary to GUID format
Index: php4/ext/mssql/php_mssql.h
diff -u php4/ext/mssql/php_mssql.h:1.13 php4/ext/mssql/php_mssql.h:1.14
--- php4/ext/mssql/php_mssql.h:1.13 Tue Jun 5 17:09:50 2001
+++ php4/ext/mssql/php_mssql.h Thu Jun 28 12:59:16 2001
@@ -12,12 +12,12 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Frank M. Kromann frank@frontbase.com> |
+ | Authors: Frank M. Kromann <frank@frontbase.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_mssql.h,v 1.13 2001/06/05 21:09:50 fmk Exp $ */
+/* $Id: php_mssql.h,v 1.14 2001/06/28 16:59:16 fmk Exp $ */
#ifndef PHP_MSSQL_H
#define PHP_MSSQL_H
@@ -83,6 +83,7 @@
PHP_FUNCTION(mssql_init);
PHP_FUNCTION(mssql_bind);
PHP_FUNCTION(mssql_execute);
+PHP_FUNCTION(mssql_guid_string);
typedef struct mssql_link {
LOGINREC *login;
Index: php4/ext/mssql/php_mssql.c
diff -u php4/ext/mssql/php_mssql.c:1.50 php4/ext/mssql/php_mssql.c:1.51
--- php4/ext/mssql/php_mssql.c:1.50 Tue Jun 19 12:03:33 2001
+++ php4/ext/mssql/php_mssql.c Thu Jun 28 12:59:17 2001
@@ -12,11 +12,11 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Frank M. Kromann frank@frontbase.com> |
+ | Authors: Frank M. Kromann <frank@frontbase.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_mssql.c,v 1.50 2001/06/19 16:03:33 andi Exp $ */
+/* $Id: php_mssql.c,v 1.51 2001/06/28 16:59:17 fmk Exp $ */
#ifdef COMPILE_DL_MSSQL
#define HAVE_MSSQL 1
@@ -76,6 +76,7 @@
PHP_FE(mssql_init, NULL)
PHP_FE(mssql_bind, a3_arg_force_ref)
PHP_FE(mssql_execute, NULL)
+ PHP_FE(mssql_guid_string, NULL)
{NULL, NULL, NULL}
};
@@ -775,7 +776,7 @@
result->value.lval = (long) anyintcol(offset);
result->type = IS_LONG;
break;
- }
+ }
case SQLCHAR:
case SQLVARCHAR:
case SQLTEXT: {
@@ -2121,6 +2122,75 @@
}
else {
ZEND_REGISTER_RESOURCE(return_value, result, le_result);
+ }
+}
+/* }}} */
+
+/* {{{ proto string mssql_guid_string(string binary [,int short_format])
+ Converts a 16 byte binary GUID to a string */
+PHP_FUNCTION(mssql_guid_string)
+{
+ zval **binary, **short_format;
+ int sf = 0;
+ char buffer[32+1];
+ char buffer2[36+1];
+ MSSQLLS_FETCH();
+
+ switch(ZEND_NUM_ARGS()) {
+ case 1:
+ if (zend_get_parameters_ex(1, &binary)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(binary);
+ break;
+ case 2:
+ if (zend_get_parameters_ex(2, &binary, &short_format)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(binary);
+ convert_to_long_ex(short_format);
+ sf = (*short_format)->value.lval;
+ break;
+
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ dbconvert(NULL, SQLBINARY, (BYTE*)(*binary)->value.str.val, 16, SQLCHAR, buffer, -1);
+
+ if (sf) {
+ php_strtoupper(buffer, 32);
+ RETURN_STRING(buffer, 1);
+ }
+ else {
+ int i;
+ for (i=0; i<4; i++) {
+ buffer2[2*i] = buffer[6-2*i];
+ buffer2[2*i+1] = buffer[7-2*i];
+ }
+ buffer2[8] = '-';
+ for (i=0; i<2; i++) {
+ buffer2[9+2*i] = buffer[10-2*i];
+ buffer2[10+2*i] = buffer[11-2*i];
+ }
+ buffer2[13] = '-';
+ for (i=0; i<2; i++) {
+ buffer2[14+2*i] = buffer[14-2*i];
+ buffer2[15+2*i] = buffer[15-2*i];
+ }
+ buffer2[18] = '-';
+ for (i=0; i<4; i++) {
+ buffer2[19+i] = buffer[16+i];
+ }
+ buffer2[23] = '-';
+ for (i=0; i<12; i++) {
+ buffer2[24+i] = buffer[20+i];
+ }
+ buffer2[36] = 0;
+
+ php_strtoupper(buffer2, 36);
+ RETURN_STRING(buffer2, 1);
}
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net
For additional commands, e-mail: php-cvs-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic