Fossil SCM

Add the "email" command and basic infrastructure for generating outbound email messages.

drh 2018-06-20 18:25 trunk
Commit 5200323a417be0af7038eb7b517cc2db74c29baac070e0c8d5b3a50d1ada41ae
3 files changed +10 -8 +1 -1 +20 -11
+10 -8
--- src/checkin.c
+++ src/checkin.c
@@ -1192,17 +1192,19 @@
11921192
blob_add_cr(pPrompt);
11931193
#endif
11941194
}
11951195
#endif
11961196
if( zEditor==0 ){
1197
- blob_append(pPrompt,
1198
- "#\n"
1199
- "# Since no default text editor is set using EDITOR or VISUAL\n"
1200
- "# environment variables or the \"fossil set editor\" command,\n"
1201
- "# and because no comment was specified using the \"-m\" or \"-M\"\n"
1202
- "# command-line options, you will need to enter the comment below.\n"
1203
- "# Type \".\" on a line by itself when you are done:\n", -1);
1197
+ if( blob_size(pPrompt)>0 ){
1198
+ blob_append(pPrompt,
1199
+ "#\n"
1200
+ "# Since no default text editor is set using EDITOR or VISUAL\n"
1201
+ "# environment variables or the \"fossil set editor\" command,\n"
1202
+ "# and because no comment was specified using the \"-m\" or \"-M\"\n"
1203
+ "# command-line options, you will need to enter the comment below.\n"
1204
+ "# Type \".\" on a line by itself when you are done:\n", -1);
1205
+ }
12041206
zFile = mprintf("-");
12051207
}else{
12061208
Blob fname;
12071209
blob_zero(&fname);
12081210
if( g.zLocalRoot!=0 ){
@@ -1216,11 +1218,11 @@
12161218
blob_reset(&fname);
12171219
}
12181220
#if defined(_WIN32)
12191221
blob_add_cr(pPrompt);
12201222
#endif
1221
- blob_write_to_file(pPrompt, zFile);
1223
+ if( blob_size(pPrompt)>0 ) blob_write_to_file(pPrompt, zFile);
12221224
if( zEditor ){
12231225
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
12241226
fossil_print("%s\n", zCmd);
12251227
if( fossil_system(zCmd) ){
12261228
fossil_fatal("editor aborted: \"%s\"", zCmd);
12271229
--- src/checkin.c
+++ src/checkin.c
@@ -1192,17 +1192,19 @@
1192 blob_add_cr(pPrompt);
1193 #endif
1194 }
1195 #endif
1196 if( zEditor==0 ){
1197 blob_append(pPrompt,
1198 "#\n"
1199 "# Since no default text editor is set using EDITOR or VISUAL\n"
1200 "# environment variables or the \"fossil set editor\" command,\n"
1201 "# and because no comment was specified using the \"-m\" or \"-M\"\n"
1202 "# command-line options, you will need to enter the comment below.\n"
1203 "# Type \".\" on a line by itself when you are done:\n", -1);
 
 
1204 zFile = mprintf("-");
1205 }else{
1206 Blob fname;
1207 blob_zero(&fname);
1208 if( g.zLocalRoot!=0 ){
@@ -1216,11 +1218,11 @@
1216 blob_reset(&fname);
1217 }
1218 #if defined(_WIN32)
1219 blob_add_cr(pPrompt);
1220 #endif
1221 blob_write_to_file(pPrompt, zFile);
1222 if( zEditor ){
1223 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
1224 fossil_print("%s\n", zCmd);
1225 if( fossil_system(zCmd) ){
1226 fossil_fatal("editor aborted: \"%s\"", zCmd);
1227
--- src/checkin.c
+++ src/checkin.c
@@ -1192,17 +1192,19 @@
1192 blob_add_cr(pPrompt);
1193 #endif
1194 }
1195 #endif
1196 if( zEditor==0 ){
1197 if( blob_size(pPrompt)>0 ){
1198 blob_append(pPrompt,
1199 "#\n"
1200 "# Since no default text editor is set using EDITOR or VISUAL\n"
1201 "# environment variables or the \"fossil set editor\" command,\n"
1202 "# and because no comment was specified using the \"-m\" or \"-M\"\n"
1203 "# command-line options, you will need to enter the comment below.\n"
1204 "# Type \".\" on a line by itself when you are done:\n", -1);
1205 }
1206 zFile = mprintf("-");
1207 }else{
1208 Blob fname;
1209 blob_zero(&fname);
1210 if( g.zLocalRoot!=0 ){
@@ -1216,11 +1218,11 @@
1218 blob_reset(&fname);
1219 }
1220 #if defined(_WIN32)
1221 blob_add_cr(pPrompt);
1222 #endif
1223 if( blob_size(pPrompt)>0 ) blob_write_to_file(pPrompt, zFile);
1224 if( zEditor ){
1225 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
1226 fossil_print("%s\n", zCmd);
1227 if( fossil_system(zCmd) ){
1228 fossil_fatal("editor aborted: \"%s\"", zCmd);
1229
+1 -1
--- src/db.c
+++ src/db.c
@@ -2750,11 +2750,11 @@
27502750
27512751
/*
27522752
** Print the current value of a setting identified by the pSetting
27532753
** pointer.
27542754
*/
2755
-static void print_setting(const Setting *pSetting){
2755
+void print_setting(const Setting *pSetting){
27562756
Stmt q;
27572757
if( g.repositoryOpen ){
27582758
db_prepare(&q,
27592759
"SELECT '(local)', value FROM config WHERE name=%Q"
27602760
" UNION ALL "
27612761
--- src/db.c
+++ src/db.c
@@ -2750,11 +2750,11 @@
2750
2751 /*
2752 ** Print the current value of a setting identified by the pSetting
2753 ** pointer.
2754 */
2755 static void print_setting(const Setting *pSetting){
2756 Stmt q;
2757 if( g.repositoryOpen ){
2758 db_prepare(&q,
2759 "SELECT '(local)', value FROM config WHERE name=%Q"
2760 " UNION ALL "
2761
--- src/db.c
+++ src/db.c
@@ -2750,11 +2750,11 @@
2750
2751 /*
2752 ** Print the current value of a setting identified by the pSetting
2753 ** pointer.
2754 */
2755 void print_setting(const Setting *pSetting){
2756 Stmt q;
2757 if( g.repositoryOpen ){
2758 db_prepare(&q,
2759 "SELECT '(local)', value FROM config WHERE name=%Q"
2760 " UNION ALL "
2761
+20 -11
--- src/encode.c
+++ src/encode.c
@@ -434,23 +434,16 @@
434434
*/
435435
static unsigned char zBase[] =
436436
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
437437
438438
/*
439
-** Encode a string using a base-64 encoding.
440
-** The encoding can be reversed using the <b>decode64</b> function.
441
-**
442
-** Space to hold the result comes from malloc().
439
+** Translate nData bytes of content from zData into
440
+** ((nData+2)/3)*4) bytes of base64 encoded content and
441
+** put the result in z64. Add a zero-terminator at the end.
443442
*/
444
-char *encode64(const char *zData, int nData){
445
- char *z64;
443
+int translateBase64(const char *zData, int nData, char *z64){
446444
int i, n;
447
-
448
- if( nData<=0 ){
449
- nData = strlen(zData);
450
- }
451
- z64 = fossil_malloc( (nData*4)/3 + 8 );
452445
for(i=n=0; i+2<nData; i+=3){
453446
z64[n++] = zBase[ (zData[i]>>2) & 0x3f ];
454447
z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ];
455448
z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ];
456449
z64[n++] = zBase[ zData[i+2] & 0x3f ];
@@ -465,10 +458,26 @@
465458
z64[n++] = zBase[ ((zData[i]<<4) & 0x30) ];
466459
z64[n++] = '=';
467460
z64[n++] = '=';
468461
}
469462
z64[n] = 0;
463
+ return n;
464
+}
465
+
466
+/*
467
+** Encode a string using a base-64 encoding.
468
+** The encoding can be reversed using the <b>decode64</b> function.
469
+**
470
+** Space to hold the result comes from malloc().
471
+*/
472
+char *encode64(const char *zData, int nData){
473
+ char *z64;
474
+ if( nData<=0 ){
475
+ nData = strlen(zData);
476
+ }
477
+ z64 = fossil_malloc( (nData*4)/3 + 8 );
478
+ translateBase64(zData, nData, z64);
470479
return z64;
471480
}
472481
473482
/*
474483
** COMMAND: test-encode64
475484
--- src/encode.c
+++ src/encode.c
@@ -434,23 +434,16 @@
434 */
435 static unsigned char zBase[] =
436 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
437
438 /*
439 ** Encode a string using a base-64 encoding.
440 ** The encoding can be reversed using the <b>decode64</b> function.
441 **
442 ** Space to hold the result comes from malloc().
443 */
444 char *encode64(const char *zData, int nData){
445 char *z64;
446 int i, n;
447
448 if( nData<=0 ){
449 nData = strlen(zData);
450 }
451 z64 = fossil_malloc( (nData*4)/3 + 8 );
452 for(i=n=0; i+2<nData; i+=3){
453 z64[n++] = zBase[ (zData[i]>>2) & 0x3f ];
454 z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ];
455 z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ];
456 z64[n++] = zBase[ zData[i+2] & 0x3f ];
@@ -465,10 +458,26 @@
465 z64[n++] = zBase[ ((zData[i]<<4) & 0x30) ];
466 z64[n++] = '=';
467 z64[n++] = '=';
468 }
469 z64[n] = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470 return z64;
471 }
472
473 /*
474 ** COMMAND: test-encode64
475
--- src/encode.c
+++ src/encode.c
@@ -434,23 +434,16 @@
434 */
435 static unsigned char zBase[] =
436 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
437
438 /*
439 ** Translate nData bytes of content from zData into
440 ** ((nData+2)/3)*4) bytes of base64 encoded content and
441 ** put the result in z64. Add a zero-terminator at the end.
 
442 */
443 int translateBase64(const char *zData, int nData, char *z64){
 
444 int i, n;
 
 
 
 
 
445 for(i=n=0; i+2<nData; i+=3){
446 z64[n++] = zBase[ (zData[i]>>2) & 0x3f ];
447 z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ];
448 z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ];
449 z64[n++] = zBase[ zData[i+2] & 0x3f ];
@@ -465,10 +458,26 @@
458 z64[n++] = zBase[ ((zData[i]<<4) & 0x30) ];
459 z64[n++] = '=';
460 z64[n++] = '=';
461 }
462 z64[n] = 0;
463 return n;
464 }
465
466 /*
467 ** Encode a string using a base-64 encoding.
468 ** The encoding can be reversed using the <b>decode64</b> function.
469 **
470 ** Space to hold the result comes from malloc().
471 */
472 char *encode64(const char *zData, int nData){
473 char *z64;
474 if( nData<=0 ){
475 nData = strlen(zData);
476 }
477 z64 = fossil_malloc( (nData*4)/3 + 8 );
478 translateBase64(zData, nData, z64);
479 return z64;
480 }
481
482 /*
483 ** COMMAND: test-encode64
484

Keyboard Shortcuts

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