Поддержка connect to для isqltcl3.2.d (patch connect sql)
Ключевые слова: patch, connect, sql, (найти похожие документы)
_ RU.UNIX (2:5077/15.22) _____________________________________________ RU.UNIX _
From : Boris Tobotras 2:5020/510 27 Jul 98 21:44:48
Subj : Поддержка connect to для isqltcl3.2.d
________________________________________________________________________________
Может, еще кому надо. Добавляет новую команду:
sql connect database username password
diff -u isqltcl3.2.d/sqlinf.ec isqltcl3.2.d+connect/sqlinf.ec
- --- isqltcl3.2.d/sqlinf.ec Mon Jul 1 21:20:47 1996
+++ isqltcl3.2.d+connect/sqlinf.ec Mon Jul 27 18:38:48 1998
@@ -1465,6 +1465,22 @@
return 0;
}
+int sql_connect(database, username, password)
+ char *database, *username, *password;
+{
+ $char *dbase;
+ $char *user;
+ $char *pass;
+
+ dbase = database;
+ user = username;
+ pass = password;
+
+ $connect to $dbase user $user using $pass;
+ chk_status("CONNECT", database);
+ return 0;
+}
+
int sql_finish() {
if (database_name) {
$close database;
diff -u isqltcl3.2.d/tclsql.c isqltcl3.2.d+connect/tclsql.c
- --- isqltcl3.2.d/tclsql.c Wed Jul 24 18:54:44 1996
+++ isqltcl3.2.d+connect/tclsql.c Mon Jul 27 18:46:03 1998
@@ -16,7 +16,7 @@
int tcl_informix_cmds();
int tcl_system();
extern char *sql_geterror();
-isql_init(interp) Tcl_Interp *interp; {
+Isql_Init(interp) Tcl_Interp *interp; {
Tcl_CreateCommand(interp, "sql", tcl_informix_cmds,
(ClientData)0L,(void (*)()) NULL);
Tcl_CreateCommand(interp, "tcl_system", tcl_system,
@@ -25,7 +25,7 @@
}
static int tcl_sql_usage(interp) Tcl_Interp *interp; {
- Tcl_AppendResult(interp, "wrong args to sql: should be one of open,\n\
+ Tcl_AppendResult(interp, "wrong args to sql: should be one of
connect,open,\n\
fetch,close,run,exists,reopen,explain,geterror,sqlca,sqlda,\n\
sqld,database,getdatabase,finish", (char *)NULL);
return TCL_ERROR;
@@ -42,8 +42,12 @@
if (!minor) return tcl_sql_usage(interp);
mlen = strlen(minor);
- if (*minor == 'c' && strncmp(minor, "close", mlen) == 0)
- return tcl_sql_close(dummy, interp, --argc, ++argv);
+ if (*minor == 'c') {
+ if (strncmp(minor, "close", mlen) == 0)
+ return tcl_sql_close(dummy, interp, --argc, ++argv);
+ if (strncmp(minor, "connect", mlen) == 0)
+ return tcl_sql_connect(dummy,interp, --argc, ++argv);
+ }
if (*minor == 'd' && strncmp(minor, "database", mlen) == 0)
return tcl_sql_database(dummy, interp, --argc, ++argv);
if (*minor == 'e') {
@@ -548,6 +552,39 @@
}
sprintf(buf, "%d", ret);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ return TCL_OK;
+}
+
+
+int
+tcl_sql_connect(dummy, interp, argc, argv)
+ ClientData dummy; /* Not used. */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int argc; /* Number of arguments. */
+ char **argv; /* Argument strings. */
+{
+ char *arg0, *dbase, *user, *pass;
+ char buf[25];
+ int ret;
+ if (argc != 4) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"sql ", argv[0],
+ " database username password\"", (char *) NULL);
+ return TCL_ERROR;
+ }
+ arg0 = argv[0];
+ argc--;
+ argv++;
+ dbase = argv[0];
+ user = argv[1];
+ pass = argv[2];
+ ret = sql_connect(dbase, user, pass);
+ if (ret < 0) {
+ Tcl_AppendResult(interp, "\"sql ", arg0, ":", sql_geterror(),
+ "\"", (char *) NULL);
+ return TCL_ERROR;
+ }
+ sprintf(buf, "%d", ret);
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}
--
Best regards, -- Boris.
Lisp ('lishp) n: '(a language (MIT from) that (annoys really) many (and CS
non-CS) people), and makes us feel (artificially
intelligent)))))))))))))))))))
--- Gnus v5.5/XEmacs 20.3 - "London"
* Origin: Linux inside (2:5020/510@fidonet)