LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File yada-64bit-fix.diff of Package yada (Project home:crt0solutions:extras)

diff --git a/src/_yada.h b/src/_yada.h
index b33c507..e32d04e 100644
--- a/src/_yada.h
+++ b/src/_yada.h
@@ -59,7 +59,7 @@
  */
 
 #ifdef DEBUGMODE
-#  define DEBUGMSG(m...) { fprintf(stderr, m); fprintf(stderr, "\n"); }
+#  define DEBUGMSG(m...) { fprintf(stdout, m); fprintf(stdout, "\n"); }
 #  ifdef DEBUGCOLOR
 #    define DBG_RED(a) "\033[01;31m" a "\033[00m"
 #    define DBG_GREEN(a) "\033[01;32m" a "\033[00m"
@@ -108,7 +108,7 @@ struct yada_rc_t
 {
   char magic;
   unsigned int t;
-  unsigned int len;
+  size_t len;
   void *data;
   yada_rc_t *prev, *next;
 };
@@ -123,19 +123,19 @@ struct yada_rc_t
   /** pointer to the static string */
   char *buf;
   /** len of static string */
-  int len;
+  size_t len;
 } prep_ele_t;
 
 typedef struct
 {
   /** number of elements allocated */
-  int sz;
+  size_t sz;
   /** number of elements used */
-  int eles;
+  size_t eles;
   /** total length of all static strings */
-  int len;
+  size_t len;
   /** number of arguments */
-  int args;
+  size_t args;
   /** element array */
   prep_ele_t ele[1];
 } yada_prep_t;
@@ -157,7 +157,7 @@ struct yada_rc_t
   union
     {
     int i;
-    long long l;
+    int64_t l;
     unsigned char *buf;
     double f;
     } var;
@@ -166,9 +166,9 @@ struct yada_rc_t
 typedef struct
 {
   /** number of elements allocated */
-  int sz;
+  size_t sz;
   /** number of elements used */
-  int eles;
+  size_t eles;
   /** element array */
   bindset_ele_t ele[1];
 } yada_bindset_t;
@@ -182,16 +182,16 @@ struct yada_rc_t
 struct yada_priv_t
 {
   void (*destroy)(yada_t *);
-  int (*exec)(yada_t *, char *, int);
-  yada_rc_t* (*query)(yada_t *, char *, int);
+  int (*exec)(yada_t *, char *, size_t);
+  yada_rc_t* (*query)(yada_t *, char *, size_t);
   unsigned int flags;
   lt_dlhandle dlh;
   yada_rc_t *rc_head;
   yada_rc_t *rc_tail;
   yada_rc_free_t free_rc[10];
   char errbuf[1024];
-  int (*execprep)(yada_t *, void *, int *, va_list);
-  yada_rc_t* (*queryprep)(yada_t *, void *, int *, va_list);
+  int (*execprep)(yada_t *, void *, size_t *, va_list);
+  yada_rc_t* (*queryprep)(yada_t *, void *, size_t *, va_list);
 };
 
 /******************************************************************************
diff --git a/src/common.c b/src/common.c
index a90ad31..112cddf 100644
--- a/src/common.c
+++ b/src/common.c
@@ -102,11 +102,12 @@
  *  outputs null terminated strings
  */
 
-char *_yada_escstr(char *src, int slen, char *dest, int *dlen)
+char *_yada_escstr(char *src, size_t slen, char *dest, size_t *dlen)
 {
-  int i, len;
+  size_t i, len;
   char *destp;
 
+  printf("====> _yada_escstr\n");
 
   if(!slen)
     slen = strlen(src);
diff --git a/src/common.h b/src/common.h
index e9d9ca7..d9f61dc 100644
--- a/src/common.h
+++ b/src/common.h
@@ -51,9 +51,9 @@
  * P R O T O T Y P E S ********************************************************
  ******************************************************************************/
 
-char *_yada_escstr(char *, int, char *, int *);
+char *_yada_escstr(char *, size_t, char *, size_t *);
 
-yada_rc_t* _yada_prepare(yada_t *, char *, int);
+yada_rc_t* _yada_prepare(yada_t *, char *, size_t);
 yada_rc_t* _yada_preparef(yada_t *, char *, ...);
 yada_rc_t* _yada_npreparef(yada_t *, char *, ...);
 yada_rc_t* _yada_xprepare(yada_t *, int, char *, ...);
@@ -66,7 +66,7 @@
 yada_rc_t* _yada_query(yada_t *, void *, ...);
 yada_rc_t* _yada_xquery(yada_t *, int, void *, ...);
 
-char* _yada_dumpexec(yada_t *, int *, yada_rc_t *, ...);
+char* _yada_dumpexec(yada_t *, size_t *, yada_rc_t *, ...);
 void _yada_free_stmt(yada_t *, yada_rc_t *);
 
 yada_rc_t* _yada_vbind(yada_t *, char *, va_list);
@@ -74,7 +74,7 @@
 
 void yada_free_bindset(yada_t *, yada_rc_t *);
 
-char* _yada_parse_exec(yada_t *_yada, yada_prep_t *_ypr, int *rlen, va_list ap);
+char* _yada_parse_exec(yada_t *_yada, yada_prep_t *_ypr, size_t *rlen, va_list ap);
 
 /******************************************************************************/
 
diff --git a/src/prepexec.c b/src/prepexec.c
index 9384632..81836a3 100644
--- a/src/prepexec.c
+++ b/src/prepexec.c
@@ -114,7 +114,7 @@
 
 yada_prep_t* _prep_ele_grow(yada_prep_t *yprep)
 {
-  int sz = yprep->sz + PREP_ELE_CHUNK_SZ;
+  size_t sz = yprep->sz + PREP_ELE_CHUNK_SZ;
   yada_prep_t *tmp_ptr;
 
 
@@ -156,10 +156,10 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
  * shouldn't be called directly
  */
 
-static inline char* _fmtdup(yada_t* _yada, int *rlen, const char *fmt,
+static inline char* _fmtdup(yada_t* _yada, size_t *rlen, const char *fmt,
  va_list ap)
 {
-  int len;
+  size_t len;
   char *str;
 
 
@@ -273,7 +273,7 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
  */
 
 static inline yada_rc_t* _yada_len_prepare(yada_t *_yada, char *sqlstr,
-                                           int sqlstr_len)
+                                           size_t sqlstr_len)
 {
   char *buf, *bufp;
   yada_prep_t *yprep;
@@ -352,7 +352,7 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
 /** yada compat function to prepare an sql statement
  */
 
-yada_rc_t* _yada_prepare(yada_t *_yada, char *sqlstr, int sqlstr_len)
+yada_rc_t* _yada_prepare(yada_t *_yada, char *sqlstr, size_t sqlstr_len)
 {
   if(sqlstr_len)
     return(_yada_len_prepare(_yada, sqlstr, sqlstr_len));
@@ -366,12 +366,11 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
 
 yada_rc_t* _yada_preparef(yada_t *_yada, char *fmt, ...)
 {
-  int len;
+  size_t len;
   char *sqlstr;
   va_list ap;
   yada_rc_t *_yrc;
 
-
   va_start(ap, fmt);
   sqlstr = _fmtdup(_yada, &len, fmt, ap);
   va_end(ap);
@@ -390,7 +389,7 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
 
 yada_rc_t* _yada_npreparef(yada_t *_yada, char *fmt, ...)
 {
-  int len;
+  size_t len;
   char *sqlstr;
   va_list ap;
   yada_rc_t *_yrc;
@@ -414,12 +413,11 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
 
 yada_rc_t* _yada_xprepare(yada_t *_yada, int flags, char *fmt, ...)
 { 
-  int len;
+  size_t len;
   char *sqlstr;
   va_list ap;
   yada_rc_t *_yrc;
 
-
   va_start(ap, fmt);
 
   if(flags & YADA_FORMAT)
@@ -449,7 +447,7 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
  *  @return 0 on error, frees buf
  */
 
-static inline char* _yada_grow_buf(char *buf, int *sz, int len)
+static inline char* _yada_grow_buf(char *buf, size_t *sz, size_t len)
 {
   char *tmp_ptr;
 
@@ -472,8 +470,8 @@ void _yada_free_stmt(yada_t *_yada, yada_rc_t *_yrc)
  * should not be called directly
  */
 
-static inline int _yada_ins_esc(yada_t *_yada, char **qstr, int *sz, int *len,
-                                char *arg, int arglen)
+static inline int _yada_ins_esc(yada_t *_yada, char **qstr, size_t *sz, size_t *len,
+                                char *arg, size_t arglen)
 {
   int dlen = (arglen <<1) + 1;
 
@@ -497,10 +495,10 @@ static inline int _yada_ins_esc(yada_t *_yada, char **qstr, int *sz, int *len,
  * should not be called directly
  */
 
-static inline int _yada_ins_var(yada_t *_yada, char **qstr, int *sz, int *len,
-                                char *arg, int arglen)
+static inline int _yada_ins_var(yada_t *_yada, char **qstr, size_t *sz, size_t *len,
+                                char *arg, size_t arglen)
 {
-  int dlen = (arglen <<1) + 3;
+  size_t dlen = (arglen <<1) + 3;
   char *str;
 
 
@@ -526,8 +524,8 @@ static inline int _yada_ins_var(yada_t *_yada, char **qstr, int *sz, int *len,
  *  should not be called directly
  */
 
-static inline int _yada_ins_double(yada_t *_yada, char **qstr, int *sz,
- int *len, double arg)
+static inline int _yada_ins_double(yada_t *_yada, char **qstr, size_t *sz,
+ size_t *len, double arg)
 {
   int dlen, alen;
 
@@ -549,10 +547,9 @@ static inline int _yada_ins_double(yada_t *_yada, char **qstr, int *sz,
 /******************************************************************************/
 
 inline char* _yada_parse_exec(yada_t *_yada, yada_prep_t *_ypr,
-                                     int *rlen, va_list ap)
+                                     size_t *rlen, va_list ap)
 {
-  int len = 0;
-  int i, arglen, nlen, sz;
+  size_t len = 0, i, arglen, nlen, sz;
   char *qstr, *bufp, *arg;
   prep_ele_t *elep, *elelen;
 
@@ -561,7 +558,7 @@ static inline int _yada_ins_double(yada_t *_yada, char **qstr, int *sz,
   elelen = elep + _ypr->eles;
   sz = _ypr->len << 1;
 
-  if(!(qstr = malloc(sz)))
+  if(!(qstr = calloc(1, sz)))
     {
     _yada_set_yadaerr(_yada, YADA_ENOMEM);
     return(0);
@@ -652,11 +649,11 @@ static inline int _yada_ins_double(yada_t *_yada, char **qstr, int *sz,
     case 'l':
       {
       int next;
-      long long l;
+      int64_t l;
       char dest[STRLEN_INT64];
       char *destp, *endp;
 
-      l = va_arg(ap, long long);
+      l = va_arg(ap, int64_t);
 
       /* always have at least 1 spare byte, no need to check overflow */
       if(l < 0)
@@ -736,11 +733,11 @@ static inline int _yada_ins_double(yada_t *_yada, char **qstr, int *sz,
 
 int _yada_vexecute(yada_t *_yada, void *magic, va_list ap)
 {
-  int len, rv;
+  size_t len;
+  int rv;
   char *qstr;
   yada_rc_t *rc;
-
-
+  
   /* check for string */
   if(((yada_rc_t *)magic)->magic)
     {
@@ -780,10 +777,9 @@ int _yada_vexecute(yada_t *_yada, void *magic, va_list ap)
 
 int _yada_execute(yada_t *_yada, void *magic, ...)
 {
-  int rv;
+  size_t rv;
   va_list ap;
 
-
   va_start(ap, magic);
   rv = _yada_vexecute(_yada, magic, ap);
   va_end(ap);
@@ -797,11 +793,11 @@ int _yada_execute(yada_t *_yada, void *magic, ...)
 
 int _yada_xexecute(yada_t *_yada, int flags, void *magic, ...)
 {
-  int len, rv;
+  size_t len;
+  int rv;
   char *qstr;
   va_list ap;
 
-
   va_start(ap, magic);
 
   /* check for string */
@@ -851,7 +847,7 @@ int _yada_xexecute(yada_t *_yada, int flags, void *magic, ...)
 
 yada_rc_t* _yada_vquery(yada_t *_yada, void *magic, va_list ap)
 {
-  int len;
+  size_t len;
   char *qstr;
   yada_rc_t *qrc;
   yada_rc_t *rc;
@@ -911,7 +907,7 @@ int _yada_xexecute(yada_t *_yada, int flags, void *magic, ...)
 
 yada_rc_t* _yada_xquery(yada_t *_yada, int flags, void *magic, ...)
 {
-  int len;
+  size_t len;
   char *qstr;
   va_list ap;
   yada_rc_t *qrc;
@@ -970,7 +966,7 @@ int _yada_xexecute(yada_t *_yada, int flags, void *magic, ...)
 /** return a string of prepared statement ready to be executed
  */
 
-char* _yada_dumpexec(yada_t *_yada, int *retlen, yada_rc_t *_yrc, ...)
+char* _yada_dumpexec(yada_t *_yada, size_t *retlen, yada_rc_t *_yrc, ...)
 {
   char *qstr;
   va_list ap;
diff --git a/src/yada.h b/src/yada.h
index 41ba12e..ffa75ab 100644
--- a/src/yada.h
+++ b/src/yada.h
@@ -137,19 +137,19 @@ struct yada_t
   int type_id;
   char *dbtype;
   char *dbstr;
-  char* (*escstr)(char *, int, char *, int *);
+  char* (*escstr)(char *, size_t, char *, size_t *);
   int (*connect)(yada_t *, char *, char *);
   void (*disconnect)(yada_t *);
-  yada_rc_t* (*prepare)(yada_t *, char *, int);
+  yada_rc_t* (*prepare)(yada_t *, char *, size_t);
   yada_rc_t* (*preparef)(yada_t *, char *, ...);
-  yada_rc_t* (*yprepare)(yada_t *, char *, int);
+  yada_rc_t* (*yprepare)(yada_t *, char *, size_t);
   yada_rc_t* (*ypreparef)(yada_t *, char *, ...);
   yada_rc_t* (*xprepare)(yada_t *, int, char *, ...);
   int (*execute)(yada_t *, void *, ...);
   int (*xexecute)(yada_t *, int, void *, ...);
   yada_rc_t* (*query)(yada_t *, void *, ...);
   yada_rc_t* (*xquery)(yada_t *, int, void *, ...);
-  char* (*dumpexec)(yada_t *, int *, yada_rc_t *, ...);
+  char* (*dumpexec)(yada_t *, size_t *, yada_rc_t *, ...);
   yada_rc_t* (*bind)(yada_t *, char *, ...);
   int (*fetch)(yada_t *, yada_rc_t *, yada_rc_t *);
   int (*trx)(yada_t *, int);
diff --git a/src/yada_mysql.c b/src/yada_mysql.c
index cfe636a..c4a4676 100644
--- a/src/yada_mysql.c
+++ b/src/yada_mysql.c
@@ -128,7 +128,7 @@ static void yada_mysql_disconnect(yada_t *_yada)
 
 /******************************************************************************/
 
-static int yada_mysql__exec(yada_t *_yada, char *sqlstr, int sqlstr_len)
+static int yada_mysql__exec(yada_t *_yada, char *sqlstr, size_t sqlstr_len)
 {
   int rv;
 
@@ -160,7 +160,7 @@ static int yada_mysql__exec(yada_t *_yada, char *sqlstr, int sqlstr_len)
 
 /******************************************************************************/
 
-static yada_rc_t* yada_mysql__query(yada_t *_yada, char *sqlstr, int sqlstr_len)
+static yada_rc_t* yada_mysql__query(yada_t *_yada, char *sqlstr, size_t sqlstr_len)
 {
   int rv;
   yada_rc_t *_yrc;
@@ -327,7 +327,7 @@ int yada_mysql_fetch(yada_t *_yada, yada_rc_t *rrc, yada_rc_t *brc)
       break;
     case 'l':
       bindset->ele[i].var.l = atoll(rrow[di]);
-      *(long long **)bindset->ele[i].ptr = &(bindset->ele[i].var.l);
+      *(int64_t **)bindset->ele[i].ptr = &(bindset->ele[i].var.l);
       break;
     case 's':
     case 'e':
diff --git a/test/yada_test.c b/test/yada_test.c
index 4550080..571573a 100644
--- a/test/yada_test.c
+++ b/test/yada_test.c
@@ -61,12 +61,12 @@
 typedef struct
 {
   int i;
-  long long l;
+  int64_t l;
   char s[60];
   char e[60];
   char b[60];
   int blen;
-  int vnull;
+  size_t vnull;
   char v[60];
   double f;
 } insval_t;
@@ -75,7 +75,7 @@
 {
   int *id;
   int *i;
-  long long *l;
+  int64_t *l;
   char *s;
   char *e;
   char *b;
@@ -230,7 +230,7 @@ int compare_ptr(insval_t *src, bindptr_t *dst)
     {
     dbstr = "mysql:localhost::test";
     dbuser = "test";
-    dbpass = "";
+    dbpass = "test";
     create_table = mysql_create_table;
     }
   else if(spin() && !strcmp("oracle", type))
@@ -339,12 +339,18 @@ int ytest_prepare(yada_t *yada)
   test_start("native prepare / insert");
   spin();
 
+  printf("=> One..\n");
+
   if(!(stmt = yada->prepare(yada, SQL_PREP_INS, 0)))
     test_fail("failed to prepare statement: %s", yada->errmsg);
 
+  printf("=> Two..\n");
+
   for(i = 0; i < insval_rows; i++)
     {
     spin();
+
+  printf("=> FOR(%d)..\n", i);
  
     if(yada->execute(yada, stmt, i, insval[i].i, insval[i].l, insval[i].s,
      insval[i].e, insval[i].vnull, insval[i].v, insval[i].f) == -1)