Fossil SCM

Win32 port: compiles, all tests pass but many functions fail due to path separators. Incomplete. Path fixes to come next

anonymous 2007-09-21 21:53 trunk
Commit 83c876b44708a2a5c7380645814ea218cbbaf4ab
+5 -2
--- Makefile
+++ Makefile
@@ -24,19 +24,22 @@
2424
# the finished binary for fossil. The BCC compiler above is used
2525
# for building intermediate code-generator tools.
2626
#
2727
#TCC = gcc -O6
2828
#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
3031
3132
#### Extra arguments for linking the finished binary. Fossil needs
3233
# to link against the Z-Lib compression library. There are no
3334
# other dependencies. We sometimes add the -static option here
3435
# so that we can build a static executable that will run in a
3536
# chroot jail.
3637
#
37
-LIB = -lz
38
+#LIB = -lz
39
+LIB = -lz -lwsock32
40
+
3841
3942
#### Tcl shell for use in running the fossil testsuite.
4043
#
4144
TCLSH = tclsh
4245
4346
--- 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 @@
2626
** dispensing QUERY_STRING parameters and cookies, the "mprintf()"
2727
** formatting function and its cousins, and routines to encode and
2828
** decode strings in HTML or HTTP.
2929
*/
3030
#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
3444
#include <time.h>
35
-#include <sys/times.h>
36
-#include <sys/time.h>
37
-#include <sys/wait.h>
3845
#include <stdio.h>
3946
#include <stdlib.h>
40
-#include <sys/select.h>
4147
#include <unistd.h>
4248
#include "cgi.h"
4349
4450
#if INTERFACE
4551
/*
@@ -1076,10 +1082,14 @@
10761082
** As new connections arrive, fork a child and let child return
10771083
** out of this procedure call. The child will handle the request.
10781084
** The parent never returns from this procedure.
10791085
*/
10801086
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
10811091
int listener; /* The server socket */
10821092
int connection; /* A socket for each individual connection */
10831093
fd_set readfds; /* Set of file descriptors for select() */
10841094
size_t lenaddr; /* Length of the inaddr structure */
10851095
int child; /* PID of the child process */
@@ -1142,10 +1152,11 @@
11421152
nchildren--;
11431153
}
11441154
}
11451155
/* NOT REACHED */
11461156
exit(1);
1157
+#endif
11471158
}
11481159
11491160
/*
11501161
** Name of days and months.
11511162
*/
11521163
--- 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
+3 -1
--- src/db.c
+++ src/db.c
@@ -33,14 +33,16 @@
3333
** (3) A local checkout database named "FOSSIL" and located at the
3434
** root of the local copy of the source tree.
3535
**
3636
*/
3737
#include "config.h"
38
+#ifndef __MINGW32__
39
+# include <pwd.h>
40
+#endif
3841
#include <sqlite3.h>
3942
#include <sys/types.h>
4043
#include <sys/stat.h>
41
-#include <pwd.h>
4244
#include <unistd.h>
4345
#include "db.h"
4446
4547
#if INTERFACE
4648
/*
4749
--- 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 @@
105105
if( rc==2 ){
106106
if( !forceFlag ) return 1;
107107
unlink(zName);
108108
}
109109
if( rc!=1 ){
110
+#ifdef __MINGW32__
111
+ return mkdir(zName);
112
+#else
110113
return mkdir(zName, 0755);
114
+#endif
111115
}
112116
return 0;
113117
}
114118
115119
/*
116120
--- 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 @@
2323
**
2424
** This file contains code that implements the client-side HTTP protocol
2525
*/
2626
#include "config.h"
2727
#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
2837
#include <assert.h>
29
-#include <arpa/inet.h>
3038
#include <sys/types.h>
31
-#include <sys/socket.h>
32
-#include <netdb.h>
33
-#include <netinet/in.h>
3439
#include <signal.h>
3540
3641
/*
3742
** Persistent information about the HTTP connection.
3843
*/
@@ -77,11 +82,13 @@
7782
}
7883
if( connect(s,(struct sockaddr*)&addr,sizeof(addr))<0 ){
7984
fossil_panic("cannot connect to host %s:%d", g.urlName, g.urlPort);
8085
}
8186
pSocket = fdopen(s,"r+");
87
+#ifndef __MINGW32__
8288
signal(SIGPIPE, SIG_IGN);
89
+#endif
8390
return 0;
8491
}
8592
8693
/*
8794
** Make a single attempt to talk to the server. Return TRUE on success
8895
--- 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
--- src/login.c
+++ src/login.c
@@ -44,10 +44,14 @@
4444
** logs and downloading diffs of very version of the archive that
4545
** has ever existed, and things like that.
4646
*/
4747
#include "config.h"
4848
#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
4953
#include <time.h>
5054
5155
/*
5256
** Return the name of the login cookie
5357
*/
5458
--- 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 @@
4444
}
4545
if( z[i]<' ' ) z[i] = ' ';
4646
}
4747
blob_append(pBlob, z, -1);
4848
}
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
4989
5090
/*
5191
** Do a single prompt for a passphrase. Store the results in the blob.
5292
*/
5393
static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){
5494
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button