[PATCH] build fisql on VMS (Re: FISQL on OPENVMS)
"Craig A. Berry" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Mar 7, 2009, at 9:35 AM, Craig A. Berry wrote: > > On Mar 2, 2009, at 1:37 AM, Nagy György wrote: > >> I've successfully compiled FREETDS 0.82 on OPENVMS 8.3.1-H1, but I >> have a question: >> >> Can I use FISQL on OPENVMS? > > Nothing says you can't except that build support isn't there yet, and > of course we'll have to build it before we see if there are any other > portability problems. > >> I didn't find it among the apps, and then I realized, that FISQL >> can't be found in the DESCRIP_MMS.TEMPLATE file. > > > If you have time put it in there, please send in a patch. If not, > I'll probably get to it at some point. At some point is today (yes, a bit over a year later). Patch attached. The patch does not touch anything seen by other OS's. There is one new file, vms/edit.c, which adds very rudimentary editor support. That probably needs refinement but is functional in a minimal way now. ________________________________________ Craig A. Berry mailto:[email protected] "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
fisql_vms.patch
(application/octet-stream, 7.3 KB)
--- vms/descrip_mms.template;-0 2009-04-08 22:12:51 -0500
+++ vms/descrip_mms.template 2010-04-18 18:48:21 -0500
@@ -221,6 +221,15 @@ $(TDSODBCOBJS) : $(CONFIGS)
@ open/write readlineh $(MMS$TARGET)
@ write readlineh "char *readline(char *prompt);"
@ write readlineh "int rl_inhibit_completion;"
+ @ write readlineh "/* The following are needed for fisql. */"
+ @ write readlineh "FILE **rl_outstream_get_addr(void);"
+ @ write readlineh "#define rl_outstream (*rl_outstream_get_addr())"
+ @ write readlineh "FILE **rl_instream_get_addr(void);"
+ @ write readlineh "#define rl_instream (*rl_instream_get_addr())"
+ @ write readlineh "static const char *rl_readline_name = NULL;"
+ @ write readlineh "#define rl_bind_key(c,f) do {} while(0)"
+ @ write readlineh "#define rl_reset_line_state() do {} while(0)"
+ @ write readlineh "#define rl_on_new_line() do {} while(0)"
@ close readlineh
[.include]history.h :
@@ -278,7 +287,7 @@ $(TDSODBCSHR) : []libtdsodbc$(OLB)
# Build the utility programs and the pool server
-apps : freebcp$(E) tsql$(E) bsqldb$(E) defncopy$(E) tdspool$(E)
+apps : freebcp$(E) tsql$(E) bsqldb$(E) defncopy$(E) tdspool$(E) fisql$(E)
@ continue
freebcp$(E) : [.src.apps]freebcp$(OBJ) []libsybdb$(OLB) []libtds$(OLB)
@@ -306,6 +315,19 @@ defncopy$(E) : [.src.apps]defncopy$(OBJ)
tdspool$(E) : $(TDSPOOLOBJS) []libtdssrv$(OLB) []libtds$(OLB)
link$(LINKFLAGS)/exe=$(MMS$TARGET) $(TDSPOOLOBJS), []libtdssrv$(OLB)/library, []libtds$(OLB)/library
+
+fisql$(E) : [.src.apps.fisql]fisql$(OBJ) [.src.apps.fisql]interrupt$(OBJ) [.src.apps.fisql]handlers$(OBJ) [.vms]edit$(OBJ)
+ link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library, []libtds$(OLB)/library
+
+[.src.apps.fisql]fisql$(OBJ) : [.src.apps.fisql]fisql.c
+ @ define/nolog/user_mode readline [.include]
+ $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE)) $(MMS$SOURCE)
+
+[.src.apps.fisql]interrupt$(OBJ) : [.src.apps.fisql]interrupt.c
+
+[.src.apps.fisql]handlers$(OBJ) : [.src.apps.fisql]handlers.c
+
+
# Run the test suite
check : buildchecks PWD libtdscheck ctlibcheck dblibcheck $(tdsodbccheck)
--- /dev/null 2010-04-18 19:14:26 -0500
+++ vms/edit.c 2010-04-17 10:54:05 -0500
@@ -0,0 +1,73 @@
+/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
+ * Copyright (C) 2010 Craig A. Berry [email protected]
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* $Id: edit.c,v */
+
+#include <namdef.h>
+#include <descrip.h>
+#include <stsdef.h>
+#include <tpu$routines.h>
+#include <string.h>
+#include <unixlib.h>
+
+#if defined(NAML$C_MAXRSS) && !defined(__VAX)
+# define VMS_MAXRSS (NAML$C_MAXRSS+1)
+#else
+# define VMS_MAXRSS (NAM$C_MAXRSS+1)
+#endif
+
+char vms_fnm[VMS_MAXRSS];
+static int get_vms_name(char *, int);
+
+int
+edit(const char *editor, const char *arg)
+{
+ $DESCRIPTOR(fnm_dsc, "");
+ int status;
+
+ decc$to_vms(arg, get_vms_name, 0, 0);
+
+ fnm_dsc.dsc$a_pointer = vms_fnm;
+ fnm_dsc.dsc$w_length = strlen(vms_fnm);
+
+ if (fnm_dsc.dsc$a_pointer == NULL
+ || fnm_dsc.dsc$w_length == 0)
+ return -1;
+
+ status = TPU$EDIT(&fnm_dsc, &fnm_dsc);
+
+ if ($VMS_STATUS_SUCCESS(status))
+ return 0;
+ else
+ return -1;
+}
+
+static int
+get_vms_name(char *name, int type)
+{
+ strncpy(vms_fnm, name, VMS_MAXRSS);
+ return 1;
+}
+
+int
+reset_term()
+{
+ return 0;
+}
+
--- vms/getpass.c;-0 2005-12-29 04:24:34 -0600
+++ vms/getpass.c 2010-04-18 18:56:10 -0500
@@ -1,5 +1,5 @@
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
- * Copyright (C) 2003 Craig A. Berry [email protected] 23-JAN-2003
+ * Copyright (C) 2003, 2010 Craig A. Berry [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -42,10 +42,13 @@
#include <strings.h>
#include <replacements/readpassphrase.h>
+#include "readline.h"
+
+static FILE *tds_rl_instream = NULL;
+static FILE *tds_rl_outstream = NULL;
static char software_version[] = "$Id: getpass.c,v 1.5 2005/12/29 10:24:34 freddy77 Exp $";
static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
-static char passbuff[128];
/*
* A collection of assorted UNIXy input functions for VMS. The core
@@ -128,14 +131,16 @@ readpassphrase(const char *prompt, char
prompt_dsc.dsc$a_pointer = myprompt;
prompt_dsc.dsc$w_length = strlen(myprompt);
- /* Disable Ctrl-T and Ctrl-Y */
- ctrl_mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY;
- status = LIB$DISABLE_CTRL(&ctrl_mask, &saved_ctrl_mask);
- if (!$VMS_STATUS_SUCCESS(status)) {
- errno = EVMSERR;
- vaxc$errno = status;
- free(myprompt);
- return NULL;
+ if (!(flags & RPP_ECHO_ON) && (ttdevclass == DC$_TERM)) {
+ /* Disable Ctrl-T and Ctrl-Y */
+ ctrl_mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY;
+ status = LIB$DISABLE_CTRL(&ctrl_mask, &saved_ctrl_mask);
+ if (!$VMS_STATUS_SUCCESS(status)) {
+ errno = EVMSERR;
+ vaxc$errno = status;
+ free(myprompt);
+ return NULL;
+ }
}
/*
@@ -161,7 +166,7 @@ readpassphrase(const char *prompt, char
status = SYS$ASSIGN(&ttdsc, &ttchan, 0, 0, 0);
if ($VMS_STATUS_SUCCESS(status)) {
- unsigned long qio_func = IO$_READPROMPT | IO$M_NOECHO;
+ unsigned long qio_func = IO$_READPROMPT | IO$M_NOECHO | IO$M_PURGE;
if (!(flags & RPP_TIMEOUT_OFF))
qio_func |= IO$M_TIMED;
@@ -239,15 +244,17 @@ readpassphrase(const char *prompt, char
free(myprompt);
- /*
- * Reenable previous control processing.
- */
- status = LIB$ENABLE_CTRL(&saved_ctrl_mask);
-
- if (!$VMS_STATUS_SUCCESS(status)) {
- errno = EVMSERR;
- vaxc$errno = status;
- return NULL;
+ if (!(flags & RPP_ECHO_ON) && (ttdevclass == DC$_TERM)) {
+ /*
+ * Reenable previous control processing.
+ */
+ status = LIB$ENABLE_CTRL(&saved_ctrl_mask);
+
+ if (!$VMS_STATUS_SUCCESS(status)) {
+ errno = EVMSERR;
+ vaxc$errno = status;
+ return NULL;
+ }
}
return retval;
@@ -271,10 +278,12 @@ getpass(const char *prompt)
char *
readline(char *prompt)
{
-
- char *buf = NULL;
- char *s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf),
- RPP_ECHO_ON | RPP_TIMEOUT_OFF);
+ char *buf = NULL, *s = NULL, *p = NULL;
+ if (tds_rl_instream == NULL)
+ s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf),
+ RPP_ECHO_ON | RPP_TIMEOUT_OFF);
+ else
+ s = fgets(passbuf, sizeof(passbuf), tds_rl_instream);
if (s != NULL) {
buf = (char *) malloc(strlen(s) + 1);
@@ -288,3 +297,17 @@ void
add_history(const char *s)
{
}
+
+
+FILE **
+rl_instream_get_addr(void)
+{
+ return &tds_rl_instream;
+}
+
+FILE **
+rl_outstream_get_addr(void)
+{
+ return &tds_rl_outstream;
+}
+