| | @@ -314,5 +314,38 @@ |
| 314 | 314 | db_must_be_within_tree(); |
| 315 | 315 | rid = name_to_rid(g.argv[2]); |
| 316 | 316 | zip_of_baseline(rid, &zip); |
| 317 | 317 | blob_write_to_file(&zip, g.argv[3]); |
| 318 | 318 | } |
| 319 | + |
| 320 | +/* |
| 321 | +** WEBPAGE: zip |
| 322 | +** |
| 323 | +** Generate a ZIP archive for the baseline specified by g.zExtra |
| 324 | +** and return that ZIP archive as the HTTP reply content. |
| 325 | +*/ |
| 326 | +void baseline_zip_page(void){ |
| 327 | + int rid; |
| 328 | + char *zName; |
| 329 | + int i; |
| 330 | + Blob zip; |
| 331 | + |
| 332 | + login_check_credentials(); |
| 333 | + if( !g.okRead || !g.okHistory ){ login_needed(); return; } |
| 334 | + zName = mprintf("%s", g.zExtra); |
| 335 | + i = strlen(zName); |
| 336 | + for(i=strlen(zName)-1; i>5; i--){ |
| 337 | + if( zName[i]=='.' ){ |
| 338 | + zName[i] = 0; |
| 339 | + break; |
| 340 | + } |
| 341 | + } |
| 342 | + rid = name_to_rid(zName); |
| 343 | + if( rid==0 ){ |
| 344 | + @ Not found |
| 345 | + return; |
| 346 | + } |
| 347 | + zip_of_baseline(rid, &zip); |
| 348 | + cgi_set_content(&zip); |
| 349 | + cgi_set_content_type("application/zip"); |
| 350 | + cgi_reply(); |
| 351 | +} |
| 319 | 352 | |