Fossil SCM
Win32 port: compiles, all tests pass but many functions fail due to path separators. Incomplete. Path fixes to come next
Commit
83c876b44708a2a5c7380645814ea218cbbaf4ab
Parent
3dc92fdb7f45b8a…
7 files changed
+5
-2
+18
-7
+3
-1
+4
+11
-4
+4
+40
M
Makefile
+5
-2
| --- Makefile | ||
| +++ Makefile | ||
| @@ -24,19 +24,22 @@ | ||
| 24 | 24 | # the finished binary for fossil. The BCC compiler above is used |
| 25 | 25 | # for building intermediate code-generator tools. |
| 26 | 26 | # |
| 27 | 27 | #TCC = gcc -O6 |
| 28 | 28 | #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage |
| 29 | -TCC = gcc -g -Os -Wall | |
| 29 | +#TCC = gcc -g -Os -Wall | |
| 30 | +TCC = gcc -g -Os -Wall -DFOSSIL_I18N=0 | |
| 30 | 31 | |
| 31 | 32 | #### Extra arguments for linking the finished binary. Fossil needs |
| 32 | 33 | # to link against the Z-Lib compression library. There are no |
| 33 | 34 | # other dependencies. We sometimes add the -static option here |
| 34 | 35 | # so that we can build a static executable that will run in a |
| 35 | 36 | # chroot jail. |
| 36 | 37 | # |
| 37 | -LIB = -lz | |
| 38 | +#LIB = -lz | |
| 39 | +LIB = -lz -lwsock32 | |
| 40 | + | |
| 38 | 41 | |
| 39 | 42 | #### Tcl shell for use in running the fossil testsuite. |
| 40 | 43 | # |
| 41 | 44 | TCLSH = tclsh |
| 42 | 45 | |
| 43 | 46 |
| --- Makefile | |
| +++ Makefile | |
| @@ -24,19 +24,22 @@ | |
| 24 | # the finished binary for fossil. The BCC compiler above is used |
| 25 | # for building intermediate code-generator tools. |
| 26 | # |
| 27 | #TCC = gcc -O6 |
| 28 | #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage |
| 29 | TCC = gcc -g -Os -Wall |
| 30 | |
| 31 | #### Extra arguments for linking the finished binary. Fossil needs |
| 32 | # to link against the Z-Lib compression library. There are no |
| 33 | # other dependencies. We sometimes add the -static option here |
| 34 | # so that we can build a static executable that will run in a |
| 35 | # chroot jail. |
| 36 | # |
| 37 | LIB = -lz |
| 38 | |
| 39 | #### Tcl shell for use in running the fossil testsuite. |
| 40 | # |
| 41 | TCLSH = tclsh |
| 42 | |
| 43 |
| --- Makefile | |
| +++ Makefile | |
| @@ -24,19 +24,22 @@ | |
| 24 | # the finished binary for fossil. The BCC compiler above is used |
| 25 | # for building intermediate code-generator tools. |
| 26 | # |
| 27 | #TCC = gcc -O6 |
| 28 | #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage |
| 29 | #TCC = gcc -g -Os -Wall |
| 30 | TCC = gcc -g -Os -Wall -DFOSSIL_I18N=0 |
| 31 | |
| 32 | #### Extra arguments for linking the finished binary. Fossil needs |
| 33 | # to link against the Z-Lib compression library. There are no |
| 34 | # other dependencies. We sometimes add the -static option here |
| 35 | # so that we can build a static executable that will run in a |
| 36 | # chroot jail. |
| 37 | # |
| 38 | #LIB = -lz |
| 39 | LIB = -lz -lwsock32 |
| 40 | |
| 41 | |
| 42 | #### Tcl shell for use in running the fossil testsuite. |
| 43 | # |
| 44 | TCLSH = tclsh |
| 45 | |
| 46 |
+18
-7
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -26,20 +26,26 @@ | ||
| 26 | 26 | ** dispensing QUERY_STRING parameters and cookies, the "mprintf()" |
| 27 | 27 | ** formatting function and its cousins, and routines to encode and |
| 28 | 28 | ** decode strings in HTML or HTTP. |
| 29 | 29 | */ |
| 30 | 30 | #include "config.h" |
| 31 | -#include <sys/socket.h> | |
| 32 | -#include <netinet/in.h> | |
| 33 | -#include <arpa/inet.h> | |
| 31 | +#ifdef __MINGW32__ | |
| 32 | +# include <windows.h> /* for Sleep once server works again */ | |
| 33 | +# include <winsock.h> /* socket operations */ | |
| 34 | +# define sleep Sleep /* windows does not have sleep, but Sleep */ | |
| 35 | +#else | |
| 36 | +# include <sys/socket.h> | |
| 37 | +# include <netinet/in.h> | |
| 38 | +# include <arpa/inet.h> | |
| 39 | +# include <sys/times.h> | |
| 40 | +# include <sys/time.h> | |
| 41 | +# include <sys/wait.h> | |
| 42 | +# include <sys/select.h> | |
| 43 | +#endif | |
| 34 | 44 | #include <time.h> |
| 35 | -#include <sys/times.h> | |
| 36 | -#include <sys/time.h> | |
| 37 | -#include <sys/wait.h> | |
| 38 | 45 | #include <stdio.h> |
| 39 | 46 | #include <stdlib.h> |
| 40 | -#include <sys/select.h> | |
| 41 | 47 | #include <unistd.h> |
| 42 | 48 | #include "cgi.h" |
| 43 | 49 | |
| 44 | 50 | #if INTERFACE |
| 45 | 51 | /* |
| @@ -1076,10 +1082,14 @@ | ||
| 1076 | 1082 | ** As new connections arrive, fork a child and let child return |
| 1077 | 1083 | ** out of this procedure call. The child will handle the request. |
| 1078 | 1084 | ** The parent never returns from this procedure. |
| 1079 | 1085 | */ |
| 1080 | 1086 | void cgi_http_server(int iPort){ |
| 1087 | +#ifdef __MINGW32__ | |
| 1088 | + fprintf(stderr,"server not yet available in windows version of fossil\n"); | |
| 1089 | + exit(1); | |
| 1090 | +#else | |
| 1081 | 1091 | int listener; /* The server socket */ |
| 1082 | 1092 | int connection; /* A socket for each individual connection */ |
| 1083 | 1093 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1084 | 1094 | size_t lenaddr; /* Length of the inaddr structure */ |
| 1085 | 1095 | int child; /* PID of the child process */ |
| @@ -1142,10 +1152,11 @@ | ||
| 1142 | 1152 | nchildren--; |
| 1143 | 1153 | } |
| 1144 | 1154 | } |
| 1145 | 1155 | /* NOT REACHED */ |
| 1146 | 1156 | exit(1); |
| 1157 | +#endif | |
| 1147 | 1158 | } |
| 1148 | 1159 | |
| 1149 | 1160 | /* |
| 1150 | 1161 | ** Name of days and months. |
| 1151 | 1162 | */ |
| 1152 | 1163 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -26,20 +26,26 @@ | |
| 26 | ** dispensing QUERY_STRING parameters and cookies, the "mprintf()" |
| 27 | ** formatting function and its cousins, and routines to encode and |
| 28 | ** decode strings in HTML or HTTP. |
| 29 | */ |
| 30 | #include "config.h" |
| 31 | #include <sys/socket.h> |
| 32 | #include <netinet/in.h> |
| 33 | #include <arpa/inet.h> |
| 34 | #include <time.h> |
| 35 | #include <sys/times.h> |
| 36 | #include <sys/time.h> |
| 37 | #include <sys/wait.h> |
| 38 | #include <stdio.h> |
| 39 | #include <stdlib.h> |
| 40 | #include <sys/select.h> |
| 41 | #include <unistd.h> |
| 42 | #include "cgi.h" |
| 43 | |
| 44 | #if INTERFACE |
| 45 | /* |
| @@ -1076,10 +1082,14 @@ | |
| 1076 | ** As new connections arrive, fork a child and let child return |
| 1077 | ** out of this procedure call. The child will handle the request. |
| 1078 | ** The parent never returns from this procedure. |
| 1079 | */ |
| 1080 | void cgi_http_server(int iPort){ |
| 1081 | int listener; /* The server socket */ |
| 1082 | int connection; /* A socket for each individual connection */ |
| 1083 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1084 | size_t lenaddr; /* Length of the inaddr structure */ |
| 1085 | int child; /* PID of the child process */ |
| @@ -1142,10 +1152,11 @@ | |
| 1142 | nchildren--; |
| 1143 | } |
| 1144 | } |
| 1145 | /* NOT REACHED */ |
| 1146 | exit(1); |
| 1147 | } |
| 1148 | |
| 1149 | /* |
| 1150 | ** Name of days and months. |
| 1151 | */ |
| 1152 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -26,20 +26,26 @@ | |
| 26 | ** dispensing QUERY_STRING parameters and cookies, the "mprintf()" |
| 27 | ** formatting function and its cousins, and routines to encode and |
| 28 | ** decode strings in HTML or HTTP. |
| 29 | */ |
| 30 | #include "config.h" |
| 31 | #ifdef __MINGW32__ |
| 32 | # include <windows.h> /* for Sleep once server works again */ |
| 33 | # include <winsock.h> /* socket operations */ |
| 34 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 35 | #else |
| 36 | # include <sys/socket.h> |
| 37 | # include <netinet/in.h> |
| 38 | # include <arpa/inet.h> |
| 39 | # include <sys/times.h> |
| 40 | # include <sys/time.h> |
| 41 | # include <sys/wait.h> |
| 42 | # include <sys/select.h> |
| 43 | #endif |
| 44 | #include <time.h> |
| 45 | #include <stdio.h> |
| 46 | #include <stdlib.h> |
| 47 | #include <unistd.h> |
| 48 | #include "cgi.h" |
| 49 | |
| 50 | #if INTERFACE |
| 51 | /* |
| @@ -1076,10 +1082,14 @@ | |
| 1082 | ** As new connections arrive, fork a child and let child return |
| 1083 | ** out of this procedure call. The child will handle the request. |
| 1084 | ** The parent never returns from this procedure. |
| 1085 | */ |
| 1086 | void cgi_http_server(int iPort){ |
| 1087 | #ifdef __MINGW32__ |
| 1088 | fprintf(stderr,"server not yet available in windows version of fossil\n"); |
| 1089 | exit(1); |
| 1090 | #else |
| 1091 | int listener; /* The server socket */ |
| 1092 | int connection; /* A socket for each individual connection */ |
| 1093 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1094 | size_t lenaddr; /* Length of the inaddr structure */ |
| 1095 | int child; /* PID of the child process */ |
| @@ -1142,10 +1152,11 @@ | |
| 1152 | nchildren--; |
| 1153 | } |
| 1154 | } |
| 1155 | /* NOT REACHED */ |
| 1156 | exit(1); |
| 1157 | #endif |
| 1158 | } |
| 1159 | |
| 1160 | /* |
| 1161 | ** Name of days and months. |
| 1162 | */ |
| 1163 |
M
src/db.c
+3
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -33,14 +33,16 @@ | ||
| 33 | 33 | ** (3) A local checkout database named "FOSSIL" and located at the |
| 34 | 34 | ** root of the local copy of the source tree. |
| 35 | 35 | ** |
| 36 | 36 | */ |
| 37 | 37 | #include "config.h" |
| 38 | +#ifndef __MINGW32__ | |
| 39 | +# include <pwd.h> | |
| 40 | +#endif | |
| 38 | 41 | #include <sqlite3.h> |
| 39 | 42 | #include <sys/types.h> |
| 40 | 43 | #include <sys/stat.h> |
| 41 | -#include <pwd.h> | |
| 42 | 44 | #include <unistd.h> |
| 43 | 45 | #include "db.h" |
| 44 | 46 | |
| 45 | 47 | #if INTERFACE |
| 46 | 48 | /* |
| 47 | 49 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -33,14 +33,16 @@ | |
| 33 | ** (3) A local checkout database named "FOSSIL" and located at the |
| 34 | ** root of the local copy of the source tree. |
| 35 | ** |
| 36 | */ |
| 37 | #include "config.h" |
| 38 | #include <sqlite3.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | #include <pwd.h> |
| 42 | #include <unistd.h> |
| 43 | #include "db.h" |
| 44 | |
| 45 | #if INTERFACE |
| 46 | /* |
| 47 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -33,14 +33,16 @@ | |
| 33 | ** (3) A local checkout database named "FOSSIL" and located at the |
| 34 | ** root of the local copy of the source tree. |
| 35 | ** |
| 36 | */ |
| 37 | #include "config.h" |
| 38 | #ifndef __MINGW32__ |
| 39 | # include <pwd.h> |
| 40 | #endif |
| 41 | #include <sqlite3.h> |
| 42 | #include <sys/types.h> |
| 43 | #include <sys/stat.h> |
| 44 | #include <unistd.h> |
| 45 | #include "db.h" |
| 46 | |
| 47 | #if INTERFACE |
| 48 | /* |
| 49 |
+4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -105,11 +105,15 @@ | ||
| 105 | 105 | if( rc==2 ){ |
| 106 | 106 | if( !forceFlag ) return 1; |
| 107 | 107 | unlink(zName); |
| 108 | 108 | } |
| 109 | 109 | if( rc!=1 ){ |
| 110 | +#ifdef __MINGW32__ | |
| 111 | + return mkdir(zName); | |
| 112 | +#else | |
| 110 | 113 | return mkdir(zName, 0755); |
| 114 | +#endif | |
| 111 | 115 | } |
| 112 | 116 | return 0; |
| 113 | 117 | } |
| 114 | 118 | |
| 115 | 119 | /* |
| 116 | 120 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -105,11 +105,15 @@ | |
| 105 | if( rc==2 ){ |
| 106 | if( !forceFlag ) return 1; |
| 107 | unlink(zName); |
| 108 | } |
| 109 | if( rc!=1 ){ |
| 110 | return mkdir(zName, 0755); |
| 111 | } |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | /* |
| 116 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -105,11 +105,15 @@ | |
| 105 | if( rc==2 ){ |
| 106 | if( !forceFlag ) return 1; |
| 107 | unlink(zName); |
| 108 | } |
| 109 | if( rc!=1 ){ |
| 110 | #ifdef __MINGW32__ |
| 111 | return mkdir(zName); |
| 112 | #else |
| 113 | return mkdir(zName, 0755); |
| 114 | #endif |
| 115 | } |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 |
+11
-4
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -23,16 +23,21 @@ | ||
| 23 | 23 | ** |
| 24 | 24 | ** This file contains code that implements the client-side HTTP protocol |
| 25 | 25 | */ |
| 26 | 26 | #include "config.h" |
| 27 | 27 | #include "http.h" |
| 28 | +#ifdef __MINGW32__ | |
| 29 | +# include <windows.h> | |
| 30 | +# include <winsock.h> | |
| 31 | +#else | |
| 32 | +# include <arpa/inet.h> | |
| 33 | +# include <sys/socket.h> | |
| 34 | +# include <netdb.h> | |
| 35 | +# include <netinet/in.h> | |
| 36 | +#endif | |
| 28 | 37 | #include <assert.h> |
| 29 | -#include <arpa/inet.h> | |
| 30 | 38 | #include <sys/types.h> |
| 31 | -#include <sys/socket.h> | |
| 32 | -#include <netdb.h> | |
| 33 | -#include <netinet/in.h> | |
| 34 | 39 | #include <signal.h> |
| 35 | 40 | |
| 36 | 41 | /* |
| 37 | 42 | ** Persistent information about the HTTP connection. |
| 38 | 43 | */ |
| @@ -77,11 +82,13 @@ | ||
| 77 | 82 | } |
| 78 | 83 | if( connect(s,(struct sockaddr*)&addr,sizeof(addr))<0 ){ |
| 79 | 84 | fossil_panic("cannot connect to host %s:%d", g.urlName, g.urlPort); |
| 80 | 85 | } |
| 81 | 86 | pSocket = fdopen(s,"r+"); |
| 87 | +#ifndef __MINGW32__ | |
| 82 | 88 | signal(SIGPIPE, SIG_IGN); |
| 89 | +#endif | |
| 83 | 90 | return 0; |
| 84 | 91 | } |
| 85 | 92 | |
| 86 | 93 | /* |
| 87 | 94 | ** Make a single attempt to talk to the server. Return TRUE on success |
| 88 | 95 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -23,16 +23,21 @@ | |
| 23 | ** |
| 24 | ** This file contains code that implements the client-side HTTP protocol |
| 25 | */ |
| 26 | #include "config.h" |
| 27 | #include "http.h" |
| 28 | #include <assert.h> |
| 29 | #include <arpa/inet.h> |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/socket.h> |
| 32 | #include <netdb.h> |
| 33 | #include <netinet/in.h> |
| 34 | #include <signal.h> |
| 35 | |
| 36 | /* |
| 37 | ** Persistent information about the HTTP connection. |
| 38 | */ |
| @@ -77,11 +82,13 @@ | |
| 77 | } |
| 78 | if( connect(s,(struct sockaddr*)&addr,sizeof(addr))<0 ){ |
| 79 | fossil_panic("cannot connect to host %s:%d", g.urlName, g.urlPort); |
| 80 | } |
| 81 | pSocket = fdopen(s,"r+"); |
| 82 | signal(SIGPIPE, SIG_IGN); |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | ** Make a single attempt to talk to the server. Return TRUE on success |
| 88 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -23,16 +23,21 @@ | |
| 23 | ** |
| 24 | ** This file contains code that implements the client-side HTTP protocol |
| 25 | */ |
| 26 | #include "config.h" |
| 27 | #include "http.h" |
| 28 | #ifdef __MINGW32__ |
| 29 | # include <windows.h> |
| 30 | # include <winsock.h> |
| 31 | #else |
| 32 | # include <arpa/inet.h> |
| 33 | # include <sys/socket.h> |
| 34 | # include <netdb.h> |
| 35 | # include <netinet/in.h> |
| 36 | #endif |
| 37 | #include <assert.h> |
| 38 | #include <sys/types.h> |
| 39 | #include <signal.h> |
| 40 | |
| 41 | /* |
| 42 | ** Persistent information about the HTTP connection. |
| 43 | */ |
| @@ -77,11 +82,13 @@ | |
| 82 | } |
| 83 | if( connect(s,(struct sockaddr*)&addr,sizeof(addr))<0 ){ |
| 84 | fossil_panic("cannot connect to host %s:%d", g.urlName, g.urlPort); |
| 85 | } |
| 86 | pSocket = fdopen(s,"r+"); |
| 87 | #ifndef __MINGW32__ |
| 88 | signal(SIGPIPE, SIG_IGN); |
| 89 | #endif |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | ** Make a single attempt to talk to the server. Return TRUE on success |
| 95 |
+4
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -44,10 +44,14 @@ | ||
| 44 | 44 | ** logs and downloading diffs of very version of the archive that |
| 45 | 45 | ** has ever existed, and things like that. |
| 46 | 46 | */ |
| 47 | 47 | #include "config.h" |
| 48 | 48 | #include "login.h" |
| 49 | +#ifdef __MINGW32__ | |
| 50 | +# include <windows.h> /* for Sleep */ | |
| 51 | +# define sleep Sleep /* windows does not have sleep, but Sleep */ | |
| 52 | +#endif | |
| 49 | 53 | #include <time.h> |
| 50 | 54 | |
| 51 | 55 | /* |
| 52 | 56 | ** Return the name of the login cookie |
| 53 | 57 | */ |
| 54 | 58 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -44,10 +44,14 @@ | |
| 44 | ** logs and downloading diffs of very version of the archive that |
| 45 | ** has ever existed, and things like that. |
| 46 | */ |
| 47 | #include "config.h" |
| 48 | #include "login.h" |
| 49 | #include <time.h> |
| 50 | |
| 51 | /* |
| 52 | ** Return the name of the login cookie |
| 53 | */ |
| 54 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -44,10 +44,14 @@ | |
| 44 | ** logs and downloading diffs of very version of the archive that |
| 45 | ** has ever existed, and things like that. |
| 46 | */ |
| 47 | #include "config.h" |
| 48 | #include "login.h" |
| 49 | #ifdef __MINGW32__ |
| 50 | # include <windows.h> /* for Sleep */ |
| 51 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 52 | #endif |
| 53 | #include <time.h> |
| 54 | |
| 55 | /* |
| 56 | ** Return the name of the login cookie |
| 57 | */ |
| 58 |
+40
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -44,10 +44,50 @@ | ||
| 44 | 44 | } |
| 45 | 45 | if( z[i]<' ' ) z[i] = ' '; |
| 46 | 46 | } |
| 47 | 47 | blob_append(pBlob, z, -1); |
| 48 | 48 | } |
| 49 | + | |
| 50 | +#ifdef __MINGW32__ | |
| 51 | +/* | |
| 52 | +** getpass for Windows | |
| 53 | +*/ | |
| 54 | +static char *getpass(const char *prompt){ | |
| 55 | + static char pwd[64]; | |
| 56 | + size_t i; | |
| 57 | + | |
| 58 | + fputs(prompt,stderr); | |
| 59 | + fflush(stderr); | |
| 60 | + for(i=0; i<sizeof(pwd)-1; ++i){ | |
| 61 | + pwd[i] = _getch(); | |
| 62 | + if(pwd[i]=='\r' || pwd[i]=='\n'){ | |
| 63 | + break; | |
| 64 | + } | |
| 65 | + /* BS or DEL */ | |
| 66 | + else if(i>0 && (pwd[i]==8 || pwd[i]==127)){ | |
| 67 | + i -= 2; | |
| 68 | + continue; | |
| 69 | + } | |
| 70 | + /* CTRL-C */ | |
| 71 | + else if(pwd[i]==3) { | |
| 72 | + i=0; | |
| 73 | + break; | |
| 74 | + } | |
| 75 | + /* ESC */ | |
| 76 | + else if(pwd[i]==27){ | |
| 77 | + i=0; | |
| 78 | + break; | |
| 79 | + } | |
| 80 | + else{ | |
| 81 | + fputc('*',stderr); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + pwd[i]='\0'; | |
| 85 | + fputs("\n", stderr); | |
| 86 | + return pwd; | |
| 87 | +} | |
| 88 | +#endif | |
| 49 | 89 | |
| 50 | 90 | /* |
| 51 | 91 | ** Do a single prompt for a passphrase. Store the results in the blob. |
| 52 | 92 | */ |
| 53 | 93 | static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){ |
| 54 | 94 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -44,10 +44,50 @@ | |
| 44 | } |
| 45 | if( z[i]<' ' ) z[i] = ' '; |
| 46 | } |
| 47 | blob_append(pBlob, z, -1); |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | ** Do a single prompt for a passphrase. Store the results in the blob. |
| 52 | */ |
| 53 | static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){ |
| 54 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -44,10 +44,50 @@ | |
| 44 | } |
| 45 | if( z[i]<' ' ) z[i] = ' '; |
| 46 | } |
| 47 | blob_append(pBlob, z, -1); |
| 48 | } |
| 49 | |
| 50 | #ifdef __MINGW32__ |
| 51 | /* |
| 52 | ** getpass for Windows |
| 53 | */ |
| 54 | static char *getpass(const char *prompt){ |
| 55 | static char pwd[64]; |
| 56 | size_t i; |
| 57 | |
| 58 | fputs(prompt,stderr); |
| 59 | fflush(stderr); |
| 60 | for(i=0; i<sizeof(pwd)-1; ++i){ |
| 61 | pwd[i] = _getch(); |
| 62 | if(pwd[i]=='\r' || pwd[i]=='\n'){ |
| 63 | break; |
| 64 | } |
| 65 | /* BS or DEL */ |
| 66 | else if(i>0 && (pwd[i]==8 || pwd[i]==127)){ |
| 67 | i -= 2; |
| 68 | continue; |
| 69 | } |
| 70 | /* CTRL-C */ |
| 71 | else if(pwd[i]==3) { |
| 72 | i=0; |
| 73 | break; |
| 74 | } |
| 75 | /* ESC */ |
| 76 | else if(pwd[i]==27){ |
| 77 | i=0; |
| 78 | break; |
| 79 | } |
| 80 | else{ |
| 81 | fputc('*',stderr); |
| 82 | } |
| 83 | } |
| 84 | pwd[i]='\0'; |
| 85 | fputs("\n", stderr); |
| 86 | return pwd; |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | /* |
| 91 | ** Do a single prompt for a passphrase. Store the results in the blob. |
| 92 | */ |
| 93 | static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){ |
| 94 |