Fossil SCM

Continuing work on the new HTTP transport mechanism. Make it more obvious where in the code extensions to support file: and https: belong.

drh 2009-03-30 00:58 trunk
Commit 327823e39bd363be157a9d32718ff7994d092220
--- src/configure.c
+++ src/configure.c
@@ -453,13 +453,10 @@
453453
if( zServer==0 ){
454454
fossil_fatal("no server specified");
455455
}
456456
}
457457
url_parse(zServer);
458
- if( g.urlIsFile ){
459
- fossil_fatal("network sync only");
460
- }
461458
user_select();
462459
if( strncmp(zMethod, "push", n)==0 ){
463460
client_sync(0,0,0,0,mask);
464461
}else{
465462
client_sync(0,0,0,mask,0);
466463
--- src/configure.c
+++ src/configure.c
@@ -453,13 +453,10 @@
453 if( zServer==0 ){
454 fossil_fatal("no server specified");
455 }
456 }
457 url_parse(zServer);
458 if( g.urlIsFile ){
459 fossil_fatal("network sync only");
460 }
461 user_select();
462 if( strncmp(zMethod, "push", n)==0 ){
463 client_sync(0,0,0,0,mask);
464 }else{
465 client_sync(0,0,0,mask,0);
466
--- src/configure.c
+++ src/configure.c
@@ -453,13 +453,10 @@
453 if( zServer==0 ){
454 fossil_fatal("no server specified");
455 }
456 }
457 url_parse(zServer);
 
 
 
458 user_select();
459 if( strncmp(zMethod, "push", n)==0 ){
460 client_sync(0,0,0,0,mask);
461 }else{
462 client_sync(0,0,0,mask,0);
463
--- src/http_transport.c
+++ src/http_transport.c
@@ -37,11 +37,11 @@
3737
char *pBuf; /* Buffer used to hold the reply */
3838
int nAlloc; /* Space allocated for transportBuf[] */
3939
int nUsed ; /* Space of transportBuf[] used */
4040
int iCursor; /* Next unread by in transportBuf[] */
4141
} transport = {
42
- 0, 0, 0, 0
42
+ 0, 0, 0, 0, 0
4343
};
4444
4545
/*
4646
** Return the current transport error message.
4747
*/
@@ -59,45 +59,63 @@
5959
**
6060
** Return the number of errors.
6161
*/
6262
int transport_open(void){
6363
int rc = 0;
64
- if( g.urlIsHttps ){
65
- socket_set_errmsg("TLS is not yet implemented");
66
- rc = 1;
67
- }else{
68
- rc = socket_open();
69
- if( rc==0 ) transport.isOpen = 1;
64
+ if( transport.isOpen==0 ){
65
+ if( g.urlIsHttps ){
66
+ socket_set_errmsg("HTTPS: is not yet implemented");
67
+ rc = 1;
68
+ }else if( g.urlIsFile ){
69
+ socket_set_errmsg("FILE: is not yet implemented");
70
+ rc = 1;
71
+ }else{
72
+ rc = socket_open();
73
+ if( rc==0 ) transport.isOpen = 1;
74
+ }
7075
}
7176
return rc;
7277
}
7378
7479
/*
7580
** Close the current connection
7681
*/
7782
void transport_close(void){
7883
if( transport.isOpen ){
79
- socket_close();
8084
free(transport.pBuf);
8185
transport.pBuf = 0;
8286
transport.nAlloc = 0;
8387
transport.nUsed = 0;
8488
transport.iCursor = 0;
89
+ if( g.urlIsHttps ){
90
+ /* TBD */
91
+ }else if( g.urlIsFile ){
92
+ /* TBD */
93
+ }else{
94
+ socket_close();
95
+ }
96
+ transport.isOpen = 0;
8597
}
8698
}
8799
88100
/*
89101
** Send content over the wire.
90102
*/
91103
void transport_send(Blob *toSend){
92
- char *z = blob_buffer(toSend);
93
- int n = blob_size(toSend);
94
- int sent;
95
- while( n>0 ){
96
- sent = socket_send(0, z, n);
97
- if( sent<=0 ) break;
98
- n -= sent;
104
+ if( g.urlIsHttps ){
105
+ /* TBD */
106
+ }else if( g.urlIsFile ){
107
+ /* TBD */
108
+ }else{
109
+ char *z = blob_buffer(toSend);
110
+ int n = blob_size(toSend);
111
+ int sent;
112
+ while( n>0 ){
113
+ sent = socket_send(0, z, n);
114
+ if( sent<=0 ) break;
115
+ n -= sent;
116
+ }
99117
}
100118
}
101119
102120
/*
103121
** Read N bytes of content from the wire and store in the supplied buffer.
@@ -120,11 +138,20 @@
120138
N -= toMove;
121139
zBuf += toMove;
122140
nByte += toMove;
123141
}
124142
if( N>0 ){
125
- int got = socket_receive(0, zBuf, N);
143
+ int got;
144
+ if( g.urlIsHttps ){
145
+ /* TBD */
146
+ got = 0;
147
+ }else if( g.urlIsFile ){
148
+ /* TBD */
149
+ got = 0;
150
+ }else{
151
+ got = socket_receive(0, zBuf, N);
152
+ }
126153
if( got>0 ){
127154
nByte += got;
128155
}
129156
}
130157
return nByte;
131158
--- src/http_transport.c
+++ src/http_transport.c
@@ -37,11 +37,11 @@
37 char *pBuf; /* Buffer used to hold the reply */
38 int nAlloc; /* Space allocated for transportBuf[] */
39 int nUsed ; /* Space of transportBuf[] used */
40 int iCursor; /* Next unread by in transportBuf[] */
41 } transport = {
42 0, 0, 0, 0
43 };
44
45 /*
46 ** Return the current transport error message.
47 */
@@ -59,45 +59,63 @@
59 **
60 ** Return the number of errors.
61 */
62 int transport_open(void){
63 int rc = 0;
64 if( g.urlIsHttps ){
65 socket_set_errmsg("TLS is not yet implemented");
66 rc = 1;
67 }else{
68 rc = socket_open();
69 if( rc==0 ) transport.isOpen = 1;
 
 
 
 
 
70 }
71 return rc;
72 }
73
74 /*
75 ** Close the current connection
76 */
77 void transport_close(void){
78 if( transport.isOpen ){
79 socket_close();
80 free(transport.pBuf);
81 transport.pBuf = 0;
82 transport.nAlloc = 0;
83 transport.nUsed = 0;
84 transport.iCursor = 0;
 
 
 
 
 
 
 
 
85 }
86 }
87
88 /*
89 ** Send content over the wire.
90 */
91 void transport_send(Blob *toSend){
92 char *z = blob_buffer(toSend);
93 int n = blob_size(toSend);
94 int sent;
95 while( n>0 ){
96 sent = socket_send(0, z, n);
97 if( sent<=0 ) break;
98 n -= sent;
 
 
 
 
 
 
99 }
100 }
101
102 /*
103 ** Read N bytes of content from the wire and store in the supplied buffer.
@@ -120,11 +138,20 @@
120 N -= toMove;
121 zBuf += toMove;
122 nByte += toMove;
123 }
124 if( N>0 ){
125 int got = socket_receive(0, zBuf, N);
 
 
 
 
 
 
 
 
 
126 if( got>0 ){
127 nByte += got;
128 }
129 }
130 return nByte;
131
--- src/http_transport.c
+++ src/http_transport.c
@@ -37,11 +37,11 @@
37 char *pBuf; /* Buffer used to hold the reply */
38 int nAlloc; /* Space allocated for transportBuf[] */
39 int nUsed ; /* Space of transportBuf[] used */
40 int iCursor; /* Next unread by in transportBuf[] */
41 } transport = {
42 0, 0, 0, 0, 0
43 };
44
45 /*
46 ** Return the current transport error message.
47 */
@@ -59,45 +59,63 @@
59 **
60 ** Return the number of errors.
61 */
62 int transport_open(void){
63 int rc = 0;
64 if( transport.isOpen==0 ){
65 if( g.urlIsHttps ){
66 socket_set_errmsg("HTTPS: is not yet implemented");
67 rc = 1;
68 }else if( g.urlIsFile ){
69 socket_set_errmsg("FILE: is not yet implemented");
70 rc = 1;
71 }else{
72 rc = socket_open();
73 if( rc==0 ) transport.isOpen = 1;
74 }
75 }
76 return rc;
77 }
78
79 /*
80 ** Close the current connection
81 */
82 void transport_close(void){
83 if( transport.isOpen ){
 
84 free(transport.pBuf);
85 transport.pBuf = 0;
86 transport.nAlloc = 0;
87 transport.nUsed = 0;
88 transport.iCursor = 0;
89 if( g.urlIsHttps ){
90 /* TBD */
91 }else if( g.urlIsFile ){
92 /* TBD */
93 }else{
94 socket_close();
95 }
96 transport.isOpen = 0;
97 }
98 }
99
100 /*
101 ** Send content over the wire.
102 */
103 void transport_send(Blob *toSend){
104 if( g.urlIsHttps ){
105 /* TBD */
106 }else if( g.urlIsFile ){
107 /* TBD */
108 }else{
109 char *z = blob_buffer(toSend);
110 int n = blob_size(toSend);
111 int sent;
112 while( n>0 ){
113 sent = socket_send(0, z, n);
114 if( sent<=0 ) break;
115 n -= sent;
116 }
117 }
118 }
119
120 /*
121 ** Read N bytes of content from the wire and store in the supplied buffer.
@@ -120,11 +138,20 @@
138 N -= toMove;
139 zBuf += toMove;
140 nByte += toMove;
141 }
142 if( N>0 ){
143 int got;
144 if( g.urlIsHttps ){
145 /* TBD */
146 got = 0;
147 }else if( g.urlIsFile ){
148 /* TBD */
149 got = 0;
150 }else{
151 got = socket_receive(0, zBuf, N);
152 }
153 if( got>0 ){
154 nByte += got;
155 }
156 }
157 return nByte;
158
-6
--- src/sync.c
+++ src/sync.c
@@ -52,13 +52,10 @@
5252
zUrl = db_get("last-sync-url", 0);
5353
if( zUrl==0 ){
5454
return; /* No default server */
5555
}
5656
url_parse(zUrl);
57
- if( g.urlIsFile ){
58
- return; /* Network sync only */
59
- }
6057
if( g.urlPort!=g.urlDfltPort ){
6158
printf("Autosync: %s://%s:%d%s\n",
6259
g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
6360
}else{
6461
printf("Autosync: %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
@@ -86,13 +83,10 @@
8683
if( zUrl==0 ){
8784
if( urlOptional ) exit(0);
8885
usage("URL");
8986
}
9087
url_parse(zUrl);
91
- if( g.urlIsFile ){
92
- fossil_fatal("network sync only");
93
- }
9488
db_set("last-sync-url", zUrl, 0);
9589
user_select();
9690
if( g.argc==2 ){
9791
if( g.urlPort!=g.urlDfltPort ){
9892
printf("Server: %s://%s:%d%s\n",
9993
--- src/sync.c
+++ src/sync.c
@@ -52,13 +52,10 @@
52 zUrl = db_get("last-sync-url", 0);
53 if( zUrl==0 ){
54 return; /* No default server */
55 }
56 url_parse(zUrl);
57 if( g.urlIsFile ){
58 return; /* Network sync only */
59 }
60 if( g.urlPort!=g.urlDfltPort ){
61 printf("Autosync: %s://%s:%d%s\n",
62 g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
63 }else{
64 printf("Autosync: %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
@@ -86,13 +83,10 @@
86 if( zUrl==0 ){
87 if( urlOptional ) exit(0);
88 usage("URL");
89 }
90 url_parse(zUrl);
91 if( g.urlIsFile ){
92 fossil_fatal("network sync only");
93 }
94 db_set("last-sync-url", zUrl, 0);
95 user_select();
96 if( g.argc==2 ){
97 if( g.urlPort!=g.urlDfltPort ){
98 printf("Server: %s://%s:%d%s\n",
99
--- src/sync.c
+++ src/sync.c
@@ -52,13 +52,10 @@
52 zUrl = db_get("last-sync-url", 0);
53 if( zUrl==0 ){
54 return; /* No default server */
55 }
56 url_parse(zUrl);
 
 
 
57 if( g.urlPort!=g.urlDfltPort ){
58 printf("Autosync: %s://%s:%d%s\n",
59 g.urlProtocol, g.urlName, g.urlPort, g.urlPath);
60 }else{
61 printf("Autosync: %s://%s%s\n", g.urlProtocol, g.urlName, g.urlPath);
@@ -86,13 +83,10 @@
83 if( zUrl==0 ){
84 if( urlOptional ) exit(0);
85 usage("URL");
86 }
87 url_parse(zUrl);
 
 
 
88 db_set("last-sync-url", zUrl, 0);
89 user_select();
90 if( g.argc==2 ){
91 if( g.urlPort!=g.urlDfltPort ){
92 printf("Server: %s://%s:%d%s\n",
93
-2
--- src/xfer.c
+++ src/xfer.c
@@ -876,12 +876,10 @@
876876
xfer.pIn = &recv;
877877
xfer.pOut = &send;
878878
xfer.mxSend = db_get_int("max-upload", 250000);
879879
880880
assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
881
- assert( !g.urlIsFile ); /* This only works for networking */
882
-
883881
db_begin_transaction();
884882
db_record_repository_filename(0);
885883
db_multi_exec(
886884
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
887885
);
888886
--- src/xfer.c
+++ src/xfer.c
@@ -876,12 +876,10 @@
876 xfer.pIn = &recv;
877 xfer.pOut = &send;
878 xfer.mxSend = db_get_int("max-upload", 250000);
879
880 assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
881 assert( !g.urlIsFile ); /* This only works for networking */
882
883 db_begin_transaction();
884 db_record_repository_filename(0);
885 db_multi_exec(
886 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
887 );
888
--- src/xfer.c
+++ src/xfer.c
@@ -876,12 +876,10 @@
876 xfer.pIn = &recv;
877 xfer.pOut = &send;
878 xfer.mxSend = db_get_int("max-upload", 250000);
879
880 assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
 
 
881 db_begin_transaction();
882 db_record_repository_filename(0);
883 db_multi_exec(
884 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
885 );
886

Keyboard Shortcuts

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