| | @@ -35,10 +35,11 @@ |
| 35 | 35 | i64 nSent; /* Number of bytes sent */ |
| 36 | 36 | i64 nRcvd; /* Number of bytes received */ |
| 37 | 37 | FILE *pFile; /* File I/O for FILE: */ |
| 38 | 38 | char *zOutFile; /* Name of outbound file for FILE: */ |
| 39 | 39 | char *zInFile; /* Name of inbound file for FILE: */ |
| 40 | + FILE *pLog; /* Log output here */ |
| 40 | 41 | } transport = { |
| 41 | 42 | 0, 0, 0, 0, 0, 0, 0 |
| 42 | 43 | }; |
| 43 | 44 | |
| 44 | 45 | /* |
| | @@ -226,10 +227,14 @@ |
| 226 | 227 | free(transport.pBuf); |
| 227 | 228 | transport.pBuf = 0; |
| 228 | 229 | transport.nAlloc = 0; |
| 229 | 230 | transport.nUsed = 0; |
| 230 | 231 | transport.iCursor = 0; |
| 232 | + if( transport.pLog ){ |
| 233 | + fclose(transport.pLog); |
| 234 | + transport.pLog = 0; |
| 235 | + } |
| 231 | 236 | if( g.urlIsSsh ){ |
| 232 | 237 | /* No-op */ |
| 233 | 238 | }else if( g.urlIsHttps ){ |
| 234 | 239 | #ifdef FOSSIL_ENABLE_SSL |
| 235 | 240 | ssl_close(); |
| | @@ -301,10 +306,22 @@ |
| 301 | 306 | fossil_system(zCmd); |
| 302 | 307 | free(zCmd); |
| 303 | 308 | transport.pFile = fopen(transport.zInFile, "rb"); |
| 304 | 309 | } |
| 305 | 310 | } |
| 311 | + |
| 312 | +/* |
| 313 | +** Log all input to a file. The transport layer will take responsibility |
| 314 | +** for closing the log file when it is done. |
| 315 | +*/ |
| 316 | +void transport_log(FILE *pLog){ |
| 317 | + if( transport.pLog ){ |
| 318 | + fclose(transport.pLog); |
| 319 | + transport.pLog = 0; |
| 320 | + } |
| 321 | + transport.pLog = pLog; |
| 322 | +} |
| 306 | 323 | |
| 307 | 324 | /* |
| 308 | 325 | ** This routine is called when the inbound message has been received |
| 309 | 326 | ** and it is time to start sending again. |
| 310 | 327 | */ |
| | @@ -340,10 +357,14 @@ |
| 340 | 357 | got = fread(zBuf, 1, N, transport.pFile); |
| 341 | 358 | }else{ |
| 342 | 359 | got = socket_receive(0, zBuf, N); |
| 343 | 360 | } |
| 344 | 361 | /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */ |
| 362 | + if( transport.pLog ){ |
| 363 | + fwrite(zBuf, 1, got, transport.pLog); |
| 364 | + fflush(transport.pLog); |
| 365 | + } |
| 345 | 366 | return got; |
| 346 | 367 | } |
| 347 | 368 | |
| 348 | 369 | /* |
| 349 | 370 | ** Read N bytes of content from the wire and store in the supplied buffer. |
| 350 | 371 | |