Date: 10/28/98
- Next message: eschmid: "[PHP-DEV] CVS update: php3/doc/functions"
- Previous message: shane: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: shane: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wednesday October 28, 1998 @ 10:10
Author: nyenyon
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv19995
Modified Files:
ifx.ec php3_ifx.h
Log Message:
- add ifx_create_char/ifx_free_char/ifx_update_char/ifx_get_char for handling char-fields bigger than 255 bytes.
- it have to be handled like the blob-support (id...)
Index: php3/functions/ifx.ec
diff -c php3/functions/ifx.ec:1.31 php3/functions/ifx.ec:1.32
*** php3/functions/ifx.ec:1.31 Sun Oct 25 09:07:45 1998
--- php3/functions/ifx.ec Wed Oct 28 10:10:45 1998
***************
*** 130,135 ****
--- 130,136 ----
#define TYPE_BLBYTE 0
#define TYPE_BLTEXT 1
#define TYPE_SLOB 2
+ #define TYPE_CHAR 3
#define BLMODE_INMEM 0
***************
*** 179,184 ****
--- 180,190 ----
{"ifx_nullformat" ,php3_ifx_nullformat, NULL},
{"ifx_blobinfile_mode",php3_ifx_blobinfile_mode, NULL},
+ {"ifx_create_char", php3_ifx_create_char, NULL},
+ {"ifx_free_char", php3_ifx_free_char, NULL},
+ {"ifx_get_char", php3_ifx_get_char, NULL},
+ {"ifx_update_char", php3_ifx_update_char, NULL},
+
$ifdef HAVE_IFX_IUS;
{"ifxus_create_slob", php3_ifxus_create_slob, NULL},
{"ifxus_close_slob", php3_ifxus_close_slob, NULL},
***************
*** 915,923 ****
int i; /* field index */
short fieldtype;
loc_t *locator;
! int loc_t_type=CLOCATORTYPE; /* WORKAROUND:TYPE=CLOCATORTYPE doesn't work,
! don't ask me, why. */
!
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
$endif;
--- 921,931 ----
int i; /* field index */
short fieldtype;
loc_t *locator;
! int loc_t_type=CLOCATORTYPE; /* WORKAROUND:TYPE=CLOCATORTYPE doesn't work, */
! int sqlchar_type=SQLCHAR; /* don't ask me, why. */
! char *char_tmp;
! long len;
! int indicator;
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
$endif;
***************
*** 1083,1088 ****
--- 1091,1112 ----
DATA= :*locator,
TYPE= :loc_t_type;
}
+
+ /* CHAR */
+ if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_CHAR) {
+ len=php3_intifx_get_char((int)tmp->value.lval,list,&char_tmp);
+ indicator=0;
+ if(char_tmp==NULL || len<0)
+ indicator=-1;
+ len++;
+ EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
+ DATA= :char_tmp,
+ LENGTH= :len,
+ INDICATOR= :indicator,
+ TYPE= :sqlchar_type;
+ }
+
+
i++;
_php3_hash_move_forward(pblobidarr->value.ht);
}
***************
*** 1270,1277 ****
int i; /* field index */
short fieldtype;
loc_t *locator;
! int loc_t_type=CLOCATORTYPE; /* WORKAROUND: TYPE=CLOCATORTYPE doesn't work,
! don't ask me, why. */
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
--- 1294,1304 ----
int i; /* field index */
short fieldtype;
loc_t *locator;
! int loc_t_type=CLOCATORTYPE; /* WORKAROUND: TYPE=CLOCATORTYPE doesn't work, */
! int sqlchar_type=SQLCHAR; /* don't ask me, why. */
! char *char_tmp;
! long len;
! int indicator;
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
***************
*** 1441,1446 ****
--- 1468,1487 ----
DATA= :*locator,
TYPE=:loc_t_type;
}
+ /* CHAR */
+ if(php3_intifx_getType((int)tmp->value.lval,list)==TYPE_CHAR) {
+ len=php3_intifx_get_char((int)tmp->value.lval,list,&char_tmp);
+ indicator=0;
+ if(char_tmp==NULL || len<0)
+ indicator=-1;
+ len++;
+ EXEC SQL SET DESCRIPTOR :descrpid VALUE :i
+ DATA= :char_tmp,
+ LENGTH= :len,
+ INDICATOR= :indicator,
+ TYPE= :sqlchar_type;
+ }
+
i++;
_php3_hash_move_forward(pblobidarr->value.ht);
} /* while */
***************
*** 2114,2121 ****
ifx_var_dealloc(&lvar_tmp);
add_assoc_stringl(return_value, fieldname, char_data, fieldleng,0);
break;
-
-
case SQLBOOL:
$endif;
case SQLVCHAR :
--- 2155,2160 ----
***************
*** 3785,3790 ****
--- 3824,4125 ----
}
return tmp;
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /* ----------------------------------------------------------------------
+ ** int php3_ifx_create_char(string param)
+ **
+ ** creates an char-object
+ ** param: content
+ ** return false on error otherwise the new char-Object-id
+ ** ----------------------------------------------------------------------
+ */
+ void php3_ifx_create_char(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *pparam;
+ long id;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pparam)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string(pparam);
+
+ id=php3_intifx_create_char(pparam->value.str.val,pparam->value.str.len,list);
+ if(id<0) {
+ RETURN_FALSE;
+ }
+ RETURN_LONG(id);
+ }
+
+ /* ----------------------------------------------------------------------
+ * internal function
+ * long php3_intifx_create_char(char* param, long len, HashTable *list)
+ *
+ * creates an char-object
+ * param: content
+ * len: length of param
+ * list: internal hashlist of php3
+ * return -1 on error otherwise the new char-Object-id
+ * ----------------------------------------------------------------------
+ */
+ long php3_intifx_create_char(char* param, long len, HashTable *list) {
+ IFX_IDRES *Ifx_char;
+
+
+ Ifx_char=emalloc(sizeof(IFX_IDRES));
+ if(Ifx_char==NULL) {
+ php3_error(E_WARNING,"can't create char-resource");
+ return -1;
+ }
+
+ Ifx_char->type=TYPE_CHAR;
+
+ if(param==NULL || len<0) {
+ Ifx_char->CHAR.char_data=NULL;
+ Ifx_char->CHAR.len=0;
+ } else {
+ Ifx_char->CHAR.char_data=emalloc(len+1);
+ if(Ifx_char->CHAR.char_data==NULL) {
+ efree(Ifx_char);
+ php3_error(E_WARNING,"can't create char-resource");
+ return -1;
+ }
+ memcpy(Ifx_char->CHAR.char_data,param,len);
+ Ifx_char->CHAR.char_data[len]=0;
+ Ifx_char->CHAR.len=len;
+ }
+ return php3_list_insert(Ifx_char,Informix_GLOBAL(php3_ifx_module).le_idresult);
+ }
+
+ /* ----------------------------------------------------------------------
+ ** string php3_ifx_get_char(int bid)
+ **
+ ** returns the content of the char-object
+ ** bid: Id of charobject
+ ** return the content
+ ** ----------------------------------------------------------------------
+ */
+ void php3_ifx_get_char(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *pbid;
+ char *content;
+ long len;
+
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(pbid);
+
+ len=php3_intifx_get_char(pbid->value.lval,list,&content);
+ if(content==NULL || len<0) {
+ RETURN_STRING("",1);
+ }
+ RETURN_STRINGL(content,len,1);
+ }
+
+
+ /* ----------------------------------------------------------------------
+ * internal function
+ * long php3_intifx_get_char(long bid, HashTable *list, char** content)
+ *
+ * returns the content of the char-object
+ * bid: Id of charobject
+ * list: internal hashlist of php3
+ *
+ * return -1 on error
+ * returns the pointer to the content in char** content and the amount of content in bytes
+ * ----------------------------------------------------------------------
+ */
+ long php3_intifx_get_char(long bid, HashTable *list, char** content) {
+ IFX_IDRES *Ifx_char;
+ int type;
+
+ Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
+ if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
+ php3_error(E_WARNING,"%d is not a Informix char-result index",
+ bid);
+ return -1;
+ }
+
+ *content=Ifx_char->CHAR.char_data;
+ return Ifx_char->CHAR.len;
+ }
+
+ /* ----------------------------------------------------------------------
+ ** int php3_ifx_free_char(int bid)
+ **
+ ** deletes the char-object
+ ** bid: Id of charobject
+ ** return false on error otherwise true
+ ** ----------------------------------------------------------------------
+ */
+ void php3_ifx_free_char(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *pid;
+ long ret;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &pid)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(pid);
+
+ ret=php3_intifx_free_char(pid->value.lval,list);
+ if(ret<0) {
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ }
+
+ /* ----------------------------------------------------------------------
+ * internal function
+ * long php3_intifx_free_char(long bid, HashTable *list)
+ *
+ * deletes the char-object
+ * bid: Id of Charobject
+ * list: internal hashlist of php3
+ *
+ * return -1 on error otherwise 0
+ * ----------------------------------------------------------------------
+ */
+ long php3_intifx_free_char(long bid, HashTable *list) {
+ IFX_IDRES *Ifx_char;
+ int type;
+
+ Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
+ if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
+ php3_error(E_WARNING,"%d is not a Informix char-result index",
+ bid);
+ return -1;
+ }
+
+ if(Ifx_char->CHAR.char_data!=NULL) {
+ efree(Ifx_char->CHAR.char_data);
+ }
+
+ php3_list_delete(bid);
+ efree(Ifx_char);
+ return 0;
+ }
+
+ /* ----------------------------------------------------------------------
+ ** int php3_ifx_update_char(int bid, string content)
+ **
+ ** updates the content of the char-object
+ ** bid: Id of charobject
+ ** content: string of new data
+ ** return false on error otherwise true
+ ** ----------------------------------------------------------------------
+ */
+
+ void php3_ifx_update_char(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *pbid,*pparam;
+ long ret;
+
+
+ if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &pbid,&pparam)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(pbid);
+ convert_to_string(pparam);
+
+ ret=php3_intifx_update_char(pbid->value.lval,
+ pparam->value.str.val,
+ pparam->value.str.len,
+ list);
+ if(ret<0) {
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ }
+
+
+ /* ----------------------------------------------------------------------
+ * internal function
+ * long php3_intifx_update_char(long bid, char* param, long len, HashTable *list)
+ *
+ * updates the content of the char-object
+ * bid: Id of charobject
+ * param: string of new data
+ * len: length of string
+ * list: internal hashlist of php3
+ * return nothing
+ * ----------------------------------------------------------------------
+ */
+ long php3_intifx_update_char(long bid, char* param, long len, HashTable *list) {
+ IFX_IDRES *Ifx_char;
+ int type;
+
+ Ifx_char = (IFX_IDRES *) php3_list_find(bid,&type);
+ if (type!=Informix_GLOBAL(php3_ifx_module).le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
+ php3_error(E_WARNING,"%d is not a Informix char-result index",
+ bid);
+ return -1;
+ }
+
+ if(Ifx_char->CHAR.char_data!=NULL) {
+ efree(Ifx_char->CHAR.char_data);
+ }
+ Ifx_char->CHAR.char_data=NULL;
+ Ifx_char->CHAR.len=0;
+
+ if(param==NULL || len<0) {
+ Ifx_char->CHAR.char_data=NULL;
+ Ifx_char->CHAR.len=0;
+ } else {
+ Ifx_char->CHAR.char_data=emalloc(len+1);
+ if(Ifx_char->CHAR.char_data==NULL) {
+ php3_error(E_WARNING,"can't create char-resource");
+ return -1;
+ }
+ memcpy(Ifx_char->CHAR.char_data,param,len);
+ Ifx_char->CHAR.char_data[len]=0;
+ Ifx_char->CHAR.len=len;
+ }
+ return 0;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: php3/functions/php3_ifx.h
diff -c php3/functions/php3_ifx.h:1.13 php3/functions/php3_ifx.h:1.14
*** php3/functions/php3_ifx.h:1.13 Sat Oct 24 15:02:06 1998
--- php3/functions/php3_ifx.h Wed Oct 28 10:10:46 1998
***************
*** 49,54 ****
--- 49,55 ----
#include "locator.h"
#include "sqltypes.h"
+
extern php3_module_entry ifx_module_entry;
#define ifx_module_ptr &ifx_module_entry
***************
*** 93,98 ****
--- 94,109 ----
extern void php3_ifx_nullformat(INTERNAL_FUNCTION_PARAMETERS);
char* php3_intifx_null();
+ extern void php3_ifx_create_char(INTERNAL_FUNCTION_PARAMETERS);
+ long php3_intifx_create_char(char* param, long len, HashTable *list);
+ extern void php3_ifx_free_char(INTERNAL_FUNCTION_PARAMETERS) ;
+ long php3_intifx_free_char(long id, HashTable *list);
+ extern void php3_ifx_update_char(INTERNAL_FUNCTION_PARAMETERS);
+ long php3_intifx_update_char(long bid, char* param, long len, HashTable *list);
+ extern void php3_ifx_get_char(INTERNAL_FUNCTION_PARAMETERS);
+ long php3_intifx_get_char(long bid, HashTable *list, char** content);
+
+
#if HAVE_IFX_IUS
extern void php3_ifxus_create_slob(INTERNAL_FUNCTION_PARAMETERS);
long php3_intifxus_create_slob(long create_mode, HashTable *list);
***************
*** 156,161 ****
--- 167,176 ----
int mode;
loc_t blob_data;
} BLOBRES;
+ struct {
+ char *char_data;
+ int len;
+ } CHARRES;
#if HAVE_IFX_IUS
struct {
ifx_lo_t slob_data;
***************
*** 169,174 ****
--- 184,190 ----
#define BLOB DATARES.BLOBRES
+ #define CHAR DATARES.CHARRES
#if HAVE_IFX_IUS
#define SLOB DATARES.SLOBRES
-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: eschmid: "[PHP-DEV] CVS update: php3/doc/functions"
- Previous message: shane: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: shane: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

