Index: sql.c =================================================================== RCS file: /mnt/kens/cvsroot/kens/scheme/squile/sql.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -B -w -p -r1.1 -r1.2 --- sql.c 3 Jan 2004 02:36:21 -0000 1.1 +++ sql.c 2 Aug 2004 06:14:02 -0000 1.2 @@ -81,11 +81,11 @@ int gh_sql_realloc_dbs(int old_size, int } int gh_sql_init_db(void *db, char *db_name, char *host_name, - char *user_name, char *pass) { + char *user_name, char *pass, char *port) { char buf[GH_SQL_BUF_LEN]; - if (!(gh_sql_imp_connect(db, host_name, user_name, pass))) { + if (!(gh_sql_imp_connect(db, db_name, host_name, user_name, pass, port))) { snprintf(buf, GH_SQL_BUF_LEN, "gh_sql_init: Unable to connect to " "server: %s \n", gh_sql_imp_error(db)); gh_sql_error(buf); @@ -107,7 +107,7 @@ int gh_sql_init_db(void *db, char *db_na #define GH_DB_GROW 2 SCM gh_sql_create(char *db_name, char *host_name, char *user_name, - char *pass) { + char *pass, char *port) { int i; @@ -144,7 +144,7 @@ SCM gh_sql_create(char *db_name, char *h /* initialize the mutex */ if (!gh_sql_init_db(gh_sql_dbs[i], db_name, - host_name, user_name, pass)) { + host_name, user_name, pass, port)) { free(gh_sql_dbs[i]); gh_sql_dbs[i] = NULL; return SCM_BOOL_F; @@ -170,9 +170,9 @@ char *gh_sql_create_param(SCM arg) { /* gh_sql_create_prim returns the index of a newly allocated and initalized mutex from the mutex table. */ SCM gh_sql_create_prim (SCM scm_db_name, SCM scm_host_name, - SCM scm_user_name, SCM scm_pass) { + SCM scm_user_name, SCM scm_pass, SCM scm_port) { - char *db_name, *host_name = NULL, *user_name = NULL, *pass = NULL; + char *db_name, *host_name = NULL, *user_name = NULL, *pass = NULL, *port = NULL; SCM ret; if (scm_host_name != SCM_UNDEFINED) { @@ -181,13 +181,16 @@ SCM gh_sql_create_prim (SCM scm_db_name, user_name = gh_sql_create_param(scm_user_name); if (scm_pass != SCM_UNDEFINED) { pass = gh_sql_create_param(scm_pass); + if (scm_port != SCM_UNDEFINED) { + port = gh_sql_create_param(scm_port); + } } } } if (gh_string_p(scm_db_name)) { db_name = gh_scm2newstr(scm_db_name, NULL); - ret = gh_sql_create(db_name, host_name, user_name, pass); + ret = gh_sql_create(db_name, host_name, user_name, pass, port); free(db_name); } else { gh_sql_error("gh_sql_create_prim: Argument to db-create is not a " @@ -201,6 +204,8 @@ SCM gh_sql_create_prim (SCM scm_db_name, free(user_name); if (pass) free(pass); + if (port) + free(port); return ret; } @@ -258,7 +263,7 @@ SCM gh_sql_destroy_prim (SCM arg) { /* begin sql-query section */ -/* send a query to the sql engine and return a scm list in the +/* send a query to the sql engine and return a scm vector in the * following format: [[field1 field2 ...] [data1 data2 ...] ... ] * * If there is an error, return NULL. If the resultset is empty, the Index: sql.h =================================================================== RCS file: /mnt/kens/cvsroot/kens/scheme/squile/sql.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -B -w -p -r1.1 -r1.2 --- sql.h 3 Jan 2004 02:36:22 -0000 1.1 +++ sql.h 2 Aug 2004 06:14:03 -0000 1.2 @@ -27,7 +27,7 @@ SCM gh_sql_query_prim(SCM db_id, SCM que /* create a database */ SCM gh_sql_create_prim(SCM db_name, SCM host_name, SCM user_name, - SCM passwd); + SCM pass, SCM port); /* destroy a database */ SCM gh_sql_destroy_prim(SCM db_id); Index: sql_imp.c =================================================================== RCS file: /mnt/kens/cvsroot/kens/scheme/squile/sql_imp.c,v retrieving revision 1.3 retrieving revision 1.5 diff -u -b -B -w -p -r1.3 -r1.5 --- sql_imp.c 21 Mar 2004 16:35:50 -0000 1.3 +++ sql_imp.c 2 Aug 2004 06:19:19 -0000 1.5 @@ -38,13 +38,17 @@ int gh_sql_msql_affected_rows; #endif -int gh_sql_imp_connect(void *db, char *host, char *name, char *pass) { +int gh_sql_imp_connect(void *dbh, char *dbname, char *host, char *user, char *pass, char *port) { #ifdef GH_SQL_MYSQL - return (int)mysql_connect((MYSQL *)db, host, name, pass); + int realport = port ? atoi(port) : 0; + + mysql_init((MYSQL *)dbh); + return (int)mysql_real_connect((MYSQL *)dbh, host, user, pass, + dbname, realport, NULL, 0); #elif defined GH_SQL_MSQL - *((int *)db) = msqlConnect(host); - return (*((int *)db) >= 0); + *((int *)dbh) = msqlConnect(host); + return (*((int *)dbh) >= 0); #endif } Index: sql_imp.h =================================================================== RCS file: /mnt/kens/cvsroot/kens/scheme/squile/sql_imp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -B -w -p -r1.1 -r1.2 --- sql_imp.h 3 Jan 2004 02:36:24 -0000 1.1 +++ sql_imp.h 2 Aug 2004 06:14:05 -0000 1.2 @@ -26,8 +26,8 @@ #include -int gh_sql_imp_connect(void *db, char *host_name, char *user_name, - char *pass); +int gh_sql_imp_connect(void *db, char *dbname, char *host, char *user, + char *pass, char *port); int gh_sql_imp_select_db(void *db, char *db_name); char *gh_sql_imp_error(void *db); void gh_sql_imp_close(void *db); Index: squile.c =================================================================== RCS file: /mnt/kens/cvsroot/kens/scheme/squile/squile.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -B -w -p -r1.1 -r1.2 --- squile.c 3 Jan 2004 02:36:25 -0000 1.1 +++ squile.c 2 Aug 2004 06:14:06 -0000 1.2 @@ -34,7 +34,7 @@ inner_main (void *closure, int argc, cha { gh_new_procedure("sql-query", gh_sql_query_prim, 2, 0, 0); - gh_new_procedure("sql-create", gh_sql_create_prim, 1, 3, 0); + gh_new_procedure("sql-create", gh_sql_create_prim, 1, 4, 0); gh_new_procedure("sql-destroy", gh_sql_destroy_prim, 1, 0, 0); /* module initializations would go here */