Update of /cvsroot/hcoop/domtool2/src In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv25596/src
Modified Files: dbms.sig dbms.sml main-dbtool.sml main.sig main.sml msg.sml msgTypes.sml Log Message: Specifying encoding on database creation Index: msgTypes.sml =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/msgTypes.sml,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** msgTypes.sml 17 Nov 2007 17:44:11 -0000 1.33 --- msgTypes.sml 9 Apr 2008 14:23:57 -0000 1.34 *************** *** 77,81 **** | MsgCreateDbUser of {dbtype : string, passwd : string option} (* Request creation of a user for the named DBMS type *) ! | MsgCreateDb of {dbtype : string, dbname : string} (* Request creation of a DBMS database *) | MsgDropDb of {dbtype : string, dbname : string} --- 77,81 ---- | MsgCreateDbUser of {dbtype : string, passwd : string option} (* Request creation of a user for the named DBMS type *) ! | MsgCreateDb of {dbtype : string, dbname : string, encoding : string option} (* Request creation of a DBMS database *) | MsgDropDb of {dbtype : string, dbname : string} Index: main.sig =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/main.sig,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** main.sig 25 Feb 2008 01:40:17 -0000 1.47 --- main.sig 9 Apr 2008 14:23:57 -0000 1.48 *************** *** 59,63 **** val requestDbUser : {dbtype : string, passwd : string option} -> unit val requestDbPasswd : {dbtype : string, passwd : string} -> unit ! val requestDbTable : {dbtype : string, dbname : string} -> unit val requestDbDrop : {dbtype : string, dbname : string} -> unit val requestDbGrant : {dbtype : string, dbname : string} -> unit --- 59,63 ---- val requestDbUser : {dbtype : string, passwd : string option} -> unit val requestDbPasswd : {dbtype : string, passwd : string} -> unit ! val requestDbTable : {dbtype : string, dbname : string, encoding : string option} -> unit val requestDbDrop : {dbtype : string, dbname : string} -> unit val requestDbGrant : {dbtype : string, dbname : string} -> unit Index: dbms.sml =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/dbms.sml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dbms.sml 13 Nov 2007 23:52:59 -0000 1.7 --- dbms.sml 9 Apr 2008 14:23:57 -0000 1.8 *************** *** 24,32 **** val validDbname = CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"_") type handler = {getpass : (unit -> Client.passwd_result) option, adduser : {user : string, passwd : string option} -> string option, passwd : {user : string, passwd : string} -> string option, ! createdb : {user : string, dbname : string} -> string option, dropdb : {user : string, dbname : string} -> string option, grant : {user : string, dbname : string} -> string option} --- 24,36 ---- val validDbname = CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"_") + fun validEncoding encoding = + case encoding of + NONE => true + | SOME e => size e > 0 andalso size e < 20 andalso CharVector.all Char.isAlphaNum e type handler = {getpass : (unit -> Client.passwd_result) option, adduser : {user : string, passwd : string option} -> string option, passwd : {user : string, passwd : string} -> string option, ! createdb : {user : string, dbname : string, encoding : string option} -> string option, dropdb : {user : string, dbname : string} -> string option, grant : {user : string, dbname : string} -> string option} Index: main-dbtool.sml =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/main-dbtool.sml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main-dbtool.sml 23 Dec 2007 22:26:39 -0000 1.7 --- main-dbtool.sml 9 Apr 2008 14:23:57 -0000 1.8 *************** *** 59,65 **** | ["createdb", dbname] => if Dbms.validDbname dbname then ! Main.requestDbTable {dbtype = dbtype, dbname = dbname} else print ("Invalid database name " ^ dbname ^ ".\n") | ["dropdb", dbname] => if Dbms.validDbname dbname then --- 59,72 ---- | ["createdb", dbname] => if Dbms.validDbname dbname then ! Main.requestDbTable {dbtype = dbtype, dbname = dbname, encoding = NONE} else print ("Invalid database name " ^ dbname ^ ".\n") + | ["createdb", dbname, encoding] => + if not (Dbms.validDbname dbname) then + print ("Invalid database name " ^ dbname ^ ".\n") + else if not (Dbms.validEncoding (SOME encoding)) then + print ("Invalid encoding name " ^ encoding ^ ".\n") + else + Main.requestDbTable {dbtype = dbtype, dbname = dbname, encoding = SOME encoding} | ["dropdb", dbname] => if Dbms.validDbname dbname then Index: dbms.sig =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/dbms.sig,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dbms.sig 2 Jul 2007 16:14:44 -0000 1.6 --- dbms.sig 9 Apr 2008 14:23:57 -0000 1.7 *************** *** 22,30 **** val validDbname : string -> bool type handler = {getpass : (unit -> Client.passwd_result) option, adduser : {user : string, passwd : string option} -> string option, passwd : {user : string, passwd : string} -> string option, ! createdb : {user : string, dbname : string} -> string option, dropdb : {user : string, dbname : string} -> string option, grant : {user : string, dbname : string} -> string option} --- 22,31 ---- val validDbname : string -> bool + val validEncoding : string option -> bool type handler = {getpass : (unit -> Client.passwd_result) option, adduser : {user : string, passwd : string option} -> string option, passwd : {user : string, passwd : string} -> string option, ! createdb : {user : string, dbname : string, encoding : string option} -> string option, dropdb : {user : string, dbname : string} -> string option, grant : {user : string, dbname : string} -> string option} Index: main.sml =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/main.sml,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** main.sml 16 Mar 2008 00:07:02 -0000 1.102 --- main.sml 9 Apr 2008 14:23:57 -0000 1.103 *************** *** 1366,1370 **** (fn () => ()) ! | MsgCreateDb {dbtype, dbname} => doIt (fn () => if Dbms.validDbname dbname then --- 1366,1370 ---- (fn () => ()) ! | MsgCreateDb {dbtype, dbname, encoding} => doIt (fn () => if Dbms.validDbname dbname then *************** *** 1373,1381 **** SOME ("Unknown database type " ^ dbtype)) | SOME handler => ! case #createdb handler {user = user, dbname = dbname} of ! NONE => ("Created database " ^ user ^ "_" ^ dbname ^ ".", ! NONE) ! | SOME msg => ("Error creating database " ^ user ^ "_" ^ dbname ^ ": " ^ msg, ! SOME ("Error creating database: " ^ msg)) else ("Invalid database name " ^ user ^ "_" ^ dbname, --- 1373,1385 ---- SOME ("Unknown database type " ^ dbtype)) | SOME handler => ! if not (Dbms.validEncoding encoding) then ! ("Invalid encoding " ^ valOf encoding ^ " requested for database creation.", ! SOME "Invalid encoding") ! else ! case #createdb handler {user = user, dbname = dbname, encoding = encoding} of ! NONE => ("Created database " ^ user ^ "_" ^ dbname ^ ".", ! NONE) ! | SOME msg => ("Error creating database " ^ user ^ "_" ^ dbname ^ ": " ^ msg, ! SOME ("Error creating database: " ^ msg)) else ("Invalid database name " ^ user ^ "_" ^ dbname, Index: msg.sml =================================================================== RCS file: /cvsroot/hcoop/domtool2/src/msg.sml,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** msg.sml 17 Nov 2007 19:12:28 -0000 1.34 --- msg.sml 9 Apr 2008 14:23:57 -0000 1.35 *************** *** 174,180 **** OpenSSL.writeString (bio, dbtype); sendOption OpenSSL.writeString (bio, passwd)) ! | MsgCreateDb {dbtype, dbname} => (OpenSSL.writeInt (bio, 17); ! OpenSSL.writeString (bio, dbtype); ! OpenSSL.writeString (bio, dbname)) | MsgNewMailbox {domain, user, passwd, mailbox} => (OpenSSL.writeInt (bio, 18); --- 174,181 ---- OpenSSL.writeString (bio, dbtype); sendOption OpenSSL.writeString (bio, passwd)) ! | MsgCreateDb {dbtype, dbname, encoding} => (OpenSSL.writeInt (bio, 17); ! OpenSSL.writeString (bio, dbtype); ! OpenSSL.writeString (bio, dbname); ! sendOption OpenSSL.writeString (bio, encoding)) | MsgNewMailbox {domain, user, passwd, mailbox} => (OpenSSL.writeInt (bio, 18); *************** *** 290,296 **** SOME (MsgCreateDbUser {dbtype = dbtype, passwd = passwd}) | _ => NONE) ! | 17 => (case (OpenSSL.readString bio, OpenSSL.readString bio) of ! (SOME dbtype, SOME dbname) => ! SOME (MsgCreateDb {dbtype = dbtype, dbname = dbname}) | _ => NONE) | 18 => (case (OpenSSL.readString bio, OpenSSL.readString bio, --- 291,297 ---- SOME (MsgCreateDbUser {dbtype = dbtype, passwd = passwd}) | _ => NONE) ! | 17 => (case (OpenSSL.readString bio, OpenSSL.readString bio, recvOption OpenSSL.readString bio) of ! (SOME dbtype, SOME dbname, SOME encoding) => ! SOME (MsgCreateDb {dbtype = dbtype, dbname = dbname, encoding = encoding}) | _ => NONE) | 18 => (case (OpenSSL.readString bio, OpenSSL.readString bio, ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ hcoop-cvs mailing list hcoop-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hcoop-cvs