--- mysql2dbf.c.orig	Tue Nov 25 23:35:54 2003
+++ mysql2dbf.c	Fri Nov 28 19:56:04 2003
@@ -46,7 +46,7 @@
 }
 
 int main(int argc, char **argv) {
-	int             i;
+	int             i, decimals = -1;
 	MYSQL		*SQLsock,mysql;
 	extern int      optind;
 	extern char     *optarg;
@@ -101,6 +101,9 @@
 		        case 'U':
 			        user = (char *)strdup(optarg);
 				break;
+			case 'p':
+				decimals = atoi(strdup(optarg));
+				break;
 			case ':':
 				usage();
 				printf("Missing argument!\n");
@@ -148,7 +151,8 @@
 		printf("Making connection with mySQL-server\n");
 	}
 
-    if (!(SQLsock = mysql_connect(&mysql,host,user,pass))) {
+    mysql_init(&mysql);
+    if (!(SQLsock = mysql_real_connect(&mysql,host,user,pass,dbase,0,NULL,0))) {
         fprintf(stderr, "Couldn't get a connection with the ");
         fprintf(stderr, "designated host!\n");
         fprintf(stderr, "Detailed report: %s\n", mysql_error(&mysql));
@@ -195,6 +199,15 @@
 	  
 	  strtoupper(qfield->name);
 	  switch (qfield->type) {
+          /* this case catches BIGINTs */
+          case FIELD_TYPE_LONGLONG:
+            dbf_add_field(dbh, qfield->name, 'N', qfield->length, 0);
+	    if (verbose > 1) {
+	      printf("Adding field: %s, LONGLONG, %d\n", qfield->name,
+		     qfield->length);
+	    
+	    }
+            break;
 	    /* assume INT's have a max. of 10 digits (4^32 has 10 digits) */
 	  case FIELD_TYPE_CHAR:
 	  case FIELD_TYPE_SHORT:
@@ -212,7 +225,7 @@
 	  case FIELD_TYPE_FLOAT:
 	  case FIELD_TYPE_DECIMAL:
 	    dbf_add_field(dbh, qfield->name, 'N', qfield->length,
-			  qfield->decimals);
+			  (decimals == -1 ? qfield->decimals : decimals));
 	    if (verbose > 1) {
 	      printf("Adding field: %s, INT_REAL, %d\n", qfield->name,
 		     qfield->length);

