Skip to Content.
Sympa Menu

freetds - [freetds] small patches

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: christos AT zoulas.com (Christos Zoulas)
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] small patches
  • Date: Wed, 5 Nov 2003 14:07:04 -0500

Hello,

1. In c++ you cannot use cs_config() and typedef struct cs_config
2. constify server name
3. GO == go = Go etc.
4. Don't use readline when stdin is not a tty. Now we can use scripts from
stdin.

christos

PS: BCP writes don't work?

Index: include/cspublic.h
===================================================================
RCS file: /src/twosigma/cvsroot/pub/devel/freetds/include/cspublic.h,v
retrieving revision 1.1.1.5
retrieving revision 1.8
diff -u -u -1 -r1.1.1.5 -r1.8
--- include/cspublic.h 10 Oct 2003 21:32:56 -0000 1.1.1.5
+++ include/cspublic.h 10 Oct 2003 21:43:35 -0000 1.8
@@ -75,3 +75,3 @@

-typedef struct cs_config
+typedef struct _cs_config
{
@@ -177,3 +177,3 @@

-typedef struct cs_locale
+typedef struct _cs_locale
{
@@ -197,6 +197,5 @@

-
#define CS_IODATA (CS_INT)1600

-typedef struct cs_iodesc
+typedef struct _cs_iodesc
{
@@ -221,3 +220,3 @@

-typedef struct cs_command
+typedef struct _cs_command
{
@@ -251,3 +250,3 @@

-typedef struct cs_datafmt
+typedef struct _cs_datafmt
{
@@ -273,3 +272,3 @@

-typedef struct cs_daterec
+typedef struct _cs_daterec
{
@@ -321,3 +320,3 @@

-typedef struct cs_blkdesc
+typedef struct _cs_blkdesc
{
Index: include/ctpublic.h
===================================================================
RCS file: /src/twosigma/cvsroot/pub/devel/freetds/include/ctpublic.h,v
retrieving revision 1.1.1.4
retrieving revision 1.8
diff -u -u -1 -r1.1.1.4 -r1.8
--- include/ctpublic.h 10 Oct 2003 21:32:56 -0000 1.1.1.4
+++ include/ctpublic.h 10 Oct 2003 21:51:30 -0000 1.8
@@ -39,3 +39,3 @@
CS_RETCODE ct_con_props(CS_CONNECTION * con, CS_INT action, CS_INT property,
CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
-CS_RETCODE ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT
snamelen);
+CS_RETCODE ct_connect(CS_CONNECTION * con, const CS_CHAR * servername,
CS_INT snamelen);
CS_RETCODE ct_cmd_alloc(CS_CONNECTION * con, CS_COMMAND ** cmd);
Index: src/apps/tsql.c
===================================================================
RCS file: /src/twosigma/cvsroot/pub/devel/freetds/src/apps/tsql.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -u -1 -r1.1.1.3 -r1.2
--- src/apps/tsql.c 10 Oct 2003 21:32:56 -0000 1.1.1.3
+++ src/apps/tsql.c 10 Oct 2003 21:52:13 -0000 1.2
@@ -79,2 +79,4 @@

+static int istty = 0;
+
int do_query(TDSSOCKET * tds, char *buf, int opt_flags);
@@ -86,8 +88,7 @@

-#ifndef HAVE_READLINE
-char *readline(char *prompt);
-void add_history(const char *s);
+char *my_readline(char *prompt);
+void my_add_history(const char *s);

char *
-readline(char *prompt)
+my_readline(char *prompt)
{
@@ -111,5 +112,9 @@
void
-add_history(const char *s)
+my_add_history(const char *s)
{
}
+
+#ifndef HAVE_READLINE
+#define readline my_readline
+#define add_history my_add_history
#endif
@@ -229,2 +234,3 @@

+ *opt_flags = 0;
/* make sure we have enough elements */
@@ -442,3 +448,6 @@
*n = '\0';
- add_history(s);
+ if (istty)
+ add_history(s);
+ else
+ my_add_history(s);
(*line)++;
@@ -465,2 +474,4 @@

+ istty = isatty(0);
+
context = tds_alloc_context();
@@ -496,3 +507,6 @@
free(s);
- s = readline(prompt);
+ if (istty)
+ s = readline(prompt);
+ else
+ s = my_readline(prompt);
if (s != NULL) {
@@ -506,6 +520,6 @@

- if (!s || !strcmp(cmd, "exit") || !strcmp(cmd, "quit") ||
!strcmp(cmd, "bye")) {
+ if (!s || !strcasecmp(cmd, "exit") || !strcasecmp(cmd,
"quit") || !strcasecmp(cmd, "bye")) {
break;
}
- if (!strcmp(cmd, "version")) {
+ if (!strcasecmp(cmd, "version")) {
tds_version(tds, mybuf);
@@ -516,3 +530,3 @@
}
- if (!strncmp(cmd, "go", 2)) {
+ if (!strncasecmp(cmd, "go", 2)) {
line = 0;
@@ -521,6 +535,6 @@
mybuf[0] = '\0';
- } else if (!strcmp(cmd, "reset")) {
+ } else if (!strcasecmp(cmd, "reset")) {
line = 0;
mybuf[0] = '\0';
- } else if (!strcmp(cmd, ":r")) {
+ } else if (!strcasecmp(cmd, ":r")) {
slurp_input_file(strtok(NULL, " \t"), &mybuf, &bufsz,
&line);
@@ -531,3 +545,6 @@
}
- add_history(s);
+ if (istty)
+ add_history(s);
+ else
+ my_add_history(s);
strcat(mybuf, s);
Index: src/ctlib/ct.c
===================================================================
RCS file: /src/twosigma/cvsroot/pub/devel/freetds/src/ctlib/ct.c,v
retrieving revision 1.1.1.5
retrieving revision 1.6
diff -u -u -1 -r1.1.1.5 -r1.6
--- src/ctlib/ct.c 10 Oct 2003 21:32:56 -0000 1.1.1.5
+++ src/ctlib/ct.c 10 Oct 2003 21:43:36 -0000 1.6
@@ -470,3 +470,3 @@
CS_RETCODE
-ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen)
+ct_connect(CS_CONNECTION * con, const CS_CHAR * servername, CS_INT snamelen)
{




Archive powered by MHonArc 2.6.24.

Top of Page