Fossil SCM
Add the 'redirect' command to TH1.
Commit
71caba53bdc3d71fc08745341a9c52537c123a2c
Parent
352e2ef9c62efd0…
2 files changed
+22
+8
+22
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -430,10 +430,31 @@ | ||
| 430 | 430 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 431 | 431 | } |
| 432 | 432 | sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert); |
| 433 | 433 | return TH_OK; |
| 434 | 434 | } |
| 435 | + | |
| 436 | +/* | |
| 437 | +** TH1 command: redirect URL | |
| 438 | +** | |
| 439 | +** Issues an HTTP redirect (302) to the specified URL and then exits the | |
| 440 | +** process. | |
| 441 | +*/ | |
| 442 | +static int redirectCmd( | |
| 443 | + Th_Interp *interp, | |
| 444 | + void *p, | |
| 445 | + int argc, | |
| 446 | + const char **argv, | |
| 447 | + int *argl | |
| 448 | +){ | |
| 449 | + if( argc!=2 ){ | |
| 450 | + return Th_WrongNumArgs(interp, "redirect URL"); | |
| 451 | + } | |
| 452 | + cgi_redirect(argv[1]); | |
| 453 | + Th_SetResult(interp, argv[1], argl[1]); /* NOT REACHED */ | |
| 454 | + return TH_OK; | |
| 455 | +} | |
| 435 | 456 | |
| 436 | 457 | /* |
| 437 | 458 | ** TH1 command: markdown STRING |
| 438 | 459 | ** |
| 439 | 460 | ** Renders the input string as markdown. The result is a two-element list. |
| @@ -1772,10 +1793,11 @@ | ||
| 1772 | 1793 | {"linecount", linecntCmd, 0}, |
| 1773 | 1794 | {"markdown", markdownCmd, 0}, |
| 1774 | 1795 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 1775 | 1796 | {"query", queryCmd, 0}, |
| 1776 | 1797 | {"randhex", randhexCmd, 0}, |
| 1798 | + {"redirect", redirectCmd, 0}, | |
| 1777 | 1799 | {"regexp", regexpCmd, 0}, |
| 1778 | 1800 | {"reinitialize", reinitializeCmd, 0}, |
| 1779 | 1801 | {"render", renderCmd, 0}, |
| 1780 | 1802 | {"repository", repositoryCmd, 0}, |
| 1781 | 1803 | {"searchable", searchableCmd, 0}, |
| 1782 | 1804 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -430,10 +430,31 @@ | |
| 430 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 431 | } |
| 432 | sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert); |
| 433 | return TH_OK; |
| 434 | } |
| 435 | |
| 436 | /* |
| 437 | ** TH1 command: markdown STRING |
| 438 | ** |
| 439 | ** Renders the input string as markdown. The result is a two-element list. |
| @@ -1772,10 +1793,11 @@ | |
| 1772 | {"linecount", linecntCmd, 0}, |
| 1773 | {"markdown", markdownCmd, 0}, |
| 1774 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 1775 | {"query", queryCmd, 0}, |
| 1776 | {"randhex", randhexCmd, 0}, |
| 1777 | {"regexp", regexpCmd, 0}, |
| 1778 | {"reinitialize", reinitializeCmd, 0}, |
| 1779 | {"render", renderCmd, 0}, |
| 1780 | {"repository", repositoryCmd, 0}, |
| 1781 | {"searchable", searchableCmd, 0}, |
| 1782 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -430,10 +430,31 @@ | |
| 430 | return Th_WrongNumArgs(interp, "puts STRING"); |
| 431 | } |
| 432 | sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert); |
| 433 | return TH_OK; |
| 434 | } |
| 435 | |
| 436 | /* |
| 437 | ** TH1 command: redirect URL |
| 438 | ** |
| 439 | ** Issues an HTTP redirect (302) to the specified URL and then exits the |
| 440 | ** process. |
| 441 | */ |
| 442 | static int redirectCmd( |
| 443 | Th_Interp *interp, |
| 444 | void *p, |
| 445 | int argc, |
| 446 | const char **argv, |
| 447 | int *argl |
| 448 | ){ |
| 449 | if( argc!=2 ){ |
| 450 | return Th_WrongNumArgs(interp, "redirect URL"); |
| 451 | } |
| 452 | cgi_redirect(argv[1]); |
| 453 | Th_SetResult(interp, argv[1], argl[1]); /* NOT REACHED */ |
| 454 | return TH_OK; |
| 455 | } |
| 456 | |
| 457 | /* |
| 458 | ** TH1 command: markdown STRING |
| 459 | ** |
| 460 | ** Renders the input string as markdown. The result is a two-element list. |
| @@ -1772,10 +1793,11 @@ | |
| 1793 | {"linecount", linecntCmd, 0}, |
| 1794 | {"markdown", markdownCmd, 0}, |
| 1795 | {"puts", putsCmd, (void*)&aFlags[1]}, |
| 1796 | {"query", queryCmd, 0}, |
| 1797 | {"randhex", randhexCmd, 0}, |
| 1798 | {"redirect", redirectCmd, 0}, |
| 1799 | {"regexp", regexpCmd, 0}, |
| 1800 | {"reinitialize", reinitializeCmd, 0}, |
| 1801 | {"render", renderCmd, 0}, |
| 1802 | {"repository", repositoryCmd, 0}, |
| 1803 | {"searchable", searchableCmd, 0}, |
| 1804 |
+8
| --- www/th1.md | ||
| +++ www/th1.md | ||
| @@ -422,10 +422,18 @@ | ||
| 422 | 422 | |
| 423 | 423 | * randhex N |
| 424 | 424 | |
| 425 | 425 | Returns a string of N*2 random hexadecimal digits with N<50. If N is |
| 426 | 426 | omitted, use a value of 10. |
| 427 | + | |
| 428 | +<a name="redirect"></a>TH1 redirect Command | |
| 429 | +------------------------------------------- | |
| 430 | + | |
| 431 | + * redirect URL | |
| 432 | + | |
| 433 | +Issues an HTTP redirect (302) to the specified URL and then exits the | |
| 434 | +process. | |
| 427 | 435 | |
| 428 | 436 | <a name="regexp"></a>TH1 regexp Command |
| 429 | 437 | --------------------------------------- |
| 430 | 438 | |
| 431 | 439 | * regexp ?-nocase? ?--? exp string |
| 432 | 440 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -422,10 +422,18 @@ | |
| 422 | |
| 423 | * randhex N |
| 424 | |
| 425 | Returns a string of N*2 random hexadecimal digits with N<50. If N is |
| 426 | omitted, use a value of 10. |
| 427 | |
| 428 | <a name="regexp"></a>TH1 regexp Command |
| 429 | --------------------------------------- |
| 430 | |
| 431 | * regexp ?-nocase? ?--? exp string |
| 432 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -422,10 +422,18 @@ | |
| 422 | |
| 423 | * randhex N |
| 424 | |
| 425 | Returns a string of N*2 random hexadecimal digits with N<50. If N is |
| 426 | omitted, use a value of 10. |
| 427 | |
| 428 | <a name="redirect"></a>TH1 redirect Command |
| 429 | ------------------------------------------- |
| 430 | |
| 431 | * redirect URL |
| 432 | |
| 433 | Issues an HTTP redirect (302) to the specified URL and then exits the |
| 434 | process. |
| 435 | |
| 436 | <a name="regexp"></a>TH1 regexp Command |
| 437 | --------------------------------------- |
| 438 | |
| 439 | * regexp ?-nocase? ?--? exp string |
| 440 |