Fossil SCM
Enhance the pop3 TOP command so that the second argument can be zero.
Commit
644931632362bd704b6ab2b24544039a3961f5835b0ed7b7159a5adc2f77394c
Parent
2c18ed076e00863…
1 file changed
+5
-5
+5
-5
| --- src/smtp.c | ||
| +++ src/smtp.c | ||
| @@ -1487,32 +1487,32 @@ | ||
| 1487 | 1487 | } |
| 1488 | 1488 | if( strcmp(zCmd,"retr")==0 || strcmp(zCmd,"top")==0 ){ |
| 1489 | 1489 | Blob all, line; |
| 1490 | 1490 | int nLine = 0; |
| 1491 | 1491 | int iLimit; |
| 1492 | - int hdrSeen = 0; | |
| 1492 | + int hdrPending = 1; | |
| 1493 | 1493 | if( zA1==0 ) goto cmd_error; |
| 1494 | 1494 | iLimit = zA2 ? atoi(zA2) : 2147483647; |
| 1495 | - if( iLimit<=0 ) goto cmd_error; | |
| 1495 | + if( iLimit<0 ) goto cmd_error; | |
| 1496 | 1496 | z = db_text(0, "SELECT decompress(emailblob.etxt) " |
| 1497 | 1497 | " FROM emailblob, pop3" |
| 1498 | 1498 | " WHERE emailblob.emailid=pop3.emailid" |
| 1499 | 1499 | " AND pop3.id=%d AND NOT pop3.isDel", |
| 1500 | 1500 | atoi(zA1)); |
| 1501 | 1501 | if( z==0 ) goto cmd_error; |
| 1502 | 1502 | pop3_print(pLog, "+OK"); |
| 1503 | 1503 | blob_init(&all, z, -1); |
| 1504 | - while( iLimit && blob_line(&all, &line) ){ | |
| 1504 | + while( (hdrPending || iLimit>0) && blob_line(&all, &line) ){ | |
| 1505 | 1505 | char c = blob_buffer(&line)[0]; |
| 1506 | 1506 | if( c=='.' ){ |
| 1507 | 1507 | fputc('.', stdout); |
| 1508 | 1508 | }else if( c=='\r' || c=='\n' ){ |
| 1509 | - hdrSeen = 1; | |
| 1509 | + hdrPending = 0; | |
| 1510 | 1510 | } |
| 1511 | 1511 | fwrite(blob_buffer(&line), 1, blob_size(&line), stdout); |
| 1512 | 1512 | nLine++; |
| 1513 | - if( hdrSeen ) iLimit--; | |
| 1513 | + if( !hdrPending ) iLimit--; | |
| 1514 | 1514 | } |
| 1515 | 1515 | if( pLog ) fprintf(pLog, "S: # %d lines of content\n", nLine); |
| 1516 | 1516 | pop3_print(pLog, "."); |
| 1517 | 1517 | fossil_free(z); |
| 1518 | 1518 | blob_reset(&all); |
| 1519 | 1519 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -1487,32 +1487,32 @@ | |
| 1487 | } |
| 1488 | if( strcmp(zCmd,"retr")==0 || strcmp(zCmd,"top")==0 ){ |
| 1489 | Blob all, line; |
| 1490 | int nLine = 0; |
| 1491 | int iLimit; |
| 1492 | int hdrSeen = 0; |
| 1493 | if( zA1==0 ) goto cmd_error; |
| 1494 | iLimit = zA2 ? atoi(zA2) : 2147483647; |
| 1495 | if( iLimit<=0 ) goto cmd_error; |
| 1496 | z = db_text(0, "SELECT decompress(emailblob.etxt) " |
| 1497 | " FROM emailblob, pop3" |
| 1498 | " WHERE emailblob.emailid=pop3.emailid" |
| 1499 | " AND pop3.id=%d AND NOT pop3.isDel", |
| 1500 | atoi(zA1)); |
| 1501 | if( z==0 ) goto cmd_error; |
| 1502 | pop3_print(pLog, "+OK"); |
| 1503 | blob_init(&all, z, -1); |
| 1504 | while( iLimit && blob_line(&all, &line) ){ |
| 1505 | char c = blob_buffer(&line)[0]; |
| 1506 | if( c=='.' ){ |
| 1507 | fputc('.', stdout); |
| 1508 | }else if( c=='\r' || c=='\n' ){ |
| 1509 | hdrSeen = 1; |
| 1510 | } |
| 1511 | fwrite(blob_buffer(&line), 1, blob_size(&line), stdout); |
| 1512 | nLine++; |
| 1513 | if( hdrSeen ) iLimit--; |
| 1514 | } |
| 1515 | if( pLog ) fprintf(pLog, "S: # %d lines of content\n", nLine); |
| 1516 | pop3_print(pLog, "."); |
| 1517 | fossil_free(z); |
| 1518 | blob_reset(&all); |
| 1519 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -1487,32 +1487,32 @@ | |
| 1487 | } |
| 1488 | if( strcmp(zCmd,"retr")==0 || strcmp(zCmd,"top")==0 ){ |
| 1489 | Blob all, line; |
| 1490 | int nLine = 0; |
| 1491 | int iLimit; |
| 1492 | int hdrPending = 1; |
| 1493 | if( zA1==0 ) goto cmd_error; |
| 1494 | iLimit = zA2 ? atoi(zA2) : 2147483647; |
| 1495 | if( iLimit<0 ) goto cmd_error; |
| 1496 | z = db_text(0, "SELECT decompress(emailblob.etxt) " |
| 1497 | " FROM emailblob, pop3" |
| 1498 | " WHERE emailblob.emailid=pop3.emailid" |
| 1499 | " AND pop3.id=%d AND NOT pop3.isDel", |
| 1500 | atoi(zA1)); |
| 1501 | if( z==0 ) goto cmd_error; |
| 1502 | pop3_print(pLog, "+OK"); |
| 1503 | blob_init(&all, z, -1); |
| 1504 | while( (hdrPending || iLimit>0) && blob_line(&all, &line) ){ |
| 1505 | char c = blob_buffer(&line)[0]; |
| 1506 | if( c=='.' ){ |
| 1507 | fputc('.', stdout); |
| 1508 | }else if( c=='\r' || c=='\n' ){ |
| 1509 | hdrPending = 0; |
| 1510 | } |
| 1511 | fwrite(blob_buffer(&line), 1, blob_size(&line), stdout); |
| 1512 | nLine++; |
| 1513 | if( !hdrPending ) iLimit--; |
| 1514 | } |
| 1515 | if( pLog ) fprintf(pLog, "S: # %d lines of content\n", nLine); |
| 1516 | pop3_print(pLog, "."); |
| 1517 | fossil_free(z); |
| 1518 | blob_reset(&all); |
| 1519 |