Fossil SCM
Add the 'encode64' command to TH1.
Commit
3f21421a5137cd0cff3c195d4f72fe326ae72036
Parent
3c34db8d0ecb671…
4 files changed
+23
+10
+6
-6
+8
+23
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -510,10 +510,32 @@ | ||
| 510 | 510 | zOut = htmlize((char*)argv[1], argl[1]); |
| 511 | 511 | Th_SetResult(interp, zOut, -1); |
| 512 | 512 | free(zOut); |
| 513 | 513 | return TH_OK; |
| 514 | 514 | } |
| 515 | + | |
| 516 | +/* | |
| 517 | +** TH1 command: encode64 STRING | |
| 518 | +** | |
| 519 | +** Encode the specified string using Base64 and return the result. | |
| 520 | +*/ | |
| 521 | +static int encode64Cmd( | |
| 522 | + Th_Interp *interp, | |
| 523 | + void *p, | |
| 524 | + int argc, | |
| 525 | + const char **argv, | |
| 526 | + int *argl | |
| 527 | +){ | |
| 528 | + char *zOut; | |
| 529 | + if( argc!=2 ){ | |
| 530 | + return Th_WrongNumArgs(interp, "encode64 STRING"); | |
| 531 | + } | |
| 532 | + zOut = encode64((char*)argv[1], argl[1]); | |
| 533 | + Th_SetResult(interp, zOut, -1); | |
| 534 | + free(zOut); | |
| 535 | + return TH_OK; | |
| 536 | +} | |
| 515 | 537 | |
| 516 | 538 | /* |
| 517 | 539 | ** TH1 command: date |
| 518 | 540 | ** |
| 519 | 541 | ** Return a string which is the current time and date. If the |
| @@ -1727,10 +1749,11 @@ | ||
| 1727 | 1749 | {"combobox", comboboxCmd, 0}, |
| 1728 | 1750 | {"date", dateCmd, 0}, |
| 1729 | 1751 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1730 | 1752 | {"dir", dirCmd, 0}, |
| 1731 | 1753 | {"enable_output", enableOutputCmd, 0}, |
| 1754 | + {"encode64", encode64Cmd, 0}, | |
| 1732 | 1755 | {"getParameter", getParameterCmd, 0}, |
| 1733 | 1756 | {"glob_match", globMatchCmd, 0}, |
| 1734 | 1757 | {"globalState", globalStateCmd, 0}, |
| 1735 | 1758 | {"httpize", httpizeCmd, 0}, |
| 1736 | 1759 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1737 | 1760 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -510,10 +510,32 @@ | |
| 510 | zOut = htmlize((char*)argv[1], argl[1]); |
| 511 | Th_SetResult(interp, zOut, -1); |
| 512 | free(zOut); |
| 513 | return TH_OK; |
| 514 | } |
| 515 | |
| 516 | /* |
| 517 | ** TH1 command: date |
| 518 | ** |
| 519 | ** Return a string which is the current time and date. If the |
| @@ -1727,10 +1749,11 @@ | |
| 1727 | {"combobox", comboboxCmd, 0}, |
| 1728 | {"date", dateCmd, 0}, |
| 1729 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1730 | {"dir", dirCmd, 0}, |
| 1731 | {"enable_output", enableOutputCmd, 0}, |
| 1732 | {"getParameter", getParameterCmd, 0}, |
| 1733 | {"glob_match", globMatchCmd, 0}, |
| 1734 | {"globalState", globalStateCmd, 0}, |
| 1735 | {"httpize", httpizeCmd, 0}, |
| 1736 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1737 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -510,10 +510,32 @@ | |
| 510 | zOut = htmlize((char*)argv[1], argl[1]); |
| 511 | Th_SetResult(interp, zOut, -1); |
| 512 | free(zOut); |
| 513 | return TH_OK; |
| 514 | } |
| 515 | |
| 516 | /* |
| 517 | ** TH1 command: encode64 STRING |
| 518 | ** |
| 519 | ** Encode the specified string using Base64 and return the result. |
| 520 | */ |
| 521 | static int encode64Cmd( |
| 522 | Th_Interp *interp, |
| 523 | void *p, |
| 524 | int argc, |
| 525 | const char **argv, |
| 526 | int *argl |
| 527 | ){ |
| 528 | char *zOut; |
| 529 | if( argc!=2 ){ |
| 530 | return Th_WrongNumArgs(interp, "encode64 STRING"); |
| 531 | } |
| 532 | zOut = encode64((char*)argv[1], argl[1]); |
| 533 | Th_SetResult(interp, zOut, -1); |
| 534 | free(zOut); |
| 535 | return TH_OK; |
| 536 | } |
| 537 | |
| 538 | /* |
| 539 | ** TH1 command: date |
| 540 | ** |
| 541 | ** Return a string which is the current time and date. If the |
| @@ -1727,10 +1749,11 @@ | |
| 1749 | {"combobox", comboboxCmd, 0}, |
| 1750 | {"date", dateCmd, 0}, |
| 1751 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1752 | {"dir", dirCmd, 0}, |
| 1753 | {"enable_output", enableOutputCmd, 0}, |
| 1754 | {"encode64", encode64Cmd, 0}, |
| 1755 | {"getParameter", getParameterCmd, 0}, |
| 1756 | {"glob_match", globMatchCmd, 0}, |
| 1757 | {"globalState", globalStateCmd, 0}, |
| 1758 | {"httpize", httpizeCmd, 0}, |
| 1759 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1760 |
+10
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -1245,5 +1245,15 @@ | ||
| 1245 | 1245 | <h2>Other Features</h2> |
| 1246 | 1246 | <p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p> |
| 1247 | 1247 | |
| 1248 | 1248 | </div> |
| 1249 | 1249 | }}} |
| 1250 | + | |
| 1251 | +############################################################################### | |
| 1252 | + | |
| 1253 | +fossil test-th-eval {encode64 test} | |
| 1254 | +test th1-encode64-1 {$RESULT eq "dGVzdA=="} | |
| 1255 | + | |
| 1256 | +############################################################################### | |
| 1257 | + | |
| 1258 | +fossil test-th-eval {encode64 test\0} | |
| 1259 | +test th1-encode64-2 {$RESULT eq "dGVzdAA="} | |
| 1250 | 1260 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -1245,5 +1245,15 @@ | |
| 1245 | <h2>Other Features</h2> |
| 1246 | <p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p> |
| 1247 | |
| 1248 | </div> |
| 1249 | }}} |
| 1250 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -1245,5 +1245,15 @@ | |
| 1245 | <h2>Other Features</h2> |
| 1246 | <p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p> |
| 1247 | |
| 1248 | </div> |
| 1249 | }}} |
| 1250 | |
| 1251 | ############################################################################### |
| 1252 | |
| 1253 | fossil test-th-eval {encode64 test} |
| 1254 | test th1-encode64-1 {$RESULT eq "dGVzdA=="} |
| 1255 | |
| 1256 | ############################################################################### |
| 1257 | |
| 1258 | fossil test-th-eval {encode64 test\0} |
| 1259 | test th1-encode64-2 {$RESULT eq "dGVzdAA="} |
| 1260 |
+6
-6
| --- www/changes.wiki | ||
| +++ www/changes.wiki | ||
| @@ -12,23 +12,23 @@ | ||
| 12 | 12 | tags of a "check-in". |
| 13 | 13 | * Fix bug in [/help?cmd=import|import] command, handling version 3 of |
| 14 | 14 | the svndump format for subversion. |
| 15 | 15 | * Add the [/help?cmd=all|all cache] command. |
| 16 | 16 | * TH1 enhancements: |
| 17 | - <ul><li>Add minimal <nowiki>[lsearch]</nowiki> command to TH1. Only exact | |
| 17 | + <ul><li>Add minimal <nowiki>[lsearch]</nowiki> command. Only exact | |
| 18 | 18 | case-sensitive matching is supported.</li> |
| 19 | - <li>Add the <nowiki>[glob_match]</nowiki>, <nowiki>[markdown]</nowiki>, and | |
| 20 | - <nowiki>[dir]</nowiki> commands to TH1.</li> | |
| 21 | - <li>Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> TH1 commands to | |
| 19 | + <li>Add the <nowiki>[glob_match]</nowiki>, <nowiki>[markdown]</nowiki>, | |
| 20 | + <nowiki>[dir]</nowiki>, and <nowiki>[encode64]</nowiki> commands.</li> | |
| 21 | + <li>Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> commands to | |
| 22 | 22 | the Tcl integration subsystem.</li> |
| 23 | 23 | <li>Add 'double', 'integer', and 'list' classes to the |
| 24 | - <nowiki>[string is]</nowiki> command in TH1.</li> | |
| 24 | + <nowiki>[string is]</nowiki> command.</li> | |
| 25 | 25 | </ul> |
| 26 | 26 | * Add the --undo option to the [/help?cmd=diff|diff] command. |
| 27 | 27 | * Build-in Antirez's "linenoise" command-linen editing library for use with |
| 28 | 28 | the [/help?cmd=sqlite3|fossil sql] command on Unix platforms. |
| 29 | - * Add [/help?cmd=stash|stash cat] as an alias for the | |
| 29 | + * Add [/help?cmd=stash|stash cat] as an alias for the | |
| 30 | 30 | [/help?cmd=stash|stash show] command. |
| 31 | 31 | * Updated the built-in SQLite to version 3.9.1 and activated JSON1 and FTS5 |
| 32 | 32 | support (both currently unused within Fossil). |
| 33 | 33 | |
| 34 | 34 | <h2>Changes for Version 1.33 (2015-05-23)</h2> |
| 35 | 35 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -12,23 +12,23 @@ | |
| 12 | tags of a "check-in". |
| 13 | * Fix bug in [/help?cmd=import|import] command, handling version 3 of |
| 14 | the svndump format for subversion. |
| 15 | * Add the [/help?cmd=all|all cache] command. |
| 16 | * TH1 enhancements: |
| 17 | <ul><li>Add minimal <nowiki>[lsearch]</nowiki> command to TH1. Only exact |
| 18 | case-sensitive matching is supported.</li> |
| 19 | <li>Add the <nowiki>[glob_match]</nowiki>, <nowiki>[markdown]</nowiki>, and |
| 20 | <nowiki>[dir]</nowiki> commands to TH1.</li> |
| 21 | <li>Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> TH1 commands to |
| 22 | the Tcl integration subsystem.</li> |
| 23 | <li>Add 'double', 'integer', and 'list' classes to the |
| 24 | <nowiki>[string is]</nowiki> command in TH1.</li> |
| 25 | </ul> |
| 26 | * Add the --undo option to the [/help?cmd=diff|diff] command. |
| 27 | * Build-in Antirez's "linenoise" command-linen editing library for use with |
| 28 | the [/help?cmd=sqlite3|fossil sql] command on Unix platforms. |
| 29 | * Add [/help?cmd=stash|stash cat] as an alias for the |
| 30 | [/help?cmd=stash|stash show] command. |
| 31 | * Updated the built-in SQLite to version 3.9.1 and activated JSON1 and FTS5 |
| 32 | support (both currently unused within Fossil). |
| 33 | |
| 34 | <h2>Changes for Version 1.33 (2015-05-23)</h2> |
| 35 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -12,23 +12,23 @@ | |
| 12 | tags of a "check-in". |
| 13 | * Fix bug in [/help?cmd=import|import] command, handling version 3 of |
| 14 | the svndump format for subversion. |
| 15 | * Add the [/help?cmd=all|all cache] command. |
| 16 | * TH1 enhancements: |
| 17 | <ul><li>Add minimal <nowiki>[lsearch]</nowiki> command. Only exact |
| 18 | case-sensitive matching is supported.</li> |
| 19 | <li>Add the <nowiki>[glob_match]</nowiki>, <nowiki>[markdown]</nowiki>, |
| 20 | <nowiki>[dir]</nowiki>, and <nowiki>[encode64]</nowiki> commands.</li> |
| 21 | <li>Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> commands to |
| 22 | the Tcl integration subsystem.</li> |
| 23 | <li>Add 'double', 'integer', and 'list' classes to the |
| 24 | <nowiki>[string is]</nowiki> command.</li> |
| 25 | </ul> |
| 26 | * Add the --undo option to the [/help?cmd=diff|diff] command. |
| 27 | * Build-in Antirez's "linenoise" command-linen editing library for use with |
| 28 | the [/help?cmd=sqlite3|fossil sql] command on Unix platforms. |
| 29 | * Add [/help?cmd=stash|stash cat] as an alias for the |
| 30 | [/help?cmd=stash|stash show] command. |
| 31 | * Updated the built-in SQLite to version 3.9.1 and activated JSON1 and FTS5 |
| 32 | support (both currently unused within Fossil). |
| 33 | |
| 34 | <h2>Changes for Version 1.33 (2015-05-23)</h2> |
| 35 |
+8
| --- www/th1.md | ||
| +++ www/th1.md | ||
| @@ -131,10 +131,11 @@ | ||
| 131 | 131 | * combobox |
| 132 | 132 | * date |
| 133 | 133 | * decorate |
| 134 | 134 | * dir |
| 135 | 135 | * enable_output |
| 136 | + * encode64 | |
| 136 | 137 | * getParameter |
| 137 | 138 | * glob_match |
| 138 | 139 | * globalState |
| 139 | 140 | * hascap |
| 140 | 141 | * hasfeature |
| @@ -255,10 +256,17 @@ | ||
| 255 | 256 | * enable_output BOOLEAN |
| 256 | 257 | |
| 257 | 258 | Enable or disable sending output when the combobox, puts, or wiki |
| 258 | 259 | commands are used. |
| 259 | 260 | |
| 261 | +<a name="encode64"></a>TH1 encode64 Command | |
| 262 | +------------------------------------------- | |
| 263 | + | |
| 264 | + * encode64 STRING | |
| 265 | + | |
| 266 | +Encode the specified string using Base64 and return the result. | |
| 267 | + | |
| 260 | 268 | <a name="getParameter"></a>TH1 getParameter Command |
| 261 | 269 | --------------------------------------------------- |
| 262 | 270 | |
| 263 | 271 | * getParameter NAME ?DEFAULT? |
| 264 | 272 | |
| 265 | 273 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -131,10 +131,11 @@ | |
| 131 | * combobox |
| 132 | * date |
| 133 | * decorate |
| 134 | * dir |
| 135 | * enable_output |
| 136 | * getParameter |
| 137 | * glob_match |
| 138 | * globalState |
| 139 | * hascap |
| 140 | * hasfeature |
| @@ -255,10 +256,17 @@ | |
| 255 | * enable_output BOOLEAN |
| 256 | |
| 257 | Enable or disable sending output when the combobox, puts, or wiki |
| 258 | commands are used. |
| 259 | |
| 260 | <a name="getParameter"></a>TH1 getParameter Command |
| 261 | --------------------------------------------------- |
| 262 | |
| 263 | * getParameter NAME ?DEFAULT? |
| 264 | |
| 265 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -131,10 +131,11 @@ | |
| 131 | * combobox |
| 132 | * date |
| 133 | * decorate |
| 134 | * dir |
| 135 | * enable_output |
| 136 | * encode64 |
| 137 | * getParameter |
| 138 | * glob_match |
| 139 | * globalState |
| 140 | * hascap |
| 141 | * hasfeature |
| @@ -255,10 +256,17 @@ | |
| 256 | * enable_output BOOLEAN |
| 257 | |
| 258 | Enable or disable sending output when the combobox, puts, or wiki |
| 259 | commands are used. |
| 260 | |
| 261 | <a name="encode64"></a>TH1 encode64 Command |
| 262 | ------------------------------------------- |
| 263 | |
| 264 | * encode64 STRING |
| 265 | |
| 266 | Encode the specified string using Base64 and return the result. |
| 267 | |
| 268 | <a name="getParameter"></a>TH1 getParameter Command |
| 269 | --------------------------------------------------- |
| 270 | |
| 271 | * getParameter NAME ?DEFAULT? |
| 272 | |
| 273 |