Merge lp:~jobinau/drizzle/mingwport into lp:~drizzle-trunk/drizzle/development

Proposed by Jobin Augustine
Status: Rejected
Rejected by: Lee Bieber
Proposed branch: lp:~jobinau/drizzle/mingwport
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 164 lines (+58/-7)
2 files modified
client/drizzle.cc (+19/-2)
client/get_password.cc (+39/-5)
To merge this branch: bzr merge lp:~jobinau/drizzle/mingwport
Reviewer Review Type Date Requested Status
Lee Bieber (community) Needs Fixing
Review via email: mp+33481@code.launchpad.net

Description of the change

Please Review Revisions after last merge
and advice me if any changes are to be done.

These modifications are for compiling the drizzle client tools in windows.

To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

Can't build on Linux:

  CXX client/drizzle.o
client/drizzle.cc: In function ‘int main(int, char**)’:
client/drizzle.cc:1562: error: ‘_isatty’ was not declared in this scope
client/drizzle.cc: In function ‘void window_resize(int)’:
client/drizzle.cc:1934: error: aggregate ‘winsize window_size’ has incomplete type and cannot be defined
client/drizzle.cc:1936: error: ‘TIOCGWINSZ’ was not declared in this scope
client/drizzle.cc:1936: error: ‘ioctl’ was not declared in this scope
make[2]: *** [client/drizzle.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/lbieber/repos/build'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/lbieber/repos/build'
make: *** [all] Error 2

review: Needs Fixing
Revision history for this message
Jobin Augustine (jobinau) wrote :

Thank you Lee for the test.
The decision to push as small patches is paying off.

Monty,
I need a help on build.
HAVE_SYS_IOCTL_H is not getting defined in config.h in Linux.

Unmerged revisions

1706. By jobin <jobin@jobin-laptop>

modification requied to compile on windows

1705. By jobin <jobin@jobin-laptop>

in windows, read password from keyboard and put * into screen

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/drizzle.cc'
2--- client/drizzle.cc 2010-08-21 17:16:51 +0000
3+++ client/drizzle.cc 2010-08-24 02:26:41 +0000
4@@ -63,10 +63,16 @@
5 #include <math.h>
6 #include "client/linebuffer.h"
7 #include <signal.h>
8+#ifdef HAVE_SYS_IOCTL_H
9 #include <sys/ioctl.h>
10+#endif
11 #include <drizzled/configmake.h>
12 #include "drizzled/utf8/utf8.h"
13-#include <cstdlib>
14+#include <cstdlib> /*not sure where it is used */
15+#ifdef _WIN32
16+#include <io.h>
17+#endif
18+
19
20 #if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
21 #include <curses.h>
22@@ -1553,7 +1559,7 @@
23 default_pager.assign(tmp);
24 }
25 }
26- if (! isatty(0) || ! isatty(1))
27+ if (! _isatty(0) || ! _isatty(1))
28 {
29 status.setBatch(1); opt_silent=1;
30 ignore_errors=0;
31@@ -1806,6 +1812,8 @@
32 if (histfile)
33 sprintf(histfile,"%s/.drizzle_history",getenv("HOME"));
34 char link_name[FN_REFLEN];
35+#ifndef _WIN32
36+ /*links won't work in windows */
37 ssize_t sym_link_size= readlink(histfile,link_name,FN_REFLEN-1);
38 if (sym_link_size >= 0)
39 {
40@@ -1817,6 +1825,7 @@
41 histfile= 0;
42 }
43 }
44+#endif
45 }
46 if (histfile)
47 {
48@@ -4360,16 +4369,24 @@
49 putc(c, OUTFILE);
50 }
51
52+#ifdef _WIN32
53+#include <time.h>
54+#else
55 #include <sys/times.h>
56 #ifdef _SC_CLK_TCK // For mit-pthreads
57 #undef CLOCKS_PER_SEC
58 #define CLOCKS_PER_SEC (sysconf(_SC_CLK_TCK))
59 #endif
60+#endif
61
62 static uint32_t start_timer(void)
63 {
64+#ifdef _WIN32
65+ return clock();
66+#else
67 struct tms tms_tmp;
68 return times(&tms_tmp);
69+#endif
70 }
71
72
73
74=== modified file 'client/get_password.cc'
75--- client/get_password.cc 2010-06-19 16:36:52 +0000
76+++ client/get_password.cc 2010-08-24 02:26:41 +0000
77@@ -33,6 +33,7 @@
78 #include <ctype.h>
79 #include <unistd.h>
80
81+#ifndef _WIN32
82 #include <sys/ioctl.h>
83 #ifdef HAVE_TERMIOS_H /* For tty-password */
84 # include <termios.h>
85@@ -46,6 +47,9 @@
86 # define TERMIO struct sgttyb
87 # endif
88 #endif
89+#else /*in windows, include conio.h*/
90+#include <conio.h>
91+#endif
92
93 using namespace std;
94
95@@ -100,7 +104,6 @@
96
97 char *client_get_tty_password(const char *opt_message)
98 {
99- TERMIO org,tmp;
100 char buff[80];
101
102 if (isatty(fileno(stdout)))
103@@ -108,9 +111,42 @@
104 fputs(opt_message ? opt_message : "Enter password: ",stdout);
105 fflush(stdout);
106 }
107+
108+#if defined(_WIN32)
109+ /*windows specific password reading logic goes here (read it from keyboard) */
110+ char *pos=buff,*end=buff+sizeof(buff)-1;
111+ int i=0;
112+ for (;;)
113+ {
114+ char tmp;
115+ tmp=_getch();
116+ if (tmp == '\b' || (int) tmp == 127)
117+ {
118+ if (pos != buff)
119+ {
120+ _cputs("\b \b");
121+ pos--;
122+ continue;
123+ }
124+ }
125+ if (tmp == '\n' || tmp == '\r' || tmp == 3)
126+ break;
127+ if (iscntrl(tmp) || pos == end)
128+ continue;
129+ _cputs("*");
130+ *(pos++) = tmp;
131+ }
132+ while (pos != buff && isspace(pos[-1]) == ' ')
133+ pos--; /* Allow dummy space at end */
134+ *pos=0;
135+ _cputs("\n");
136+#else /*if not windows, Declare and initialize TERMIO variables */
137+ TERMIO org,tmp;
138+ tmp = org;
139+#endif
140+
141 # if defined(HAVE_TERMIOS_H)
142 tcgetattr(fileno(stdin), &org);
143- tmp = org;
144 tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
145 tmp.c_cc[VMIN] = 1;
146 tmp.c_cc[VTIME] = 0;
147@@ -119,16 +155,14 @@
148 tcsetattr(fileno(stdin), TCSADRAIN, &org);
149 # elif defined(HAVE_TERMIO_H)
150 ioctl(fileno(stdin), (int) TCGETA, &org);
151- tmp=org;
152 tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
153 tmp.c_cc[VMIN] = 1;
154 tmp.c_cc[VTIME]= 0;
155 ioctl(fileno(stdin),(int) TCSETA, &tmp);
156 get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
157 ioctl(fileno(stdin),(int) TCSETA, &org);
158-# else
159+# elif !defined(_WIN32)
160 gtty(fileno(stdin), &org);
161- tmp=org;
162 tmp.sg_flags &= ~ECHO;
163 tmp.sg_flags |= RAW;
164 stty(fileno(stdin), &tmp);