Fossil SCM
Infrastructure changes that will allow the client-side sync to be run from a web interface - the status messages now go to CGI output if the sync is run from a web page. This is a partial implementation of the "SyncNow" button. The button itself has not yet been added.
Commit
c56af61e5e40db613bd649b676ce72810367435d
Parent
f7ec914037f76c9…
7 files changed
+2
-2
+6
-1
+10
-10
+15
+1
-1
+1
-1
+11
-11
M
src/db.c
+2
-2
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -76,12 +76,12 @@ | ||
| 76 | 76 | if( g.xferPanic ){ |
| 77 | 77 | cgi_reset_content(); |
| 78 | 78 | @ error Database\serror:\s%F(z) |
| 79 | 79 | cgi_reply(); |
| 80 | 80 | } |
| 81 | - if( g.cgiPanic ){ | |
| 82 | - g.cgiPanic = 0; | |
| 81 | + if( g.cgiOutput ){ | |
| 82 | + g.cgiOutput = 0; | |
| 83 | 83 | cgi_printf("<h1>Database Error</h1>\n" |
| 84 | 84 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 85 | 85 | cgi_reply(); |
| 86 | 86 | }else{ |
| 87 | 87 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 88 | 88 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -76,12 +76,12 @@ | |
| 76 | if( g.xferPanic ){ |
| 77 | cgi_reset_content(); |
| 78 | @ error Database\serror:\s%F(z) |
| 79 | cgi_reply(); |
| 80 | } |
| 81 | if( g.cgiPanic ){ |
| 82 | g.cgiPanic = 0; |
| 83 | cgi_printf("<h1>Database Error</h1>\n" |
| 84 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 85 | cgi_reply(); |
| 86 | }else{ |
| 87 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 88 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -76,12 +76,12 @@ | |
| 76 | if( g.xferPanic ){ |
| 77 | cgi_reset_content(); |
| 78 | @ error Database\serror:\s%F(z) |
| 79 | cgi_reply(); |
| 80 | } |
| 81 | if( g.cgiOutput ){ |
| 82 | g.cgiOutput = 0; |
| 83 | cgi_printf("<h1>Database Error</h1>\n" |
| 84 | "<pre>%h</pre><p>%s</p>", z, zRebuildMsg); |
| 85 | cgi_reply(); |
| 86 | }else{ |
| 87 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 88 |
+6
-1
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -55,11 +55,16 @@ | ||
| 55 | 55 | sha1sum_blob(pPayload, &nonce); |
| 56 | 56 | blob_copy(&pw, &nonce); |
| 57 | 57 | zLogin = g.urlUser; |
| 58 | 58 | if( g.urlPasswd ){ |
| 59 | 59 | zPw = g.urlPasswd; |
| 60 | + }else if( g.cgiOutput ){ | |
| 61 | + /* Password failure while doing a sync from the web interface */ | |
| 62 | + cgi_printf("*** incorrect or missing password for user %h\n", zLogin); | |
| 63 | + zPw = 0; | |
| 60 | 64 | }else{ |
| 65 | + /* Password failure while doing a sync from the command-line interface */ | |
| 61 | 66 | url_prompt_for_password(); |
| 62 | 67 | zPw = g.urlPasswd; |
| 63 | 68 | if( !g.dontKeepUrl ) db_set("last-sync-pw", zPw, 0); |
| 64 | 69 | } |
| 65 | 70 | |
| @@ -223,11 +228,11 @@ | ||
| 223 | 228 | int i, j; |
| 224 | 229 | for(i=9; zLine[i] && zLine[i]==' '; i++){} |
| 225 | 230 | if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine); |
| 226 | 231 | j = strlen(zLine) - 1; |
| 227 | 232 | if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0; |
| 228 | - printf("redirect to %s\n", &zLine[i]); | |
| 233 | + fossil_print("redirect to %s\n", &zLine[i]); | |
| 229 | 234 | url_parse(&zLine[i]); |
| 230 | 235 | transport_close(); |
| 231 | 236 | http_exchange(pSend, pReply, useLogin); |
| 232 | 237 | return; |
| 233 | 238 | } |
| 234 | 239 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -55,11 +55,16 @@ | |
| 55 | sha1sum_blob(pPayload, &nonce); |
| 56 | blob_copy(&pw, &nonce); |
| 57 | zLogin = g.urlUser; |
| 58 | if( g.urlPasswd ){ |
| 59 | zPw = g.urlPasswd; |
| 60 | }else{ |
| 61 | url_prompt_for_password(); |
| 62 | zPw = g.urlPasswd; |
| 63 | if( !g.dontKeepUrl ) db_set("last-sync-pw", zPw, 0); |
| 64 | } |
| 65 | |
| @@ -223,11 +228,11 @@ | |
| 223 | int i, j; |
| 224 | for(i=9; zLine[i] && zLine[i]==' '; i++){} |
| 225 | if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine); |
| 226 | j = strlen(zLine) - 1; |
| 227 | if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0; |
| 228 | printf("redirect to %s\n", &zLine[i]); |
| 229 | url_parse(&zLine[i]); |
| 230 | transport_close(); |
| 231 | http_exchange(pSend, pReply, useLogin); |
| 232 | return; |
| 233 | } |
| 234 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -55,11 +55,16 @@ | |
| 55 | sha1sum_blob(pPayload, &nonce); |
| 56 | blob_copy(&pw, &nonce); |
| 57 | zLogin = g.urlUser; |
| 58 | if( g.urlPasswd ){ |
| 59 | zPw = g.urlPasswd; |
| 60 | }else if( g.cgiOutput ){ |
| 61 | /* Password failure while doing a sync from the web interface */ |
| 62 | cgi_printf("*** incorrect or missing password for user %h\n", zLogin); |
| 63 | zPw = 0; |
| 64 | }else{ |
| 65 | /* Password failure while doing a sync from the command-line interface */ |
| 66 | url_prompt_for_password(); |
| 67 | zPw = g.urlPasswd; |
| 68 | if( !g.dontKeepUrl ) db_set("last-sync-pw", zPw, 0); |
| 69 | } |
| 70 | |
| @@ -223,11 +228,11 @@ | |
| 228 | int i, j; |
| 229 | for(i=9; zLine[i] && zLine[i]==' '; i++){} |
| 230 | if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine); |
| 231 | j = strlen(zLine) - 1; |
| 232 | if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0; |
| 233 | fossil_print("redirect to %s\n", &zLine[i]); |
| 234 | url_parse(&zLine[i]); |
| 235 | transport_close(); |
| 236 | http_exchange(pSend, pReply, useLogin); |
| 237 | return; |
| 238 | } |
| 239 |
+10
-10
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -78,11 +78,11 @@ | ||
| 78 | 78 | char *zTop; /* Parent directory of zPath */ |
| 79 | 79 | const char *zContentType; /* The content type of the input HTTP request */ |
| 80 | 80 | int iErrPriority; /* Priority of current error message */ |
| 81 | 81 | char *zErrMsg; /* Text of an error message */ |
| 82 | 82 | Blob cgiIn; /* Input to an xfer www method */ |
| 83 | - int cgiPanic; /* Write error messages to CGI */ | |
| 83 | + int cgiOutput; /* Write error and status messages to CGI */ | |
| 84 | 84 | int xferPanic; /* Write error messages in XFER protocol */ |
| 85 | 85 | int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ |
| 86 | 86 | Th_Interp *interp; /* The TH1 interpreter */ |
| 87 | 87 | FILE *httpIn; /* Accept HTTP input from here */ |
| 88 | 88 | FILE *httpOut; /* Send HTTP output here */ |
| @@ -278,11 +278,11 @@ | ||
| 278 | 278 | static int once = 1; |
| 279 | 279 | mainInFatalError = 1; |
| 280 | 280 | va_start(ap, zFormat); |
| 281 | 281 | z = vmprintf(zFormat, ap); |
| 282 | 282 | va_end(ap); |
| 283 | - if( g.cgiPanic && once ){ | |
| 283 | + if( g.cgiOutput && once ){ | |
| 284 | 284 | once = 0; |
| 285 | 285 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 286 | 286 | cgi_reply(); |
| 287 | 287 | }else{ |
| 288 | 288 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| @@ -295,12 +295,12 @@ | ||
| 295 | 295 | va_list ap; |
| 296 | 296 | mainInFatalError = 1; |
| 297 | 297 | va_start(ap, zFormat); |
| 298 | 298 | z = vmprintf(zFormat, ap); |
| 299 | 299 | va_end(ap); |
| 300 | - if( g.cgiPanic ){ | |
| 301 | - g.cgiPanic = 0; | |
| 300 | + if( g.cgiOutput ){ | |
| 301 | + g.cgiOutput = 0; | |
| 302 | 302 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 303 | 303 | cgi_reply(); |
| 304 | 304 | }else{ |
| 305 | 305 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 306 | 306 | } |
| @@ -323,12 +323,12 @@ | ||
| 323 | 323 | if( mainInFatalError ) return; |
| 324 | 324 | mainInFatalError = 1; |
| 325 | 325 | va_start(ap, zFormat); |
| 326 | 326 | z = vmprintf(zFormat, ap); |
| 327 | 327 | va_end(ap); |
| 328 | - if( g.cgiPanic ){ | |
| 329 | - g.cgiPanic = 0; | |
| 328 | + if( g.cgiOutput ){ | |
| 329 | + g.cgiOutput = 0; | |
| 330 | 330 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 331 | 331 | cgi_reply(); |
| 332 | 332 | }else{ |
| 333 | 333 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 334 | 334 | } |
| @@ -342,11 +342,11 @@ | ||
| 342 | 342 | char *z; |
| 343 | 343 | va_list ap; |
| 344 | 344 | va_start(ap, zFormat); |
| 345 | 345 | z = vmprintf(zFormat, ap); |
| 346 | 346 | va_end(ap); |
| 347 | - if( g.cgiPanic ){ | |
| 347 | + if( g.cgiOutput ){ | |
| 348 | 348 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 349 | 349 | }else{ |
| 350 | 350 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 351 | 351 | } |
| 352 | 352 | } |
| @@ -811,11 +811,11 @@ | ||
| 811 | 811 | #ifdef __EMX__ |
| 812 | 812 | /* Similar hack for OS/2 */ |
| 813 | 813 | setmode(fileno(g.httpOut), O_BINARY); |
| 814 | 814 | setmode(fileno(g.httpIn), O_BINARY); |
| 815 | 815 | #endif |
| 816 | - g.cgiPanic = 1; | |
| 816 | + g.cgiOutput = 1; | |
| 817 | 817 | blob_read_from_file(&config, zFile); |
| 818 | 818 | while( blob_line(&config, &line) ){ |
| 819 | 819 | if( !blob_token(&line, &key) ) continue; |
| 820 | 820 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 821 | 821 | if( blob_eq(&key, "debug:") && blob_token(&line, &value) ){ |
| @@ -909,11 +909,11 @@ | ||
| 909 | 909 | const char *zNotFound; |
| 910 | 910 | zNotFound = find_option("notfound", 0, 1); |
| 911 | 911 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 912 | 912 | cgi_panic("no repository specified"); |
| 913 | 913 | } |
| 914 | - g.cgiPanic = 1; | |
| 914 | + g.cgiOutput = 1; | |
| 915 | 915 | g.fullHttpReply = 1; |
| 916 | 916 | if( g.argc==6 ){ |
| 917 | 917 | g.httpIn = fopen(g.argv[3], "rb"); |
| 918 | 918 | g.httpOut = fopen(g.argv[4], "wb"); |
| 919 | 919 | zIpAddr = g.argv[5]; |
| @@ -1039,11 +1039,11 @@ | ||
| 1039 | 1039 | g.httpIn = stdin; |
| 1040 | 1040 | g.httpOut = stdout; |
| 1041 | 1041 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1042 | 1042 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1043 | 1043 | } |
| 1044 | - g.cgiPanic = 1; | |
| 1044 | + g.cgiOutput = 1; | |
| 1045 | 1045 | find_server_repository(isUiCmd); |
| 1046 | 1046 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1047 | 1047 | cgi_handle_http_request(0); |
| 1048 | 1048 | process_one_web_page(zNotFound); |
| 1049 | 1049 | #else |
| 1050 | 1050 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -78,11 +78,11 @@ | |
| 78 | char *zTop; /* Parent directory of zPath */ |
| 79 | const char *zContentType; /* The content type of the input HTTP request */ |
| 80 | int iErrPriority; /* Priority of current error message */ |
| 81 | char *zErrMsg; /* Text of an error message */ |
| 82 | Blob cgiIn; /* Input to an xfer www method */ |
| 83 | int cgiPanic; /* Write error messages to CGI */ |
| 84 | int xferPanic; /* Write error messages in XFER protocol */ |
| 85 | int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ |
| 86 | Th_Interp *interp; /* The TH1 interpreter */ |
| 87 | FILE *httpIn; /* Accept HTTP input from here */ |
| 88 | FILE *httpOut; /* Send HTTP output here */ |
| @@ -278,11 +278,11 @@ | |
| 278 | static int once = 1; |
| 279 | mainInFatalError = 1; |
| 280 | va_start(ap, zFormat); |
| 281 | z = vmprintf(zFormat, ap); |
| 282 | va_end(ap); |
| 283 | if( g.cgiPanic && once ){ |
| 284 | once = 0; |
| 285 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 286 | cgi_reply(); |
| 287 | }else{ |
| 288 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| @@ -295,12 +295,12 @@ | |
| 295 | va_list ap; |
| 296 | mainInFatalError = 1; |
| 297 | va_start(ap, zFormat); |
| 298 | z = vmprintf(zFormat, ap); |
| 299 | va_end(ap); |
| 300 | if( g.cgiPanic ){ |
| 301 | g.cgiPanic = 0; |
| 302 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 303 | cgi_reply(); |
| 304 | }else{ |
| 305 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 306 | } |
| @@ -323,12 +323,12 @@ | |
| 323 | if( mainInFatalError ) return; |
| 324 | mainInFatalError = 1; |
| 325 | va_start(ap, zFormat); |
| 326 | z = vmprintf(zFormat, ap); |
| 327 | va_end(ap); |
| 328 | if( g.cgiPanic ){ |
| 329 | g.cgiPanic = 0; |
| 330 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 331 | cgi_reply(); |
| 332 | }else{ |
| 333 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 334 | } |
| @@ -342,11 +342,11 @@ | |
| 342 | char *z; |
| 343 | va_list ap; |
| 344 | va_start(ap, zFormat); |
| 345 | z = vmprintf(zFormat, ap); |
| 346 | va_end(ap); |
| 347 | if( g.cgiPanic ){ |
| 348 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 349 | }else{ |
| 350 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 351 | } |
| 352 | } |
| @@ -811,11 +811,11 @@ | |
| 811 | #ifdef __EMX__ |
| 812 | /* Similar hack for OS/2 */ |
| 813 | setmode(fileno(g.httpOut), O_BINARY); |
| 814 | setmode(fileno(g.httpIn), O_BINARY); |
| 815 | #endif |
| 816 | g.cgiPanic = 1; |
| 817 | blob_read_from_file(&config, zFile); |
| 818 | while( blob_line(&config, &line) ){ |
| 819 | if( !blob_token(&line, &key) ) continue; |
| 820 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 821 | if( blob_eq(&key, "debug:") && blob_token(&line, &value) ){ |
| @@ -909,11 +909,11 @@ | |
| 909 | const char *zNotFound; |
| 910 | zNotFound = find_option("notfound", 0, 1); |
| 911 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 912 | cgi_panic("no repository specified"); |
| 913 | } |
| 914 | g.cgiPanic = 1; |
| 915 | g.fullHttpReply = 1; |
| 916 | if( g.argc==6 ){ |
| 917 | g.httpIn = fopen(g.argv[3], "rb"); |
| 918 | g.httpOut = fopen(g.argv[4], "wb"); |
| 919 | zIpAddr = g.argv[5]; |
| @@ -1039,11 +1039,11 @@ | |
| 1039 | g.httpIn = stdin; |
| 1040 | g.httpOut = stdout; |
| 1041 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1042 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1043 | } |
| 1044 | g.cgiPanic = 1; |
| 1045 | find_server_repository(isUiCmd); |
| 1046 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1047 | cgi_handle_http_request(0); |
| 1048 | process_one_web_page(zNotFound); |
| 1049 | #else |
| 1050 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -78,11 +78,11 @@ | |
| 78 | char *zTop; /* Parent directory of zPath */ |
| 79 | const char *zContentType; /* The content type of the input HTTP request */ |
| 80 | int iErrPriority; /* Priority of current error message */ |
| 81 | char *zErrMsg; /* Text of an error message */ |
| 82 | Blob cgiIn; /* Input to an xfer www method */ |
| 83 | int cgiOutput; /* Write error and status messages to CGI */ |
| 84 | int xferPanic; /* Write error messages in XFER protocol */ |
| 85 | int fullHttpReply; /* True for full HTTP reply. False for CGI reply */ |
| 86 | Th_Interp *interp; /* The TH1 interpreter */ |
| 87 | FILE *httpIn; /* Accept HTTP input from here */ |
| 88 | FILE *httpOut; /* Send HTTP output here */ |
| @@ -278,11 +278,11 @@ | |
| 278 | static int once = 1; |
| 279 | mainInFatalError = 1; |
| 280 | va_start(ap, zFormat); |
| 281 | z = vmprintf(zFormat, ap); |
| 282 | va_end(ap); |
| 283 | if( g.cgiOutput && once ){ |
| 284 | once = 0; |
| 285 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 286 | cgi_reply(); |
| 287 | }else{ |
| 288 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| @@ -295,12 +295,12 @@ | |
| 295 | va_list ap; |
| 296 | mainInFatalError = 1; |
| 297 | va_start(ap, zFormat); |
| 298 | z = vmprintf(zFormat, ap); |
| 299 | va_end(ap); |
| 300 | if( g.cgiOutput ){ |
| 301 | g.cgiOutput = 0; |
| 302 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 303 | cgi_reply(); |
| 304 | }else{ |
| 305 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 306 | } |
| @@ -323,12 +323,12 @@ | |
| 323 | if( mainInFatalError ) return; |
| 324 | mainInFatalError = 1; |
| 325 | va_start(ap, zFormat); |
| 326 | z = vmprintf(zFormat, ap); |
| 327 | va_end(ap); |
| 328 | if( g.cgiOutput ){ |
| 329 | g.cgiOutput = 0; |
| 330 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 331 | cgi_reply(); |
| 332 | }else{ |
| 333 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 334 | } |
| @@ -342,11 +342,11 @@ | |
| 342 | char *z; |
| 343 | va_list ap; |
| 344 | va_start(ap, zFormat); |
| 345 | z = vmprintf(zFormat, ap); |
| 346 | va_end(ap); |
| 347 | if( g.cgiOutput ){ |
| 348 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 349 | }else{ |
| 350 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 351 | } |
| 352 | } |
| @@ -811,11 +811,11 @@ | |
| 811 | #ifdef __EMX__ |
| 812 | /* Similar hack for OS/2 */ |
| 813 | setmode(fileno(g.httpOut), O_BINARY); |
| 814 | setmode(fileno(g.httpIn), O_BINARY); |
| 815 | #endif |
| 816 | g.cgiOutput = 1; |
| 817 | blob_read_from_file(&config, zFile); |
| 818 | while( blob_line(&config, &line) ){ |
| 819 | if( !blob_token(&line, &key) ) continue; |
| 820 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 821 | if( blob_eq(&key, "debug:") && blob_token(&line, &value) ){ |
| @@ -909,11 +909,11 @@ | |
| 909 | const char *zNotFound; |
| 910 | zNotFound = find_option("notfound", 0, 1); |
| 911 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 912 | cgi_panic("no repository specified"); |
| 913 | } |
| 914 | g.cgiOutput = 1; |
| 915 | g.fullHttpReply = 1; |
| 916 | if( g.argc==6 ){ |
| 917 | g.httpIn = fopen(g.argv[3], "rb"); |
| 918 | g.httpOut = fopen(g.argv[4], "wb"); |
| 919 | zIpAddr = g.argv[5]; |
| @@ -1039,11 +1039,11 @@ | |
| 1039 | g.httpIn = stdin; |
| 1040 | g.httpOut = stdout; |
| 1041 | if( g.fHttpTrace || g.fSqlTrace ){ |
| 1042 | fprintf(stderr, "====== SERVER pid %d =======\n", getpid()); |
| 1043 | } |
| 1044 | g.cgiOutput = 1; |
| 1045 | find_server_repository(isUiCmd); |
| 1046 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1047 | cgi_handle_http_request(0); |
| 1048 | process_one_web_page(zNotFound); |
| 1049 | #else |
| 1050 |
+15
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -804,5 +804,20 @@ | ||
| 804 | 804 | void fossil_error_reset(void){ |
| 805 | 805 | free(g.zErrMsg); |
| 806 | 806 | g.zErrMsg = 0; |
| 807 | 807 | g.iErrPriority = 0; |
| 808 | 808 | } |
| 809 | + | |
| 810 | +/* | |
| 811 | +** Write output for user consumption. If g.cgiOutput is enabled, then | |
| 812 | +** send the output as part of the CGI reply. If g.cgiOutput is false, | |
| 813 | +** then write on standard output. | |
| 814 | +*/ | |
| 815 | +void fossil_print(const char *zFormat, ...){ | |
| 816 | + va_list ap; | |
| 817 | + va_start(ap, zFormat); | |
| 818 | + if( g.cgiOutput ){ | |
| 819 | + cgi_vprintf(zFormat, ap); | |
| 820 | + }else{ | |
| 821 | + vprintf(zFormat, ap); | |
| 822 | + } | |
| 823 | +} | |
| 809 | 824 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -804,5 +804,20 @@ | |
| 804 | void fossil_error_reset(void){ |
| 805 | free(g.zErrMsg); |
| 806 | g.zErrMsg = 0; |
| 807 | g.iErrPriority = 0; |
| 808 | } |
| 809 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -804,5 +804,20 @@ | |
| 804 | void fossil_error_reset(void){ |
| 805 | free(g.zErrMsg); |
| 806 | g.zErrMsg = 0; |
| 807 | g.iErrPriority = 0; |
| 808 | } |
| 809 | |
| 810 | /* |
| 811 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 812 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 813 | ** then write on standard output. |
| 814 | */ |
| 815 | void fossil_print(const char *zFormat, ...){ |
| 816 | va_list ap; |
| 817 | va_start(ap, zFormat); |
| 818 | if( g.cgiOutput ){ |
| 819 | cgi_vprintf(zFormat, ap); |
| 820 | }else{ |
| 821 | vprintf(zFormat, ap); |
| 822 | } |
| 823 | } |
| 824 |
+1
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -110,11 +110,11 @@ | ||
| 110 | 110 | if( g.thTrace ) Th_Trace("BEGIN_HEADER_SCRIPT<br />\n", -1); |
| 111 | 111 | Th_Render(zHeader); |
| 112 | 112 | if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1); |
| 113 | 113 | Th_Unstore("title"); /* Avoid collisions with ticket field names */ |
| 114 | 114 | cgi_destination(CGI_BODY); |
| 115 | - g.cgiPanic = 1; | |
| 115 | + g.cgiOutput = 1; | |
| 116 | 116 | headerHasBeenGenerated = 1; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /* |
| 120 | 120 | ** Draw the footer at the bottom of the page. |
| 121 | 121 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -110,11 +110,11 @@ | |
| 110 | if( g.thTrace ) Th_Trace("BEGIN_HEADER_SCRIPT<br />\n", -1); |
| 111 | Th_Render(zHeader); |
| 112 | if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1); |
| 113 | Th_Unstore("title"); /* Avoid collisions with ticket field names */ |
| 114 | cgi_destination(CGI_BODY); |
| 115 | g.cgiPanic = 1; |
| 116 | headerHasBeenGenerated = 1; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** Draw the footer at the bottom of the page. |
| 121 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -110,11 +110,11 @@ | |
| 110 | if( g.thTrace ) Th_Trace("BEGIN_HEADER_SCRIPT<br />\n", -1); |
| 111 | Th_Render(zHeader); |
| 112 | if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1); |
| 113 | Th_Unstore("title"); /* Avoid collisions with ticket field names */ |
| 114 | cgi_destination(CGI_BODY); |
| 115 | g.cgiOutput = 1; |
| 116 | headerHasBeenGenerated = 1; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** Draw the footer at the bottom of the page. |
| 121 |
+1
-1
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -95,11 +95,11 @@ | ||
| 95 | 95 | if( n<0 ) n = strlen(z); |
| 96 | 96 | if( encode ){ |
| 97 | 97 | z = htmlize(z, n); |
| 98 | 98 | n = strlen(z); |
| 99 | 99 | } |
| 100 | - if( g.cgiPanic ){ | |
| 100 | + if( g.cgiOutput ){ | |
| 101 | 101 | cgi_append_content(z, n); |
| 102 | 102 | }else{ |
| 103 | 103 | fwrite(z, 1, n, stdout); |
| 104 | 104 | } |
| 105 | 105 | if( encode ) free((char*)z); |
| 106 | 106 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -95,11 +95,11 @@ | |
| 95 | if( n<0 ) n = strlen(z); |
| 96 | if( encode ){ |
| 97 | z = htmlize(z, n); |
| 98 | n = strlen(z); |
| 99 | } |
| 100 | if( g.cgiPanic ){ |
| 101 | cgi_append_content(z, n); |
| 102 | }else{ |
| 103 | fwrite(z, 1, n, stdout); |
| 104 | } |
| 105 | if( encode ) free((char*)z); |
| 106 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -95,11 +95,11 @@ | |
| 95 | if( n<0 ) n = strlen(z); |
| 96 | if( encode ){ |
| 97 | z = htmlize(z, n); |
| 98 | n = strlen(z); |
| 99 | } |
| 100 | if( g.cgiOutput ){ |
| 101 | cgi_append_content(z, n); |
| 102 | }else{ |
| 103 | fwrite(z, 1, n, stdout); |
| 104 | } |
| 105 | if( encode ) free((char*)z); |
| 106 |
+11
-11
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -992,11 +992,11 @@ | ||
| 992 | 992 | if( pushFlag ){ |
| 993 | 993 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 994 | 994 | nCardSent++; |
| 995 | 995 | } |
| 996 | 996 | manifest_crosslink_begin(); |
| 997 | - printf(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); | |
| 997 | + fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); | |
| 998 | 998 | |
| 999 | 999 | while( go ){ |
| 1000 | 1000 | int newPhantom = 0; |
| 1001 | 1001 | char *zRandomness; |
| 1002 | 1002 | |
| @@ -1058,13 +1058,13 @@ | ||
| 1058 | 1058 | blob_appendf(&send, "# %s\n", zRandomness); |
| 1059 | 1059 | free(zRandomness); |
| 1060 | 1060 | |
| 1061 | 1061 | /* Exchange messages with the server */ |
| 1062 | 1062 | nFileSend = xfer.nFileSent + xfer.nDeltaSent; |
| 1063 | - printf(zValueFormat, "Send:", | |
| 1064 | - blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, | |
| 1065 | - xfer.nFileSent, xfer.nDeltaSent); | |
| 1063 | + fossil_print(zValueFormat, "Send:", | |
| 1064 | + blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, | |
| 1065 | + xfer.nFileSent, xfer.nDeltaSent); | |
| 1066 | 1066 | nCardSent = 0; |
| 1067 | 1067 | nCardRcvd = 0; |
| 1068 | 1068 | xfer.nFileSent = 0; |
| 1069 | 1069 | xfer.nDeltaSent = 0; |
| 1070 | 1070 | xfer.nGimmeSent = 0; |
| @@ -1091,11 +1091,11 @@ | ||
| 1091 | 1091 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 1092 | 1092 | continue; |
| 1093 | 1093 | } |
| 1094 | 1094 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1095 | 1095 | nCardRcvd++; |
| 1096 | - if (!g.fQuiet) { | |
| 1096 | + if( !g.cgiOutput && !g.fQuiet ){ | |
| 1097 | 1097 | printf("\r%d", nCardRcvd); |
| 1098 | 1098 | fflush(stdout); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | /* file UUID SIZE \n CONTENT |
| @@ -1232,11 +1232,11 @@ | ||
| 1232 | 1232 | ** to the next cycle. |
| 1233 | 1233 | */ |
| 1234 | 1234 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1235 | 1235 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1236 | 1236 | defossilize(zMsg); |
| 1237 | - if( zMsg ) printf("\rServer says: %s\n", zMsg); | |
| 1237 | + if( zMsg ) fossil_print("\rServer says: %s\n", zMsg); | |
| 1238 | 1238 | }else |
| 1239 | 1239 | |
| 1240 | 1240 | /* error MESSAGE |
| 1241 | 1241 | ** |
| 1242 | 1242 | ** Report an error and abandon the sync session. |
| @@ -1284,13 +1284,13 @@ | ||
| 1284 | 1284 | if( origConfigRcvMask & (CONFIGSET_TKT|CONFIGSET_USER) ){ |
| 1285 | 1285 | configure_finalize_receive(); |
| 1286 | 1286 | } |
| 1287 | 1287 | origConfigRcvMask = 0; |
| 1288 | 1288 | if( nCardRcvd>0 ){ |
| 1289 | - printf(zValueFormat, "Received:", | |
| 1290 | - blob_size(&recv), nCardRcvd, | |
| 1291 | - xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); | |
| 1289 | + fossil_print(zValueFormat, "Received:", | |
| 1290 | + blob_size(&recv), nCardRcvd, | |
| 1291 | + xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); | |
| 1292 | 1292 | } |
| 1293 | 1293 | blob_reset(&recv); |
| 1294 | 1294 | nCycle++; |
| 1295 | 1295 | |
| 1296 | 1296 | /* If we received one or more files on the previous exchange but |
| @@ -1316,13 +1316,13 @@ | ||
| 1316 | 1316 | |
| 1317 | 1317 | /* If this is a clone, the go at least two rounds */ |
| 1318 | 1318 | if( cloneFlag && nCycle==1 ) go = 1; |
| 1319 | 1319 | }; |
| 1320 | 1320 | transport_stats(&nSent, &nRcvd, 1); |
| 1321 | - printf("Total network traffic: %d bytes sent, %d bytes received\n", | |
| 1322 | - nSent, nRcvd); | |
| 1321 | + fossil_print("Total network traffic: %d bytes sent, %d bytes received\n", | |
| 1322 | + nSent, nRcvd); | |
| 1323 | 1323 | transport_close(); |
| 1324 | 1324 | transport_global_shutdown(); |
| 1325 | 1325 | db_multi_exec("DROP TABLE onremote"); |
| 1326 | 1326 | manifest_crosslink_end(); |
| 1327 | 1327 | db_end_transaction(0); |
| 1328 | 1328 | } |
| 1329 | 1329 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -992,11 +992,11 @@ | |
| 992 | if( pushFlag ){ |
| 993 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 994 | nCardSent++; |
| 995 | } |
| 996 | manifest_crosslink_begin(); |
| 997 | printf(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 998 | |
| 999 | while( go ){ |
| 1000 | int newPhantom = 0; |
| 1001 | char *zRandomness; |
| 1002 | |
| @@ -1058,13 +1058,13 @@ | |
| 1058 | blob_appendf(&send, "# %s\n", zRandomness); |
| 1059 | free(zRandomness); |
| 1060 | |
| 1061 | /* Exchange messages with the server */ |
| 1062 | nFileSend = xfer.nFileSent + xfer.nDeltaSent; |
| 1063 | printf(zValueFormat, "Send:", |
| 1064 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 1065 | xfer.nFileSent, xfer.nDeltaSent); |
| 1066 | nCardSent = 0; |
| 1067 | nCardRcvd = 0; |
| 1068 | xfer.nFileSent = 0; |
| 1069 | xfer.nDeltaSent = 0; |
| 1070 | xfer.nGimmeSent = 0; |
| @@ -1091,11 +1091,11 @@ | |
| 1091 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 1092 | continue; |
| 1093 | } |
| 1094 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1095 | nCardRcvd++; |
| 1096 | if (!g.fQuiet) { |
| 1097 | printf("\r%d", nCardRcvd); |
| 1098 | fflush(stdout); |
| 1099 | } |
| 1100 | |
| 1101 | /* file UUID SIZE \n CONTENT |
| @@ -1232,11 +1232,11 @@ | |
| 1232 | ** to the next cycle. |
| 1233 | */ |
| 1234 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1235 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1236 | defossilize(zMsg); |
| 1237 | if( zMsg ) printf("\rServer says: %s\n", zMsg); |
| 1238 | }else |
| 1239 | |
| 1240 | /* error MESSAGE |
| 1241 | ** |
| 1242 | ** Report an error and abandon the sync session. |
| @@ -1284,13 +1284,13 @@ | |
| 1284 | if( origConfigRcvMask & (CONFIGSET_TKT|CONFIGSET_USER) ){ |
| 1285 | configure_finalize_receive(); |
| 1286 | } |
| 1287 | origConfigRcvMask = 0; |
| 1288 | if( nCardRcvd>0 ){ |
| 1289 | printf(zValueFormat, "Received:", |
| 1290 | blob_size(&recv), nCardRcvd, |
| 1291 | xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); |
| 1292 | } |
| 1293 | blob_reset(&recv); |
| 1294 | nCycle++; |
| 1295 | |
| 1296 | /* If we received one or more files on the previous exchange but |
| @@ -1316,13 +1316,13 @@ | |
| 1316 | |
| 1317 | /* If this is a clone, the go at least two rounds */ |
| 1318 | if( cloneFlag && nCycle==1 ) go = 1; |
| 1319 | }; |
| 1320 | transport_stats(&nSent, &nRcvd, 1); |
| 1321 | printf("Total network traffic: %d bytes sent, %d bytes received\n", |
| 1322 | nSent, nRcvd); |
| 1323 | transport_close(); |
| 1324 | transport_global_shutdown(); |
| 1325 | db_multi_exec("DROP TABLE onremote"); |
| 1326 | manifest_crosslink_end(); |
| 1327 | db_end_transaction(0); |
| 1328 | } |
| 1329 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -992,11 +992,11 @@ | |
| 992 | if( pushFlag ){ |
| 993 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 994 | nCardSent++; |
| 995 | } |
| 996 | manifest_crosslink_begin(); |
| 997 | fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 998 | |
| 999 | while( go ){ |
| 1000 | int newPhantom = 0; |
| 1001 | char *zRandomness; |
| 1002 | |
| @@ -1058,13 +1058,13 @@ | |
| 1058 | blob_appendf(&send, "# %s\n", zRandomness); |
| 1059 | free(zRandomness); |
| 1060 | |
| 1061 | /* Exchange messages with the server */ |
| 1062 | nFileSend = xfer.nFileSent + xfer.nDeltaSent; |
| 1063 | fossil_print(zValueFormat, "Send:", |
| 1064 | blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, |
| 1065 | xfer.nFileSent, xfer.nDeltaSent); |
| 1066 | nCardSent = 0; |
| 1067 | nCardRcvd = 0; |
| 1068 | xfer.nFileSent = 0; |
| 1069 | xfer.nDeltaSent = 0; |
| 1070 | xfer.nGimmeSent = 0; |
| @@ -1091,11 +1091,11 @@ | |
| 1091 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 1092 | continue; |
| 1093 | } |
| 1094 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1095 | nCardRcvd++; |
| 1096 | if( !g.cgiOutput && !g.fQuiet ){ |
| 1097 | printf("\r%d", nCardRcvd); |
| 1098 | fflush(stdout); |
| 1099 | } |
| 1100 | |
| 1101 | /* file UUID SIZE \n CONTENT |
| @@ -1232,11 +1232,11 @@ | |
| 1232 | ** to the next cycle. |
| 1233 | */ |
| 1234 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1235 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1236 | defossilize(zMsg); |
| 1237 | if( zMsg ) fossil_print("\rServer says: %s\n", zMsg); |
| 1238 | }else |
| 1239 | |
| 1240 | /* error MESSAGE |
| 1241 | ** |
| 1242 | ** Report an error and abandon the sync session. |
| @@ -1284,13 +1284,13 @@ | |
| 1284 | if( origConfigRcvMask & (CONFIGSET_TKT|CONFIGSET_USER) ){ |
| 1285 | configure_finalize_receive(); |
| 1286 | } |
| 1287 | origConfigRcvMask = 0; |
| 1288 | if( nCardRcvd>0 ){ |
| 1289 | fossil_print(zValueFormat, "Received:", |
| 1290 | blob_size(&recv), nCardRcvd, |
| 1291 | xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); |
| 1292 | } |
| 1293 | blob_reset(&recv); |
| 1294 | nCycle++; |
| 1295 | |
| 1296 | /* If we received one or more files on the previous exchange but |
| @@ -1316,13 +1316,13 @@ | |
| 1316 | |
| 1317 | /* If this is a clone, the go at least two rounds */ |
| 1318 | if( cloneFlag && nCycle==1 ) go = 1; |
| 1319 | }; |
| 1320 | transport_stats(&nSent, &nRcvd, 1); |
| 1321 | fossil_print("Total network traffic: %d bytes sent, %d bytes received\n", |
| 1322 | nSent, nRcvd); |
| 1323 | transport_close(); |
| 1324 | transport_global_shutdown(); |
| 1325 | db_multi_exec("DROP TABLE onremote"); |
| 1326 | manifest_crosslink_end(); |
| 1327 | db_end_transaction(0); |
| 1328 | } |
| 1329 |