| | @@ -139,11 +139,11 @@ |
| 139 | 139 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /* |
| 144 | | -** TH1 command: httpize STRING |
| 144 | +** TH1 command: httpize STRING |
| 145 | 145 | ** |
| 146 | 146 | ** Escape all characters of STRING which have special meaning in URI |
| 147 | 147 | ** components. Return a new string result. |
| 148 | 148 | */ |
| 149 | 149 | static int httpizeCmd( |
| | @@ -167,11 +167,11 @@ |
| 167 | 167 | ** True if output is enabled. False if disabled. |
| 168 | 168 | */ |
| 169 | 169 | static int enableOutput = 1; |
| 170 | 170 | |
| 171 | 171 | /* |
| 172 | | -** TH1 command: enable_output BOOLEAN |
| 172 | +** TH1 command: enable_output BOOLEAN |
| 173 | 173 | ** |
| 174 | 174 | ** Enable or disable the puts and hputs commands. |
| 175 | 175 | */ |
| 176 | 176 | static int enableOutputCmd( |
| 177 | 177 | Th_Interp *interp, |
| | @@ -242,12 +242,12 @@ |
| 242 | 242 | sendText(forceCgi || g.cgiOutput ? "</p>" : "\n", -1, 0); |
| 243 | 243 | enableOutput = savedEnable; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /* |
| 247 | | -** TH1 command: puts STRING |
| 248 | | -** TH1 command: html STRING |
| 247 | +** TH1 command: puts STRING |
| 248 | +** TH1 command: html STRING |
| 249 | 249 | ** |
| 250 | 250 | ** Output STRING escaped for HTML (html) or unchanged (puts). |
| 251 | 251 | */ |
| 252 | 252 | static int putsCmd( |
| 253 | 253 | Th_Interp *interp, |
| | @@ -262,11 +262,11 @@ |
| 262 | 262 | sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert); |
| 263 | 263 | return TH_OK; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /* |
| 267 | | -** TH1 command: wiki STRING |
| 267 | +** TH1 command: wiki STRING |
| 268 | 268 | ** |
| 269 | 269 | ** Render the input string as wiki. |
| 270 | 270 | */ |
| 271 | 271 | static int wikiCmd( |
| 272 | 272 | Th_Interp *interp, |
| | @@ -287,11 +287,11 @@ |
| 287 | 287 | } |
| 288 | 288 | return TH_OK; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /* |
| 292 | | -** TH1 command: htmlize STRING |
| 292 | +** TH1 command: htmlize STRING |
| 293 | 293 | ** |
| 294 | 294 | ** Escape all characters of STRING which have special meaning in HTML. |
| 295 | 295 | ** Return a new string result. |
| 296 | 296 | */ |
| 297 | 297 | static int htmlizeCmd( |
| | @@ -310,11 +310,11 @@ |
| 310 | 310 | free(zOut); |
| 311 | 311 | return TH_OK; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /* |
| 315 | | -** TH1 command: date |
| 315 | +** TH1 command: date |
| 316 | 316 | ** |
| 317 | 317 | ** Return a string which is the current time and date. If the |
| 318 | 318 | ** -local option is used, the date appears using localtime instead |
| 319 | 319 | ** of UTC. |
| 320 | 320 | */ |
| | @@ -335,11 +335,11 @@ |
| 335 | 335 | free(zOut); |
| 336 | 336 | return TH_OK; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /* |
| 340 | | -** TH1 command: hascap STRING... |
| 340 | +** TH1 command: hascap STRING... |
| 341 | 341 | ** |
| 342 | 342 | ** Return true if the user has all of the capabilities listed in STRING. |
| 343 | 343 | */ |
| 344 | 344 | static int hascapCmd( |
| 345 | 345 | Th_Interp *interp, |
| | @@ -361,11 +361,11 @@ |
| 361 | 361 | Th_SetResultInt(interp, rc); |
| 362 | 362 | return TH_OK; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /* |
| 366 | | -** TH1 command: hasfeature STRING |
| 366 | +** TH1 command: hasfeature STRING |
| 367 | 367 | ** |
| 368 | 368 | ** Return true if the fossil binary has the given compile-time feature |
| 369 | 369 | ** enabled. The set of features includes: |
| 370 | 370 | ** |
| 371 | 371 | ** "ssl" = FOSSIL_ENABLE_SSL |
| | @@ -439,11 +439,11 @@ |
| 439 | 439 | return TH_OK; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | /* |
| 444 | | -** TH1 command: tclReady |
| 444 | +** TH1 command: tclReady |
| 445 | 445 | ** |
| 446 | 446 | ** Return true if the fossil binary has the Tcl integration feature |
| 447 | 447 | ** enabled and it is currently available for use by TH1 scripts. |
| 448 | 448 | ** |
| 449 | 449 | */ |
| | @@ -470,11 +470,11 @@ |
| 470 | 470 | return TH_OK; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | |
| 474 | 474 | /* |
| 475 | | -** TH1 command: anycap STRING |
| 475 | +** TH1 command: anycap STRING |
| 476 | 476 | ** |
| 477 | 477 | ** Return true if the user has any one of the capabilities listed in STRING. |
| 478 | 478 | */ |
| 479 | 479 | static int anycapCmd( |
| 480 | 480 | Th_Interp *interp, |
| | @@ -497,11 +497,11 @@ |
| 497 | 497 | Th_SetResultInt(interp, rc); |
| 498 | 498 | return TH_OK; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | /* |
| 502 | | -** TH1 command: combobox NAME TEXT-LIST NUMLINES |
| 502 | +** TH1 command: combobox NAME TEXT-LIST NUMLINES |
| 503 | 503 | ** |
| 504 | 504 | ** Generate an HTML combobox. NAME is both the name of the |
| 505 | 505 | ** CGI parameter and the name of a variable that contains the |
| 506 | 506 | ** currently selected value. TEXT-LIST is a list of possible |
| 507 | 507 | ** values for the combobox. NUMLINES is 1 for a true combobox. |
| | @@ -557,11 +557,11 @@ |
| 557 | 557 | } |
| 558 | 558 | return TH_OK; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | /* |
| 562 | | -** TH1 command: linecount STRING MAX MIN |
| 562 | +** TH1 command: linecount STRING MAX MIN |
| 563 | 563 | ** |
| 564 | 564 | ** Return one more than the number of \n characters in STRING. But |
| 565 | 565 | ** never return less than MIN or more than MAX. |
| 566 | 566 | */ |
| 567 | 567 | static int linecntCmd( |
| | @@ -592,11 +592,11 @@ |
| 592 | 592 | Th_SetResultInt(interp, n); |
| 593 | 593 | return TH_OK; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /* |
| 597 | | -** TH1 command: repository ?BOOLEAN? |
| 597 | +** TH1 command: repository ?BOOLEAN? |
| 598 | 598 | ** |
| 599 | 599 | ** Return the fully qualified file name of the open repository or an empty |
| 600 | 600 | ** string if one is not currently open. Optionally, it will attempt to open |
| 601 | 601 | ** the repository if the boolean argument is non-zero. |
| 602 | 602 | */ |
| | @@ -620,11 +620,11 @@ |
| 620 | 620 | Th_SetResult(interp, g.zRepositoryName, -1); |
| 621 | 621 | return TH_OK; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /* |
| 625 | | -** TH1 command: checkout ?BOOLEAN? |
| 625 | +** TH1 command: checkout ?BOOLEAN? |
| 626 | 626 | ** |
| 627 | 627 | ** Return the fully qualified directory name of the current checkout or an |
| 628 | 628 | ** empty string if it is not available. Optionally, it will attempt to find |
| 629 | 629 | ** the current checkout, opening the configuration ("user") database and the |
| 630 | 630 | ** repository as necessary, if the boolean argument is non-zero. |
| | @@ -649,11 +649,11 @@ |
| 649 | 649 | Th_SetResult(interp, g.zLocalRoot, -1); |
| 650 | 650 | return TH_OK; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /* |
| 654 | | -** TH1 command: trace STRING |
| 654 | +** TH1 command: trace STRING |
| 655 | 655 | ** |
| 656 | 656 | ** Generate a TH1 trace message if debugging is enabled. |
| 657 | 657 | */ |
| 658 | 658 | static int traceCmd( |
| 659 | 659 | Th_Interp *interp, |
| | @@ -671,11 +671,11 @@ |
| 671 | 671 | Th_SetResult(interp, 0, 0); |
| 672 | 672 | return TH_OK; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /* |
| 676 | | -** TH1 command: getParameter NAME ?DEFAULT? |
| 676 | +** TH1 command: getParameter NAME ?DEFAULT? |
| 677 | 677 | ** |
| 678 | 678 | ** Return the value of the specified query parameter or the specified default |
| 679 | 679 | ** value when there is no matching query parameter. |
| 680 | 680 | */ |
| 681 | 681 | static int getParameterCmd( |
| | @@ -695,11 +695,11 @@ |
| 695 | 695 | Th_SetResult(interp, cgi_parameter(argv[1], zDefault), -1); |
| 696 | 696 | return TH_OK; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /* |
| 700 | | -** TH1 command: setParameter NAME VALUE |
| 700 | +** TH1 command: setParameter NAME VALUE |
| 701 | 701 | ** |
| 702 | 702 | ** Sets the value of the specified query parameter. |
| 703 | 703 | */ |
| 704 | 704 | static int setParameterCmd( |
| 705 | 705 | Th_Interp *interp, |
| | @@ -714,11 +714,11 @@ |
| 714 | 714 | cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2])); |
| 715 | 715 | return TH_OK; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /* |
| 719 | | -** TH1 command: render STRING |
| 719 | +** TH1 command: render STRING |
| 720 | 720 | ** |
| 721 | 721 | ** Renders the template and writes the results. |
| 722 | 722 | */ |
| 723 | 723 | static int renderCmd( |
| 724 | 724 | Th_Interp *interp, |
| | @@ -735,11 +735,11 @@ |
| 735 | 735 | Th_SetResult(interp, 0, 0); |
| 736 | 736 | return rc; |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | /* |
| 740 | | -** TH1 command: styleHeader TITLE |
| 740 | +** TH1 command: styleHeader TITLE |
| 741 | 741 | ** |
| 742 | 742 | ** Render the configured style header. |
| 743 | 743 | */ |
| 744 | 744 | static int styleHeaderCmd( |
| 745 | 745 | Th_Interp *interp, |
| | @@ -760,11 +760,11 @@ |
| 760 | 760 | return TH_ERROR; |
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | /* |
| 765 | | -** TH1 command: styleFooter |
| 765 | +** TH1 command: styleFooter |
| 766 | 766 | ** |
| 767 | 767 | ** Render the configured style footer. |
| 768 | 768 | */ |
| 769 | 769 | static int styleFooterCmd( |
| 770 | 770 | Th_Interp *interp, |
| | @@ -778,10 +778,44 @@ |
| 778 | 778 | } |
| 779 | 779 | if( Th_IsRepositoryOpen() ){ |
| 780 | 780 | style_footer(); |
| 781 | 781 | Th_SetResult(interp, 0, 0); |
| 782 | 782 | return TH_OK; |
| 783 | + }else{ |
| 784 | + Th_SetResult(interp, "repository unavailable", -1); |
| 785 | + return TH_ERROR; |
| 786 | + } |
| 787 | +} |
| 788 | + |
| 789 | +/* |
| 790 | +** TH1 command: artifact ID |
| 791 | +** |
| 792 | +** Attempts to locate the specified artifact and return its contents. An |
| 793 | +** error is generated if the repository is not open or the artifact cannot |
| 794 | +** be found. |
| 795 | +*/ |
| 796 | +static int artifactCmd( |
| 797 | + Th_Interp *interp, |
| 798 | + void *p, |
| 799 | + int argc, |
| 800 | + const char **argv, |
| 801 | + int *argl |
| 802 | +){ |
| 803 | + if( argc!=2 ){ |
| 804 | + return Th_WrongNumArgs(interp, "artifact ID"); |
| 805 | + } |
| 806 | + if( Th_IsRepositoryOpen() ){ |
| 807 | + int rid; |
| 808 | + Blob content; |
| 809 | + rid = name_to_rid(argv[1]); |
| 810 | + if( rid!=0 && content_get(rid, &content) ){ |
| 811 | + Th_SetResult(interp, blob_str(&content), blob_size(&content)); |
| 812 | + return TH_OK; |
| 813 | + }else{ |
| 814 | + Th_SetResult(interp, "artifact not found", -1); |
| 815 | + return TH_ERROR; |
| 816 | + } |
| 783 | 817 | }else{ |
| 784 | 818 | Th_SetResult(interp, "repository unavailable", -1); |
| 785 | 819 | return TH_ERROR; |
| 786 | 820 | } |
| 787 | 821 | } |
| | @@ -823,11 +857,11 @@ |
| 823 | 857 | } |
| 824 | 858 | #endif |
| 825 | 859 | } |
| 826 | 860 | |
| 827 | 861 | /* |
| 828 | | -** TH1 command: utime |
| 862 | +** TH1 command: utime |
| 829 | 863 | ** |
| 830 | 864 | ** Return the number of microseconds of CPU time consumed by the current |
| 831 | 865 | ** process in user space. |
| 832 | 866 | */ |
| 833 | 867 | static int utimeCmd( |
| | @@ -844,11 +878,11 @@ |
| 844 | 878 | Th_SetResult(interp, zUTime, -1); |
| 845 | 879 | return TH_OK; |
| 846 | 880 | } |
| 847 | 881 | |
| 848 | 882 | /* |
| 849 | | -** TH1 command: stime |
| 883 | +** TH1 command: stime |
| 850 | 884 | ** |
| 851 | 885 | ** Return the number of microseconds of CPU time consumed by the current |
| 852 | 886 | ** process in system space. |
| 853 | 887 | */ |
| 854 | 888 | static int stimeCmd( |
| | @@ -866,11 +900,11 @@ |
| 866 | 900 | return TH_OK; |
| 867 | 901 | } |
| 868 | 902 | |
| 869 | 903 | |
| 870 | 904 | /* |
| 871 | | -** TH1 command: randhex N |
| 905 | +** TH1 command: randhex N |
| 872 | 906 | ** |
| 873 | 907 | ** Return N*2 random hexadecimal digits with N<50. If N is omitted, |
| 874 | 908 | ** use a value of 10. |
| 875 | 909 | */ |
| 876 | 910 | static int randhexCmd( |
| | @@ -900,11 +934,11 @@ |
| 900 | 934 | Th_SetResult(interp, (const char *)zOut, -1); |
| 901 | 935 | return TH_OK; |
| 902 | 936 | } |
| 903 | 937 | |
| 904 | 938 | /* |
| 905 | | -** TH1 command: query SQL CODE |
| 939 | +** TH1 command: query SQL CODE |
| 906 | 940 | ** |
| 907 | 941 | ** Run the SQL query given by the SQL argument. For each row in the result |
| 908 | 942 | ** set, run CODE. |
| 909 | 943 | ** |
| 910 | 944 | ** In SQL, parameters such as $var are filled in using the value of variable |
| | @@ -982,11 +1016,11 @@ |
| 982 | 1016 | } |
| 983 | 1017 | return res; |
| 984 | 1018 | } |
| 985 | 1019 | |
| 986 | 1020 | /* |
| 987 | | -** TH1 command: setting name |
| 1021 | +** TH1 command: setting name |
| 988 | 1022 | ** |
| 989 | 1023 | ** Gets and returns the value of the specified Fossil setting. |
| 990 | 1024 | */ |
| 991 | 1025 | #define SETTING_WRONGNUMARGS "setting ?-strict? ?--? name" |
| 992 | 1026 | static int settingCmd( |
| | @@ -1027,11 +1061,11 @@ |
| 1027 | 1061 | } |
| 1028 | 1062 | return rc; |
| 1029 | 1063 | } |
| 1030 | 1064 | |
| 1031 | 1065 | /* |
| 1032 | | -** TH1 command: regexp ?-nocase? ?--? exp string |
| 1066 | +** TH1 command: regexp ?-nocase? ?--? exp string |
| 1033 | 1067 | ** |
| 1034 | 1068 | ** Checks the string against the specified regular expression and returns |
| 1035 | 1069 | ** non-zero if it matches. If the regular expression is invalid or cannot |
| 1036 | 1070 | ** be compiled, an error will be generated. |
| 1037 | 1071 | */ |
| | @@ -1070,11 +1104,11 @@ |
| 1070 | 1104 | re_free(pRe); |
| 1071 | 1105 | return rc; |
| 1072 | 1106 | } |
| 1073 | 1107 | |
| 1074 | 1108 | /* |
| 1075 | | -** TH1 command: http ?-asynchronous? ?--? url ?payload? |
| 1109 | +** TH1 command: http ?-asynchronous? ?--? url ?payload? |
| 1076 | 1110 | ** |
| 1077 | 1111 | ** Perform an HTTP or HTTPS request for the specified URL. If a |
| 1078 | 1112 | ** payload is present, it will be interpreted as text/plain and |
| 1079 | 1113 | ** the POST method will be used; otherwise, the GET method will |
| 1080 | 1114 | ** be used. Upon success, if the -asynchronous option is used, an |
| | @@ -1244,10 +1278,11 @@ |
| 1244 | 1278 | const char *zName; |
| 1245 | 1279 | Th_CommandProc xProc; |
| 1246 | 1280 | void *pContext; |
| 1247 | 1281 | } aCommand[] = { |
| 1248 | 1282 | {"anycap", anycapCmd, 0}, |
| 1283 | + {"artifact", artifactCmd, 0}, |
| 1249 | 1284 | {"checkout", checkoutCmd, 0}, |
| 1250 | 1285 | {"combobox", comboboxCmd, 0}, |
| 1251 | 1286 | {"date", dateCmd, 0}, |
| 1252 | 1287 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1253 | 1288 | {"enable_output", enableOutputCmd, 0}, |
| 1254 | 1289 | |