Fossil SCM

Add the 'encode64' command to TH1.

mistachkin 2015-10-21 20:39 trunk
Commit 3f21421a5137cd0cff3c195d4f72fe326ae72036
--- src/th_main.c
+++ src/th_main.c
@@ -510,10 +510,32 @@
510510
zOut = htmlize((char*)argv[1], argl[1]);
511511
Th_SetResult(interp, zOut, -1);
512512
free(zOut);
513513
return TH_OK;
514514
}
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
+}
515537
516538
/*
517539
** TH1 command: date
518540
**
519541
** Return a string which is the current time and date. If the
@@ -1727,10 +1749,11 @@
17271749
{"combobox", comboboxCmd, 0},
17281750
{"date", dateCmd, 0},
17291751
{"decorate", wikiCmd, (void*)&aFlags[2]},
17301752
{"dir", dirCmd, 0},
17311753
{"enable_output", enableOutputCmd, 0},
1754
+ {"encode64", encode64Cmd, 0},
17321755
{"getParameter", getParameterCmd, 0},
17331756
{"glob_match", globMatchCmd, 0},
17341757
{"globalState", globalStateCmd, 0},
17351758
{"httpize", httpizeCmd, 0},
17361759
{"hascap", hascapCmd, (void*)&zeroInt},
17371760
--- 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
--- test/th1.test
+++ test/th1.test
@@ -1245,5 +1245,15 @@
12451245
<h2>Other Features</h2>
12461246
<p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p>
12471247
12481248
</div>
12491249
}}}
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="}
12501260
--- 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
--- www/changes.wiki
+++ www/changes.wiki
@@ -12,23 +12,23 @@
1212
tags of a "check-in".
1313
* Fix bug in [/help?cmd=import|import] command, handling version 3 of
1414
the svndump format for subversion.
1515
* Add the [/help?cmd=all|all cache] command.
1616
* 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
1818
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
2222
the Tcl integration subsystem.</li>
2323
<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>
2525
</ul>
2626
* Add the --undo option to the [/help?cmd=diff|diff] command.
2727
* Build-in Antirez's "linenoise" command-linen editing library for use with
2828
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
3030
[/help?cmd=stash|stash show] command.
3131
* Updated the built-in SQLite to version 3.9.1 and activated JSON1 and FTS5
3232
support (both currently unused within Fossil).
3333
3434
<h2>Changes for Version 1.33 (2015-05-23)</h2>
3535
--- 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 @@
131131
* combobox
132132
* date
133133
* decorate
134134
* dir
135135
* enable_output
136
+ * encode64
136137
* getParameter
137138
* glob_match
138139
* globalState
139140
* hascap
140141
* hasfeature
@@ -255,10 +256,17 @@
255256
* enable_output BOOLEAN
256257
257258
Enable or disable sending output when the combobox, puts, or wiki
258259
commands are used.
259260
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
+
260268
<a name="getParameter"></a>TH1 getParameter Command
261269
---------------------------------------------------
262270
263271
* getParameter NAME ?DEFAULT?
264272
265273
--- 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

Keyboard Shortcuts

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