Fossil SCM

Added configure option --enable-json to enable json features. They are disabled by default.

json-demo 2011-11-04 20:37 json-multitag-test
Commit 525816e6d731d4bcf017a6f592643dae71e57176
+5
--- auto.def
+++ auto.def
@@ -8,10 +8,11 @@
88
with-zlib:path => {Look for zlib in the given path}
99
internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
1010
static=0 => {Link a static executable}
1111
lineedit=1 => {Disable line editing}
1212
fossil-debug=0 => {Build with fossil debugging enabled}
13
+ json=0 => {Build with fossil JSON API enabled}
1314
}
1415
1516
# sqlite wants these types if possible
1617
cc-with {-includes {stdint.h inttypes.h}} {
1718
cc-check-types uint32_t uint16_t int16_t uint8_t
@@ -61,10 +62,14 @@
6162
}
6263
6364
if {[opt-bool fossil-debug]} {
6465
define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
6566
}
67
+
68
+if {[opt-bool json]} {
69
+ define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
70
+}
6671
6772
if {[opt-bool static]} {
6873
# XXX: This will not work on all systems.
6974
define-append EXTRA_LDFLAGS -static
7075
}
7176
--- auto.def
+++ auto.def
@@ -8,10 +8,11 @@
8 with-zlib:path => {Look for zlib in the given path}
9 internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
10 static=0 => {Link a static executable}
11 lineedit=1 => {Disable line editing}
12 fossil-debug=0 => {Build with fossil debugging enabled}
 
13 }
14
15 # sqlite wants these types if possible
16 cc-with {-includes {stdint.h inttypes.h}} {
17 cc-check-types uint32_t uint16_t int16_t uint8_t
@@ -61,10 +62,14 @@
61 }
62
63 if {[opt-bool fossil-debug]} {
64 define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
65 }
 
 
 
 
66
67 if {[opt-bool static]} {
68 # XXX: This will not work on all systems.
69 define-append EXTRA_LDFLAGS -static
70 }
71
--- auto.def
+++ auto.def
@@ -8,10 +8,11 @@
8 with-zlib:path => {Look for zlib in the given path}
9 internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
10 static=0 => {Link a static executable}
11 lineedit=1 => {Disable line editing}
12 fossil-debug=0 => {Build with fossil debugging enabled}
13 json=0 => {Build with fossil JSON API enabled}
14 }
15
16 # sqlite wants these types if possible
17 cc-with {-includes {stdint.h inttypes.h}} {
18 cc-check-types uint32_t uint16_t int16_t uint8_t
@@ -61,10 +62,14 @@
62 }
63
64 if {[opt-bool fossil-debug]} {
65 define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
66 }
67
68 if {[opt-bool json]} {
69 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
70 }
71
72 if {[opt-bool static]} {
73 # XXX: This will not work on all systems.
74 define-append EXTRA_LDFLAGS -static
75 }
76
+17 -5
--- src/cgi.c
+++ src/cgi.c
@@ -508,11 +508,13 @@
508508
zValue = "";
509509
}
510510
if( fossil_islower(zName[0]) ){
511511
cgi_set_parameter_nocopy(zName, zValue);
512512
}
513
+#ifdef FOSSIL_ENABLE_JSON
513514
json_setenv( zName, cson_value_new_string(zValue,strlen(zValue)) );
515
+#endif /* FOSSIL_ENABLE_JSON */
514516
}
515517
}
516518
517519
/*
518520
** *pz is a string that consists of multiple lines of text. This
@@ -683,10 +685,11 @@
683685
}
684686
}
685687
}
686688
687689
690
+#ifdef FOSSIL_ENABLE_JSON
688691
/*
689692
** Internal helper for cson_data_source_FILE_n().
690693
*/
691694
typedef struct CgiPostReadState_ {
692695
FILE * fh;
@@ -756,10 +759,11 @@
756759
invalidRequest:
757760
cgi_set_content_type(json_guess_content_type());
758761
json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
759762
fossil_exit( g.isHTTP ? 0 : 1);
760763
}
764
+#endif /* FOSSIL_ENABLE_JSON */
761765
762766
763767
/*
764768
** Initialize the query parameter database. Information is pulled from
765769
** the QUERY_STRING environment variable (if it exists), from standard
@@ -767,11 +771,13 @@
767771
*/
768772
void cgi_init(void){
769773
char *z;
770774
const char *zType;
771775
int len;
776
+#ifdef FOSSIL_ENABLE_JSON
772777
json_main_bootstrap();
778
+#endif
773779
g.isHTTP = 1;
774780
cgi_destination(CGI_BODY);
775781
776782
z = (char*)P("HTTP_COOKIE");
777783
if( z ){
@@ -809,11 +815,13 @@
809815
blob_uncompress(&g.cgiIn, &g.cgiIn);
810816
}else if( fossil_strcmp(zType, "application/x-fossil-debug")==0 ){
811817
blob_read_from_channel(&g.cgiIn, g.httpIn, len);
812818
}else if( fossil_strcmp(zType, "application/x-fossil-uncompressed")==0 ){
813819
blob_read_from_channel(&g.cgiIn, g.httpIn, len);
814
- }else if( fossil_strcmp(zType, "application/json")
820
+ }
821
+#ifdef FOSSIL_ENABLE_JSON
822
+ else if( fossil_strcmp(zType, "application/json")
815823
|| fossil_strcmp(zType,"text/plain")/*assume this MIGHT be JSON*/
816824
|| fossil_strcmp(zType,"application/javascript")){
817825
g.json.isJsonMode = 1;
818826
cgi_parse_POST_JSON(g.httpIn, (unsigned int)len);
819827
/* FIXMEs:
@@ -831,10 +839,11 @@
831839
over like-named POST entries, but in order for that to happen we
832840
need to process QUERY_STRING _after_ reading the POST data.
833841
*/
834842
cgi_set_content_type(json_guess_content_type());
835843
}
844
+#endif /* FOSSIL_ENABLE_JSON */
836845
}
837846
838847
}
839848
840849
/*
@@ -1046,24 +1055,27 @@
10461055
** Panic and die while processing a webpage.
10471056
*/
10481057
NORETURN void cgi_panic(const char *zFormat, ...){
10491058
va_list ap;
10501059
cgi_reset_content();
1060
+#ifdef FOSSIL_ENABLE_JSON
10511061
if( g.json.isJsonMode ){
10521062
char * zMsg;
10531063
va_start(ap, zFormat);
10541064
zMsg = vmprintf(zFormat,ap);
10551065
va_end(ap);
10561066
json_err( FSL_JSON_E_PANIC, zMsg, 1 );
10571067
free(zMsg);
10581068
fossil_exit( g.isHTTP ? 0 : 1 );
1059
- }else{
1069
+ }else
1070
+#endif /* FOSSIL_ENABLE_JSON */
1071
+ {
10601072
cgi_set_status(500, "Internal Server Error");
10611073
cgi_printf(
1062
- "<html><body><h1>Internal Server Error</h1>\n"
1063
- "<plaintext>"
1064
- );
1074
+ "<html><body><h1>Internal Server Error</h1>\n"
1075
+ "<plaintext>"
1076
+ );
10651077
va_start(ap, zFormat);
10661078
vxprintf(pContent,zFormat,ap);
10671079
va_end(ap);
10681080
cgi_reply();
10691081
fossil_exit(1);
10701082
--- src/cgi.c
+++ src/cgi.c
@@ -508,11 +508,13 @@
508 zValue = "";
509 }
510 if( fossil_islower(zName[0]) ){
511 cgi_set_parameter_nocopy(zName, zValue);
512 }
 
513 json_setenv( zName, cson_value_new_string(zValue,strlen(zValue)) );
 
514 }
515 }
516
517 /*
518 ** *pz is a string that consists of multiple lines of text. This
@@ -683,10 +685,11 @@
683 }
684 }
685 }
686
687
 
688 /*
689 ** Internal helper for cson_data_source_FILE_n().
690 */
691 typedef struct CgiPostReadState_ {
692 FILE * fh;
@@ -756,10 +759,11 @@
756 invalidRequest:
757 cgi_set_content_type(json_guess_content_type());
758 json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
759 fossil_exit( g.isHTTP ? 0 : 1);
760 }
 
761
762
763 /*
764 ** Initialize the query parameter database. Information is pulled from
765 ** the QUERY_STRING environment variable (if it exists), from standard
@@ -767,11 +771,13 @@
767 */
768 void cgi_init(void){
769 char *z;
770 const char *zType;
771 int len;
 
772 json_main_bootstrap();
 
773 g.isHTTP = 1;
774 cgi_destination(CGI_BODY);
775
776 z = (char*)P("HTTP_COOKIE");
777 if( z ){
@@ -809,11 +815,13 @@
809 blob_uncompress(&g.cgiIn, &g.cgiIn);
810 }else if( fossil_strcmp(zType, "application/x-fossil-debug")==0 ){
811 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
812 }else if( fossil_strcmp(zType, "application/x-fossil-uncompressed")==0 ){
813 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
814 }else if( fossil_strcmp(zType, "application/json")
 
 
815 || fossil_strcmp(zType,"text/plain")/*assume this MIGHT be JSON*/
816 || fossil_strcmp(zType,"application/javascript")){
817 g.json.isJsonMode = 1;
818 cgi_parse_POST_JSON(g.httpIn, (unsigned int)len);
819 /* FIXMEs:
@@ -831,10 +839,11 @@
831 over like-named POST entries, but in order for that to happen we
832 need to process QUERY_STRING _after_ reading the POST data.
833 */
834 cgi_set_content_type(json_guess_content_type());
835 }
 
836 }
837
838 }
839
840 /*
@@ -1046,24 +1055,27 @@
1046 ** Panic and die while processing a webpage.
1047 */
1048 NORETURN void cgi_panic(const char *zFormat, ...){
1049 va_list ap;
1050 cgi_reset_content();
 
1051 if( g.json.isJsonMode ){
1052 char * zMsg;
1053 va_start(ap, zFormat);
1054 zMsg = vmprintf(zFormat,ap);
1055 va_end(ap);
1056 json_err( FSL_JSON_E_PANIC, zMsg, 1 );
1057 free(zMsg);
1058 fossil_exit( g.isHTTP ? 0 : 1 );
1059 }else{
 
 
1060 cgi_set_status(500, "Internal Server Error");
1061 cgi_printf(
1062 "<html><body><h1>Internal Server Error</h1>\n"
1063 "<plaintext>"
1064 );
1065 va_start(ap, zFormat);
1066 vxprintf(pContent,zFormat,ap);
1067 va_end(ap);
1068 cgi_reply();
1069 fossil_exit(1);
1070
--- src/cgi.c
+++ src/cgi.c
@@ -508,11 +508,13 @@
508 zValue = "";
509 }
510 if( fossil_islower(zName[0]) ){
511 cgi_set_parameter_nocopy(zName, zValue);
512 }
513 #ifdef FOSSIL_ENABLE_JSON
514 json_setenv( zName, cson_value_new_string(zValue,strlen(zValue)) );
515 #endif /* FOSSIL_ENABLE_JSON */
516 }
517 }
518
519 /*
520 ** *pz is a string that consists of multiple lines of text. This
@@ -683,10 +685,11 @@
685 }
686 }
687 }
688
689
690 #ifdef FOSSIL_ENABLE_JSON
691 /*
692 ** Internal helper for cson_data_source_FILE_n().
693 */
694 typedef struct CgiPostReadState_ {
695 FILE * fh;
@@ -756,10 +759,11 @@
759 invalidRequest:
760 cgi_set_content_type(json_guess_content_type());
761 json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
762 fossil_exit( g.isHTTP ? 0 : 1);
763 }
764 #endif /* FOSSIL_ENABLE_JSON */
765
766
767 /*
768 ** Initialize the query parameter database. Information is pulled from
769 ** the QUERY_STRING environment variable (if it exists), from standard
@@ -767,11 +771,13 @@
771 */
772 void cgi_init(void){
773 char *z;
774 const char *zType;
775 int len;
776 #ifdef FOSSIL_ENABLE_JSON
777 json_main_bootstrap();
778 #endif
779 g.isHTTP = 1;
780 cgi_destination(CGI_BODY);
781
782 z = (char*)P("HTTP_COOKIE");
783 if( z ){
@@ -809,11 +815,13 @@
815 blob_uncompress(&g.cgiIn, &g.cgiIn);
816 }else if( fossil_strcmp(zType, "application/x-fossil-debug")==0 ){
817 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
818 }else if( fossil_strcmp(zType, "application/x-fossil-uncompressed")==0 ){
819 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
820 }
821 #ifdef FOSSIL_ENABLE_JSON
822 else if( fossil_strcmp(zType, "application/json")
823 || fossil_strcmp(zType,"text/plain")/*assume this MIGHT be JSON*/
824 || fossil_strcmp(zType,"application/javascript")){
825 g.json.isJsonMode = 1;
826 cgi_parse_POST_JSON(g.httpIn, (unsigned int)len);
827 /* FIXMEs:
@@ -831,10 +839,11 @@
839 over like-named POST entries, but in order for that to happen we
840 need to process QUERY_STRING _after_ reading the POST data.
841 */
842 cgi_set_content_type(json_guess_content_type());
843 }
844 #endif /* FOSSIL_ENABLE_JSON */
845 }
846
847 }
848
849 /*
@@ -1046,24 +1055,27 @@
1055 ** Panic and die while processing a webpage.
1056 */
1057 NORETURN void cgi_panic(const char *zFormat, ...){
1058 va_list ap;
1059 cgi_reset_content();
1060 #ifdef FOSSIL_ENABLE_JSON
1061 if( g.json.isJsonMode ){
1062 char * zMsg;
1063 va_start(ap, zFormat);
1064 zMsg = vmprintf(zFormat,ap);
1065 va_end(ap);
1066 json_err( FSL_JSON_E_PANIC, zMsg, 1 );
1067 free(zMsg);
1068 fossil_exit( g.isHTTP ? 0 : 1 );
1069 }else
1070 #endif /* FOSSIL_ENABLE_JSON */
1071 {
1072 cgi_set_status(500, "Internal Server Error");
1073 cgi_printf(
1074 "<html><body><h1>Internal Server Error</h1>\n"
1075 "<plaintext>"
1076 );
1077 va_start(ap, zFormat);
1078 vxprintf(pContent,zFormat,ap);
1079 va_end(ap);
1080 cgi_reply();
1081 fossil_exit(1);
1082
+26 -14
--- src/db.c
+++ src/db.c
@@ -72,29 +72,31 @@
7272
"need to run \"fossil all rebuild\" to bring the repository\n"
7373
"schemas up to date.\n";
7474
va_start(ap, zFormat);
7575
z = vmprintf(zFormat, ap);
7676
va_end(ap);
77
+#ifdef FOSSIL_ENABLE_JSON
7778
if( g.json.isJsonMode ){
7879
json_err( 0, z, 1 );
7980
if( g.isHTTP ){
8081
rc = 0 /* avoid HTTP 500 */;
8182
}
82
- }else{
83
- if( g.xferPanic ){
84
- cgi_reset_content();
85
- @ error Database\serror:\s%F(z)
86
- cgi_reply();
87
- }
88
- if( g.cgiOutput ){
89
- g.cgiOutput = 0;
90
- cgi_printf("<h1>Database Error</h1>\n"
91
- "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
92
- cgi_reply();
93
- }else{
94
- fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
95
- }
83
+ }
84
+ else
85
+#endif /* FOSSIL_ENABLE_JSON */
86
+ if( g.xferPanic ){
87
+ cgi_reset_content();
88
+ @ error Database\serror:\s%F(z)
89
+ cgi_reply();
90
+ }
91
+ else if( g.cgiOutput ){
92
+ g.cgiOutput = 0;
93
+ cgi_printf("<h1>Database Error</h1>\n"
94
+ "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
95
+ cgi_reply();
96
+ }else{
97
+ fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
9698
}
9799
free(z);
98100
db_force_rollback();
99101
fossil_exit(rc);
100102
}
@@ -880,18 +882,24 @@
880882
db_err("unable to find the name of a repository database");
881883
}
882884
}
883885
if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
884886
if( file_access(zDbName, 0) ){
887
+#ifdef FOSSIL_ENABLE_JSON
885888
g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
889
+#endif
886890
fossil_panic("repository does not exist or"
887891
" is in an unreadable directory: %s", zDbName);
888892
}else if( file_access(zDbName, R_OK) ){
893
+#ifdef FOSSIL_ENABLE_JSON
889894
g.json.resultCode = FSL_JSON_E_DENIED;
895
+#endif
890896
fossil_panic("read permission denied for repository %s", zDbName);
891897
}else{
898
+#ifdef FOSSIL_ENABLE_JSON
892899
g.json.resultCode = FSL_JSON_E_DB_NOT_VALID;
900
+#endif
893901
fossil_panic("not a valid repository: %s", zDbName);
894902
}
895903
}
896904
db_open_or_attach(zDbName, "repository");
897905
g.repositoryOpen = 1;
@@ -934,11 +942,13 @@
934942
if( (bFlags & OPEN_ANY_SCHEMA)==0 ) db_verify_schema();
935943
return;
936944
}
937945
rep_not_found:
938946
if( (bFlags & OPEN_OK_NOT_FOUND)==0 ){
947
+#ifdef FOSSIL_ENABLE_JSON
939948
g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
949
+#endif
940950
fossil_fatal("use --repository or -R to specify the repository database");
941951
}
942952
}
943953
944954
/*
@@ -965,11 +975,13 @@
965975
** Verify that the repository schema is correct. If it is not correct,
966976
** issue a fatal error and die.
967977
*/
968978
void db_verify_schema(void){
969979
if( db_schema_is_outofdate() ){
980
+#ifdef FOSSIL_ENABLE_JSON
970981
g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
982
+#endif
971983
fossil_warning("incorrect repository schema version");
972984
fossil_warning("your repository has schema version \"%s\" "
973985
"but this binary expects version \"%s\"",
974986
db_get("aux-schema",0), AUX_SCHEMA);
975987
fossil_fatal("run \"fossil rebuild\" to fix this problem");
976988
--- src/db.c
+++ src/db.c
@@ -72,29 +72,31 @@
72 "need to run \"fossil all rebuild\" to bring the repository\n"
73 "schemas up to date.\n";
74 va_start(ap, zFormat);
75 z = vmprintf(zFormat, ap);
76 va_end(ap);
 
77 if( g.json.isJsonMode ){
78 json_err( 0, z, 1 );
79 if( g.isHTTP ){
80 rc = 0 /* avoid HTTP 500 */;
81 }
82 }else{
83 if( g.xferPanic ){
84 cgi_reset_content();
85 @ error Database\serror:\s%F(z)
86 cgi_reply();
87 }
88 if( g.cgiOutput ){
89 g.cgiOutput = 0;
90 cgi_printf("<h1>Database Error</h1>\n"
91 "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
92 cgi_reply();
93 }else{
94 fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
95 }
 
96 }
97 free(z);
98 db_force_rollback();
99 fossil_exit(rc);
100 }
@@ -880,18 +882,24 @@
880 db_err("unable to find the name of a repository database");
881 }
882 }
883 if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
884 if( file_access(zDbName, 0) ){
 
885 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
 
886 fossil_panic("repository does not exist or"
887 " is in an unreadable directory: %s", zDbName);
888 }else if( file_access(zDbName, R_OK) ){
 
889 g.json.resultCode = FSL_JSON_E_DENIED;
 
890 fossil_panic("read permission denied for repository %s", zDbName);
891 }else{
 
892 g.json.resultCode = FSL_JSON_E_DB_NOT_VALID;
 
893 fossil_panic("not a valid repository: %s", zDbName);
894 }
895 }
896 db_open_or_attach(zDbName, "repository");
897 g.repositoryOpen = 1;
@@ -934,11 +942,13 @@
934 if( (bFlags & OPEN_ANY_SCHEMA)==0 ) db_verify_schema();
935 return;
936 }
937 rep_not_found:
938 if( (bFlags & OPEN_OK_NOT_FOUND)==0 ){
 
939 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
 
940 fossil_fatal("use --repository or -R to specify the repository database");
941 }
942 }
943
944 /*
@@ -965,11 +975,13 @@
965 ** Verify that the repository schema is correct. If it is not correct,
966 ** issue a fatal error and die.
967 */
968 void db_verify_schema(void){
969 if( db_schema_is_outofdate() ){
 
970 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
 
971 fossil_warning("incorrect repository schema version");
972 fossil_warning("your repository has schema version \"%s\" "
973 "but this binary expects version \"%s\"",
974 db_get("aux-schema",0), AUX_SCHEMA);
975 fossil_fatal("run \"fossil rebuild\" to fix this problem");
976
--- src/db.c
+++ src/db.c
@@ -72,29 +72,31 @@
72 "need to run \"fossil all rebuild\" to bring the repository\n"
73 "schemas up to date.\n";
74 va_start(ap, zFormat);
75 z = vmprintf(zFormat, ap);
76 va_end(ap);
77 #ifdef FOSSIL_ENABLE_JSON
78 if( g.json.isJsonMode ){
79 json_err( 0, z, 1 );
80 if( g.isHTTP ){
81 rc = 0 /* avoid HTTP 500 */;
82 }
83 }
84 else
85 #endif /* FOSSIL_ENABLE_JSON */
86 if( g.xferPanic ){
87 cgi_reset_content();
88 @ error Database\serror:\s%F(z)
89 cgi_reply();
90 }
91 else if( g.cgiOutput ){
92 g.cgiOutput = 0;
93 cgi_printf("<h1>Database Error</h1>\n"
94 "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
95 cgi_reply();
96 }else{
97 fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
98 }
99 free(z);
100 db_force_rollback();
101 fossil_exit(rc);
102 }
@@ -880,18 +882,24 @@
882 db_err("unable to find the name of a repository database");
883 }
884 }
885 if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
886 if( file_access(zDbName, 0) ){
887 #ifdef FOSSIL_ENABLE_JSON
888 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
889 #endif
890 fossil_panic("repository does not exist or"
891 " is in an unreadable directory: %s", zDbName);
892 }else if( file_access(zDbName, R_OK) ){
893 #ifdef FOSSIL_ENABLE_JSON
894 g.json.resultCode = FSL_JSON_E_DENIED;
895 #endif
896 fossil_panic("read permission denied for repository %s", zDbName);
897 }else{
898 #ifdef FOSSIL_ENABLE_JSON
899 g.json.resultCode = FSL_JSON_E_DB_NOT_VALID;
900 #endif
901 fossil_panic("not a valid repository: %s", zDbName);
902 }
903 }
904 db_open_or_attach(zDbName, "repository");
905 g.repositoryOpen = 1;
@@ -934,11 +942,13 @@
942 if( (bFlags & OPEN_ANY_SCHEMA)==0 ) db_verify_schema();
943 return;
944 }
945 rep_not_found:
946 if( (bFlags & OPEN_OK_NOT_FOUND)==0 ){
947 #ifdef FOSSIL_ENABLE_JSON
948 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
949 #endif
950 fossil_fatal("use --repository or -R to specify the repository database");
951 }
952 }
953
954 /*
@@ -965,11 +975,13 @@
975 ** Verify that the repository schema is correct. If it is not correct,
976 ** issue a fatal error and die.
977 */
978 void db_verify_schema(void){
979 if( db_schema_is_outofdate() ){
980 #ifdef FOSSIL_ENABLE_JSON
981 g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD;
982 #endif
983 fossil_warning("incorrect repository schema version");
984 fossil_warning("your repository has schema version \"%s\" "
985 "but this binary expects version \"%s\"",
986 db_get("aux-schema",0), AUX_SCHEMA);
987 fossil_fatal("run \"fossil rebuild\" to fix this problem");
988
+6 -4
--- src/json.c
+++ src/json.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -2267,11 +2268,11 @@
22672268
/* Last entry MUST have a NULL name. */
22682269
{NULL,NULL,0}
22692270
};
22702271
22712272
2272
-#if !defined(FOSSIL_DISABLE_JSON)
2273
+#ifdef FOSSIL_ENABLE_JSON /* dupe ifdef needed for mkindex */
22732274
/*
22742275
** WEBPAGE: json
22752276
**
22762277
** Pages under /json/... must be entered into JsonPageDefs.
22772278
** This function dispatches them, and is the HTTP equivalent of
@@ -2321,13 +2322,13 @@
23212322
blob_str(&cmdNames), 0);
23222323
blob_reset(&cmdNames);
23232324
}
23242325
23252326
}
2326
-#endif /* FOSSIL_DISABLE_JSON */
2327
+#endif /* FOSSIL_ENABLE_JSON */
23272328
2328
-#if !defined(FOSSIL_DISABLE_JSON)
2329
+#ifdef FOSSIL_ENABLE_JSON /* dupe ifdef needed for mkindex */
23292330
/*
23302331
** This function dispatches json commands and is the CLI equivalent of
23312332
** json_page_top().
23322333
**
23332334
** COMMAND: json
@@ -2417,12 +2418,13 @@
24172418
blob_str(&cmdNames), 1);
24182419
blob_reset(&cmdNames);
24192420
fossil_exit(1);
24202421
}
24212422
}
2422
-#endif /* FOSSIL_DISABLE_JSON */
2423
+#endif /* FOSSIL_ENABLE_JSON */
24232424
24242425
#undef BITSET_BYTEFOR
24252426
#undef BITSET_SET
24262427
#undef BITSET_UNSET
24272428
#undef BITSET_GET
24282429
#undef BITSET_TOGGLE
2430
+#endif /* FOSSIL_ENABLE_JSON */
24292431
--- src/json.c
+++ src/json.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -2267,11 +2268,11 @@
2267 /* Last entry MUST have a NULL name. */
2268 {NULL,NULL,0}
2269 };
2270
2271
2272 #if !defined(FOSSIL_DISABLE_JSON)
2273 /*
2274 ** WEBPAGE: json
2275 **
2276 ** Pages under /json/... must be entered into JsonPageDefs.
2277 ** This function dispatches them, and is the HTTP equivalent of
@@ -2321,13 +2322,13 @@
2321 blob_str(&cmdNames), 0);
2322 blob_reset(&cmdNames);
2323 }
2324
2325 }
2326 #endif /* FOSSIL_DISABLE_JSON */
2327
2328 #if !defined(FOSSIL_DISABLE_JSON)
2329 /*
2330 ** This function dispatches json commands and is the CLI equivalent of
2331 ** json_page_top().
2332 **
2333 ** COMMAND: json
@@ -2417,12 +2418,13 @@
2417 blob_str(&cmdNames), 1);
2418 blob_reset(&cmdNames);
2419 fossil_exit(1);
2420 }
2421 }
2422 #endif /* FOSSIL_DISABLE_JSON */
2423
2424 #undef BITSET_BYTEFOR
2425 #undef BITSET_SET
2426 #undef BITSET_UNSET
2427 #undef BITSET_GET
2428 #undef BITSET_TOGGLE
 
2429
--- src/json.c
+++ src/json.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -2267,11 +2268,11 @@
2268 /* Last entry MUST have a NULL name. */
2269 {NULL,NULL,0}
2270 };
2271
2272
2273 #ifdef FOSSIL_ENABLE_JSON /* dupe ifdef needed for mkindex */
2274 /*
2275 ** WEBPAGE: json
2276 **
2277 ** Pages under /json/... must be entered into JsonPageDefs.
2278 ** This function dispatches them, and is the HTTP equivalent of
@@ -2321,13 +2322,13 @@
2322 blob_str(&cmdNames), 0);
2323 blob_reset(&cmdNames);
2324 }
2325
2326 }
2327 #endif /* FOSSIL_ENABLE_JSON */
2328
2329 #ifdef FOSSIL_ENABLE_JSON /* dupe ifdef needed for mkindex */
2330 /*
2331 ** This function dispatches json commands and is the CLI equivalent of
2332 ** json_page_top().
2333 **
2334 ** COMMAND: json
@@ -2417,12 +2418,13 @@
2418 blob_str(&cmdNames), 1);
2419 blob_reset(&cmdNames);
2420 fossil_exit(1);
2421 }
2422 }
2423 #endif /* FOSSIL_ENABLE_JSON */
2424
2425 #undef BITSET_BYTEFOR
2426 #undef BITSET_SET
2427 #undef BITSET_UNSET
2428 #undef BITSET_GET
2429 #undef BITSET_TOGGLE
2430 #endif /* FOSSIL_ENABLE_JSON */
2431
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -409,5 +410,6 @@
409410
veryend:
410411
blob_reset(&uuid);
411412
return cson_object_value(pay);
412413
}
413414
415
+#endif /* FOSSIL_ENABLE_JSON */
414416
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -409,5 +410,6 @@
409 veryend:
410 blob_reset(&uuid);
411 return cson_object_value(pay);
412 }
413
 
414
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -409,5 +410,6 @@
410 veryend:
411 blob_reset(&uuid);
412 return cson_object_value(pay);
413 }
414
415 #endif /* FOSSIL_ENABLE_JSON */
416
--- src/json_branch.c
+++ src/json_branch.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -385,5 +386,6 @@
385386
payV = NULL;
386387
ok:
387388
return payV;
388389
}
389390
391
+#endif /* FOSSIL_ENABLE_JSON */
390392
--- src/json_branch.c
+++ src/json_branch.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -385,5 +386,6 @@
385 payV = NULL;
386 ok:
387 return payV;
388 }
389
 
390
--- src/json_branch.c
+++ src/json_branch.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -385,5 +386,6 @@
386 payV = NULL;
387 ok:
388 return payV;
389 }
390
391 #endif /* FOSSIL_ENABLE_JSON */
392
--- src/json_detail.h
+++ src/json_detail.h
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
#if !defined(FOSSIL_JSON_DETAIL_H_INCLUDED)
23
#define FOSSIL_JSON_DETAIL_H_INCLUDED
34
/*
45
** Copyright (c) 2011 D. Richard Hipp
56
**
@@ -248,5 +249,6 @@
248249
*/
249250
char fossil_has_json();
250251
251252
252253
#endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
254
+#endif /* FOSSIL_ENABLE_JSON */
253255
--- src/json_detail.h
+++ src/json_detail.h
@@ -1,5 +1,6 @@
 
1 #if !defined(FOSSIL_JSON_DETAIL_H_INCLUDED)
2 #define FOSSIL_JSON_DETAIL_H_INCLUDED
3 /*
4 ** Copyright (c) 2011 D. Richard Hipp
5 **
@@ -248,5 +249,6 @@
248 */
249 char fossil_has_json();
250
251
252 #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
 
253
--- src/json_detail.h
+++ src/json_detail.h
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 #if !defined(FOSSIL_JSON_DETAIL_H_INCLUDED)
3 #define FOSSIL_JSON_DETAIL_H_INCLUDED
4 /*
5 ** Copyright (c) 2011 D. Richard Hipp
6 **
@@ -248,5 +249,6 @@
249 */
250 char fossil_has_json();
251
252
253 #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
254 #endif /* FOSSIL_ENABLE_JSON */
255
--- src/json_diff.c
+++ src/json_diff.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -126,5 +127,6 @@
126127
v = 0;
127128
128129
return pay ? cson_object_value(pay) : NULL;
129130
}
130131
132
+#endif /* FOSSIL_ENABLE_JSON */
131133
--- src/json_diff.c
+++ src/json_diff.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -126,5 +127,6 @@
126 v = 0;
127
128 return pay ? cson_object_value(pay) : NULL;
129 }
130
 
131
--- src/json_diff.c
+++ src/json_diff.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -126,5 +127,6 @@
127 v = 0;
128
129 return pay ? cson_object_value(pay) : NULL;
130 }
131
132 #endif /* FOSSIL_ENABLE_JSON */
133
--- src/json_login.c
+++ src/json_login.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -251,5 +252,6 @@
251252
g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
252253
}
253254
db_finalize(&q);
254255
return payload;
255256
}
257
+#endif /* FOSSIL_ENABLE_JSON */
256258
--- src/json_login.c
+++ src/json_login.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -251,5 +252,6 @@
251 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
252 }
253 db_finalize(&q);
254 return payload;
255 }
 
256
--- src/json_login.c
+++ src/json_login.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -251,5 +252,6 @@
252 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
253 }
254 db_finalize(&q);
255 return payload;
256 }
257 #endif /* FOSSIL_ENABLE_JSON */
258
--- src/json_query.c
+++ src/json_query.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -83,5 +84,6 @@
8384
}
8485
return payV;
8586
8687
}
8788
89
+#endif /* FOSSIL_ENABLE_JSON */
8890
--- src/json_query.c
+++ src/json_query.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -83,5 +84,6 @@
83 }
84 return payV;
85
86 }
87
 
88
--- src/json_query.c
+++ src/json_query.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -83,5 +84,6 @@
84 }
85 return payV;
86
87 }
88
89 #endif /* FOSSIL_ENABLE_JSON */
90
--- src/json_report.c
+++ src/json_report.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -256,5 +257,6 @@
256257
}
257258
258259
static cson_value * json_report_save(){
259260
return NULL;
260261
}
262
+#endif /* FOSSIL_ENABLE_JSON */
261263
--- src/json_report.c
+++ src/json_report.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -256,5 +257,6 @@
256 }
257
258 static cson_value * json_report_save(){
259 return NULL;
260 }
 
261
--- src/json_report.c
+++ src/json_report.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -256,5 +257,6 @@
257 }
258
259 static cson_value * json_report_save(){
260 return NULL;
261 }
262 #endif /* FOSSIL_ENABLE_JSON */
263
--- src/json_tag.c
+++ src/json_tag.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -471,5 +472,6 @@
471472
if( payV && !tagsVal ){
472473
cson_object_set( pay, "tags", cson_value_null() );
473474
}
474475
return payV;
475476
}
477
+#endif /* FOSSIL_ENABLE_JSON */
476478
--- src/json_tag.c
+++ src/json_tag.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -471,5 +472,6 @@
471 if( payV && !tagsVal ){
472 cson_object_set( pay, "tags", cson_value_null() );
473 }
474 return payV;
475 }
 
476
--- src/json_tag.c
+++ src/json_tag.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -471,5 +472,6 @@
472 if( payV && !tagsVal ){
473 cson_object_set( pay, "tags", cson_value_null() );
474 }
475 return payV;
476 }
477 #endif /* FOSSIL_ENABLE_JSON */
478
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -687,5 +688,6 @@
687688
blob_reset(&sql);
688689
db_finalize(&q);
689690
return payV;
690691
}
691692
693
+#endif /* FOSSIL_ENABLE_JSON */
692694
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -687,5 +688,6 @@
687 blob_reset(&sql);
688 db_finalize(&q);
689 return payV;
690 }
691
 
692
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -687,5 +688,6 @@
688 blob_reset(&sql);
689 db_finalize(&q);
690 return payV;
691 }
692
693 #endif /* FOSSIL_ENABLE_JSON */
694
--- src/json_user.c
+++ src/json_user.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -313,5 +314,6 @@
313314
}
314315
json_user_update_from_json( u );
315316
cson_free_object(u);
316317
return NULL;
317318
}
319
+#endif /* FOSSIL_ENABLE_JSON */
318320
--- src/json_user.c
+++ src/json_user.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -313,5 +314,6 @@
313 }
314 json_user_update_from_json( u );
315 cson_free_object(u);
316 return NULL;
317 }
 
318
--- src/json_user.c
+++ src/json_user.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -313,5 +314,6 @@
314 }
315 json_user_update_from_json( u );
316 cson_free_object(u);
317 return NULL;
318 }
319 #endif /* FOSSIL_ENABLE_JSON */
320
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -1,5 +1,6 @@
1
+#ifdef FOSSIL_ENABLE_JSON
12
/*
23
** Copyright (c) 2011 D. Richard Hipp
34
**
45
** This program is free software; you can redistribute it and/or
56
** modify it under the terms of the Simplified BSD License (also
@@ -361,5 +362,6 @@
361362
listV = NULL;
362363
end:
363364
db_finalize(&q);
364365
return listV;
365366
}
367
+#endif /* FOSSIL_ENABLE_JSON */
366368
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -1,5 +1,6 @@
 
1 /*
2 ** Copyright (c) 2011 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
@@ -361,5 +362,6 @@
361 listV = NULL;
362 end:
363 db_finalize(&q);
364 return listV;
365 }
 
366
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -1,5 +1,6 @@
1 #ifdef FOSSIL_ENABLE_JSON
2 /*
3 ** Copyright (c) 2011 D. Richard Hipp
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of the Simplified BSD License (also
@@ -361,5 +362,6 @@
362 listV = NULL;
363 end:
364 db_finalize(&q);
365 return listV;
366 }
367 #endif /* FOSSIL_ENABLE_JSON */
368
+6 -1
--- src/login.c
+++ src/login.c
@@ -1060,14 +1060,19 @@
10601060
/*
10611061
** Call this routine when the credential check fails. It causes
10621062
** a redirect to the "login" page.
10631063
*/
10641064
void login_needed(void){
1065
+#ifdef FOSSIL_ENABLE_JSON
10651066
if(g.json.isJsonMode){
10661067
json_err( FSL_JSON_E_DENIED, NULL, 1 );
10671068
fossil_exit(0);
1068
- }else{
1069
+ /* NOTREACHED */
1070
+ assert(0);
1071
+ }else
1072
+#endif /* FOSSIL_ENABLE_JSON */
1073
+ {
10691074
const char *zUrl = PD("REQUEST_URI", "index");
10701075
cgi_redirect(mprintf("login?g=%T", zUrl));
10711076
/* NOTREACHED */
10721077
assert(0);
10731078
}
10741079
--- src/login.c
+++ src/login.c
@@ -1060,14 +1060,19 @@
1060 /*
1061 ** Call this routine when the credential check fails. It causes
1062 ** a redirect to the "login" page.
1063 */
1064 void login_needed(void){
 
1065 if(g.json.isJsonMode){
1066 json_err( FSL_JSON_E_DENIED, NULL, 1 );
1067 fossil_exit(0);
1068 }else{
 
 
 
 
1069 const char *zUrl = PD("REQUEST_URI", "index");
1070 cgi_redirect(mprintf("login?g=%T", zUrl));
1071 /* NOTREACHED */
1072 assert(0);
1073 }
1074
--- src/login.c
+++ src/login.c
@@ -1060,14 +1060,19 @@
1060 /*
1061 ** Call this routine when the credential check fails. It causes
1062 ** a redirect to the "login" page.
1063 */
1064 void login_needed(void){
1065 #ifdef FOSSIL_ENABLE_JSON
1066 if(g.json.isJsonMode){
1067 json_err( FSL_JSON_E_DENIED, NULL, 1 );
1068 fossil_exit(0);
1069 /* NOTREACHED */
1070 assert(0);
1071 }else
1072 #endif /* FOSSIL_ENABLE_JSON */
1073 {
1074 const char *zUrl = PD("REQUEST_URI", "index");
1075 cgi_redirect(mprintf("login?g=%T", zUrl));
1076 /* NOTREACHED */
1077 assert(0);
1078 }
1079
+77 -46
--- src/main.c
+++ src/main.c
@@ -26,13 +26,14 @@
2626
#include <sys/types.h>
2727
#include <sys/stat.h>
2828
#include <stdlib.h> /* atexit() */
2929
3030
#if INTERFACE
31
-#include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
32
-#include "json_detail.h"
33
-
31
+#ifdef FOSSIL_ENABLE_JSON
32
+# include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
33
+# include "json_detail.h"
34
+#endif
3435
/*
3536
** Number of elements in an array
3637
*/
3738
#define count(X) (sizeof(X)/sizeof(X[0]))
3839
@@ -170,10 +171,11 @@
170171
const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
171172
int anAuxCols[MX_AUX]; /* Number of columns for option() values */
172173
173174
int allowSymlinks; /* Cached "allow-symlinks" option */
174175
176
+#ifdef FOSSIL_ENABLE_JSON
175177
struct FossilJsonBits {
176178
int isJsonMode; /* True if running in JSON mode, else
177179
false. This changes how errors are
178180
reported. In JSON mode we try to
179181
always output JSON-form error
@@ -223,10 +225,11 @@
223225
struct { /* response warnings */
224226
cson_value * v;
225227
cson_array * a;
226228
} warnings;
227229
} json;
230
+#endif /* FOSSIL_ENABLE_JSON */
228231
};
229232
230233
/*
231234
** Macro for debugging:
232235
*/
@@ -293,14 +296,15 @@
293296
/*
294297
** atexit() handler which frees up "some" of the resources
295298
** used by fossil.
296299
*/
297300
void fossil_atexit() {
298
-
301
+#ifdef FOSSIL_ENABLE_JSON
299302
cson_value_free(g.json.gc.v);
300
- free(g.zErrMsg);
301303
memset(&g.json, 0, sizeof(g.json));
304
+#endif
305
+ free(g.zErrMsg);
302306
if(g.db){
303307
db_close(0);
304308
}
305309
}
306310
@@ -390,10 +394,11 @@
390394
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
391395
memset(&g, 0, sizeof(g));
392396
g.now = time(0);
393397
g.argc = argc;
394398
g.argv = argv;
399
+#ifdef FOSSIL_ENABLE_JSON
395400
#if defined(NDEBUG)
396401
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
397402
One problem we have here is that this
398403
code is needed before the db is opened,
399404
so we can't sql for it.*/;
@@ -401,10 +406,11 @@
401406
g.json.errorDetailParanoia = 0;
402407
#endif
403408
g.json.outOpt = cson_output_opt_empty;
404409
g.json.outOpt.addNewline = 1;
405410
g.json.outOpt.indentation = 1 /* in CGI/server mode this can be configured */;
411
+#endif /* FOSSIL_ENABLE_JSON */
406412
expand_args_option();
407413
argc = g.argc;
408414
argv = g.argv;
409415
for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
410416
if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
@@ -462,15 +468,10 @@
462468
"%s: could be any of:%s\n"
463469
"%s: use \"help\" for more information\n",
464470
argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
465471
fossil_exit(1);
466472
}
467
- if(rc){
468
- fossil_fatal("%s: unrecoverable error while initializing JSON CGI bits: "
469
- "cson error code #%d (%s)\n",
470
- argv[0], rc, cson_rc_string(rc));
471
- }
472473
atexit( fossil_atexit );
473474
aCommand[idx].xFunc();
474475
fossil_exit(0);
475476
/*NOT_REACHED*/
476477
return 0;
@@ -513,22 +514,28 @@
513514
static int once = 1;
514515
mainInFatalError = 1;
515516
va_start(ap, zFormat);
516517
z = vmprintf(zFormat, ap);
517518
va_end(ap);
519
+#ifdef FOSSIL_ENABLE_JSON
518520
if( g.json.isJsonMode ){
519521
json_err( 0, z, 1 );
520522
if( g.isHTTP ){
521523
rc = 0 /* avoid HTTP 500 */;
522524
}
523
- }else if( g.cgiOutput && once ){
524
- once = 0;
525
- cgi_printf("<p class=\"generalError\">%h</p>", z);
526
- cgi_reply();
527
- }else{
528
- char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
529
- fossil_puts(zOut, 1);
525
+ }
526
+ else
527
+#endif
528
+ {
529
+ if( g.cgiOutput && once ){
530
+ once = 0;
531
+ cgi_printf("<p class=\"generalError\">%h</p>", z);
532
+ cgi_reply();
533
+ }else{
534
+ char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
535
+ fossil_puts(zOut, 1);
536
+ }
530537
}
531538
free(z);
532539
db_force_rollback();
533540
fossil_exit(rc);
534541
}
@@ -539,23 +546,28 @@
539546
va_list ap;
540547
mainInFatalError = 1;
541548
va_start(ap, zFormat);
542549
z = vmprintf(zFormat, ap);
543550
va_end(ap);
551
+#ifdef FOSSIL_ENABLE_JSON
544552
if( g.json.isJsonMode ){
545553
json_err( g.json.resultCode, z, 1 );
546554
if( g.isHTTP ){
547555
rc = 0 /* avoid HTTP 500 */;
548556
}
549557
}
550
- else if( g.cgiOutput ){
551
- g.cgiOutput = 0;
552
- cgi_printf("<p class=\"generalError\">%h</p>", z);
553
- cgi_reply();
554
- }else{
555
- char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
556
- fossil_puts(zOut, 1);
558
+ else
559
+#endif
560
+ {
561
+ if( g.cgiOutput ){
562
+ g.cgiOutput = 0;
563
+ cgi_printf("<p class=\"generalError\">%h</p>", z);
564
+ cgi_reply();
565
+ }else{
566
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
567
+ fossil_puts(zOut, 1);
568
+ }
557569
}
558570
free(z);
559571
db_force_rollback();
560572
fossil_exit(rc);
561573
}
@@ -576,23 +588,28 @@
576588
if( mainInFatalError ) return;
577589
mainInFatalError = 1;
578590
va_start(ap, zFormat);
579591
z = vmprintf(zFormat, ap);
580592
va_end(ap);
593
+#ifdef FOSSIL_ENABLE_JSON
581594
if( g.json.isJsonMode ){
582595
json_err( g.json.resultCode, z, 1 );
583596
if( g.isHTTP ){
584597
rc = 0 /* avoid HTTP 500 */;
585598
}
586
- }else if( g.cgiOutput ){
587
- g.cgiOutput = 0;
588
- cgi_printf("<p class=\"generalError\">%h</p>", z);
589
- cgi_reply();
590
- }else{
591
- char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
592
- fossil_puts(zOut, 1);
593
- free(zOut);
599
+ } else
600
+#endif
601
+ {
602
+ if( g.cgiOutput ){
603
+ g.cgiOutput = 0;
604
+ cgi_printf("<p class=\"generalError\">%h</p>", z);
605
+ cgi_reply();
606
+ }else{
607
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
608
+ fossil_puts(zOut, 1);
609
+ free(zOut);
610
+ }
594611
}
595612
db_force_rollback();
596613
fossil_exit(rc);
597614
}
598615
@@ -602,18 +619,23 @@
602619
char *z;
603620
va_list ap;
604621
va_start(ap, zFormat);
605622
z = vmprintf(zFormat, ap);
606623
va_end(ap);
624
+#ifdef FOSSIL_ENABLE_JSON
607625
if(g.json.isJsonMode){
608626
json_warn( FSL_JSON_W_UNKNOWN, z );
609
- }else if( g.cgiOutput ){
610
- cgi_printf("<p class=\"generalError\">%h</p>", z);
611
- }else{
612
- char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
613
- fossil_puts(zOut, 1);
614
- free(zOut);
627
+ }else
628
+#endif
629
+ {
630
+ if( g.cgiOutput ){
631
+ cgi_printf("<p class=\"generalError\">%h</p>", z);
632
+ }else{
633
+ char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
634
+ fossil_puts(zOut, 1);
635
+ free(zOut);
636
+ }
615637
}
616638
free(z);
617639
}
618640
619641
/*
@@ -1154,17 +1176,19 @@
11541176
11551177
if( szFile<1024 ){
11561178
if( zNotFound ){
11571179
cgi_redirect(zNotFound);
11581180
}else{
1181
+#ifdef FOSSIL_ENABLE_JSON
11591182
if(g.json.isJsonMode){
11601183
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1161
- }else{
1162
- @ <h1>Not Found</h1>
1163
- cgi_set_status(404, "not found");
1164
- cgi_reply();
1184
+ return;
11651185
}
1186
+#endif
1187
+ @ <h1>Not Found</h1>
1188
+ cgi_set_status(404, "not found");
1189
+ cgi_reply();
11661190
}
11671191
return;
11681192
}
11691193
break;
11701194
}
@@ -1189,16 +1213,17 @@
11891213
zPathInfo = "/xfer";
11901214
}
11911215
set_base_url();
11921216
if( zPathInfo==0 || zPathInfo[0]==0
11931217
|| (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
1218
+#ifdef FOSSIL_ENABLE_JSON
11941219
if(g.json.isJsonMode){
11951220
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
11961221
fossil_exit(0);
1197
- }else{
1198
- fossil_redirect_home() /*does not return*/;
11991222
}
1223
+#endif
1224
+ fossil_redirect_home() /*does not return*/;
12001225
}else{
12011226
zPath = mprintf("%s", zPathInfo);
12021227
}
12031228
12041229
/* Make g.zPath point to the first element of the path. Make
@@ -1267,21 +1292,27 @@
12671292
/* Locate the method specified by the path and execute the function
12681293
** that implements that method.
12691294
*/
12701295
if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
12711296
name_search("not_found", aWebpage, count(aWebpage), &idx) ){
1297
+#ifdef FOSSIL_ENABLE_JSON
12721298
if(g.json.isJsonMode){
12731299
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
1274
- }else{
1300
+ }else
1301
+#endif
1302
+ {
12751303
cgi_set_status(404,"Not Found");
12761304
@ <h1>Not Found</h1>
12771305
@ <p>Page not found: %h(g.zPath)</p>
12781306
}
12791307
}else if( aWebpage[idx].xFunc!=page_xfer && db_schema_is_outofdate() ){
1308
+#ifdef FOSSIL_ENABLE_JSON
12801309
if(g.json.isJsonMode){
12811310
json_err(FSL_JSON_E_DB_NEEDS_REBUILD,NULL,0);
1282
- }else{
1311
+ }else
1312
+#endif
1313
+ {
12831314
@ <h1>Server Configuration Error</h1>
12841315
@ <p>The database schema on the server is out-of-date. Please ask
12851316
@ the administrator to run <b>fossil rebuild</b>.</p>
12861317
}
12871318
}else{
12881319
--- src/main.c
+++ src/main.c
@@ -26,13 +26,14 @@
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdlib.h> /* atexit() */
29
30 #if INTERFACE
31 #include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
32 #include "json_detail.h"
33
 
34 /*
35 ** Number of elements in an array
36 */
37 #define count(X) (sizeof(X)/sizeof(X[0]))
38
@@ -170,10 +171,11 @@
170 const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
171 int anAuxCols[MX_AUX]; /* Number of columns for option() values */
172
173 int allowSymlinks; /* Cached "allow-symlinks" option */
174
 
175 struct FossilJsonBits {
176 int isJsonMode; /* True if running in JSON mode, else
177 false. This changes how errors are
178 reported. In JSON mode we try to
179 always output JSON-form error
@@ -223,10 +225,11 @@
223 struct { /* response warnings */
224 cson_value * v;
225 cson_array * a;
226 } warnings;
227 } json;
 
228 };
229
230 /*
231 ** Macro for debugging:
232 */
@@ -293,14 +296,15 @@
293 /*
294 ** atexit() handler which frees up "some" of the resources
295 ** used by fossil.
296 */
297 void fossil_atexit() {
298
299 cson_value_free(g.json.gc.v);
300 free(g.zErrMsg);
301 memset(&g.json, 0, sizeof(g.json));
 
 
302 if(g.db){
303 db_close(0);
304 }
305 }
306
@@ -390,10 +394,11 @@
390 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
391 memset(&g, 0, sizeof(g));
392 g.now = time(0);
393 g.argc = argc;
394 g.argv = argv;
 
395 #if defined(NDEBUG)
396 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
397 One problem we have here is that this
398 code is needed before the db is opened,
399 so we can't sql for it.*/;
@@ -401,10 +406,11 @@
401 g.json.errorDetailParanoia = 0;
402 #endif
403 g.json.outOpt = cson_output_opt_empty;
404 g.json.outOpt.addNewline = 1;
405 g.json.outOpt.indentation = 1 /* in CGI/server mode this can be configured */;
 
406 expand_args_option();
407 argc = g.argc;
408 argv = g.argv;
409 for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
410 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
@@ -462,15 +468,10 @@
462 "%s: could be any of:%s\n"
463 "%s: use \"help\" for more information\n",
464 argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
465 fossil_exit(1);
466 }
467 if(rc){
468 fossil_fatal("%s: unrecoverable error while initializing JSON CGI bits: "
469 "cson error code #%d (%s)\n",
470 argv[0], rc, cson_rc_string(rc));
471 }
472 atexit( fossil_atexit );
473 aCommand[idx].xFunc();
474 fossil_exit(0);
475 /*NOT_REACHED*/
476 return 0;
@@ -513,22 +514,28 @@
513 static int once = 1;
514 mainInFatalError = 1;
515 va_start(ap, zFormat);
516 z = vmprintf(zFormat, ap);
517 va_end(ap);
 
518 if( g.json.isJsonMode ){
519 json_err( 0, z, 1 );
520 if( g.isHTTP ){
521 rc = 0 /* avoid HTTP 500 */;
522 }
523 }else if( g.cgiOutput && once ){
524 once = 0;
525 cgi_printf("<p class=\"generalError\">%h</p>", z);
526 cgi_reply();
527 }else{
528 char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
529 fossil_puts(zOut, 1);
 
 
 
 
 
530 }
531 free(z);
532 db_force_rollback();
533 fossil_exit(rc);
534 }
@@ -539,23 +546,28 @@
539 va_list ap;
540 mainInFatalError = 1;
541 va_start(ap, zFormat);
542 z = vmprintf(zFormat, ap);
543 va_end(ap);
 
544 if( g.json.isJsonMode ){
545 json_err( g.json.resultCode, z, 1 );
546 if( g.isHTTP ){
547 rc = 0 /* avoid HTTP 500 */;
548 }
549 }
550 else if( g.cgiOutput ){
551 g.cgiOutput = 0;
552 cgi_printf("<p class=\"generalError\">%h</p>", z);
553 cgi_reply();
554 }else{
555 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
556 fossil_puts(zOut, 1);
 
 
 
 
557 }
558 free(z);
559 db_force_rollback();
560 fossil_exit(rc);
561 }
@@ -576,23 +588,28 @@
576 if( mainInFatalError ) return;
577 mainInFatalError = 1;
578 va_start(ap, zFormat);
579 z = vmprintf(zFormat, ap);
580 va_end(ap);
 
581 if( g.json.isJsonMode ){
582 json_err( g.json.resultCode, z, 1 );
583 if( g.isHTTP ){
584 rc = 0 /* avoid HTTP 500 */;
585 }
586 }else if( g.cgiOutput ){
587 g.cgiOutput = 0;
588 cgi_printf("<p class=\"generalError\">%h</p>", z);
589 cgi_reply();
590 }else{
591 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
592 fossil_puts(zOut, 1);
593 free(zOut);
 
 
 
 
594 }
595 db_force_rollback();
596 fossil_exit(rc);
597 }
598
@@ -602,18 +619,23 @@
602 char *z;
603 va_list ap;
604 va_start(ap, zFormat);
605 z = vmprintf(zFormat, ap);
606 va_end(ap);
 
607 if(g.json.isJsonMode){
608 json_warn( FSL_JSON_W_UNKNOWN, z );
609 }else if( g.cgiOutput ){
610 cgi_printf("<p class=\"generalError\">%h</p>", z);
611 }else{
612 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
613 fossil_puts(zOut, 1);
614 free(zOut);
 
 
 
 
615 }
616 free(z);
617 }
618
619 /*
@@ -1154,17 +1176,19 @@
1154
1155 if( szFile<1024 ){
1156 if( zNotFound ){
1157 cgi_redirect(zNotFound);
1158 }else{
 
1159 if(g.json.isJsonMode){
1160 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1161 }else{
1162 @ <h1>Not Found</h1>
1163 cgi_set_status(404, "not found");
1164 cgi_reply();
1165 }
 
 
 
 
1166 }
1167 return;
1168 }
1169 break;
1170 }
@@ -1189,16 +1213,17 @@
1189 zPathInfo = "/xfer";
1190 }
1191 set_base_url();
1192 if( zPathInfo==0 || zPathInfo[0]==0
1193 || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
 
1194 if(g.json.isJsonMode){
1195 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1196 fossil_exit(0);
1197 }else{
1198 fossil_redirect_home() /*does not return*/;
1199 }
 
 
1200 }else{
1201 zPath = mprintf("%s", zPathInfo);
1202 }
1203
1204 /* Make g.zPath point to the first element of the path. Make
@@ -1267,21 +1292,27 @@
1267 /* Locate the method specified by the path and execute the function
1268 ** that implements that method.
1269 */
1270 if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
1271 name_search("not_found", aWebpage, count(aWebpage), &idx) ){
 
1272 if(g.json.isJsonMode){
1273 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
1274 }else{
 
 
1275 cgi_set_status(404,"Not Found");
1276 @ <h1>Not Found</h1>
1277 @ <p>Page not found: %h(g.zPath)</p>
1278 }
1279 }else if( aWebpage[idx].xFunc!=page_xfer && db_schema_is_outofdate() ){
 
1280 if(g.json.isJsonMode){
1281 json_err(FSL_JSON_E_DB_NEEDS_REBUILD,NULL,0);
1282 }else{
 
 
1283 @ <h1>Server Configuration Error</h1>
1284 @ <p>The database schema on the server is out-of-date. Please ask
1285 @ the administrator to run <b>fossil rebuild</b>.</p>
1286 }
1287 }else{
1288
--- src/main.c
+++ src/main.c
@@ -26,13 +26,14 @@
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdlib.h> /* atexit() */
29
30 #if INTERFACE
31 #ifdef FOSSIL_ENABLE_JSON
32 # include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
33 # include "json_detail.h"
34 #endif
35 /*
36 ** Number of elements in an array
37 */
38 #define count(X) (sizeof(X)/sizeof(X[0]))
39
@@ -170,10 +171,11 @@
171 const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
172 int anAuxCols[MX_AUX]; /* Number of columns for option() values */
173
174 int allowSymlinks; /* Cached "allow-symlinks" option */
175
176 #ifdef FOSSIL_ENABLE_JSON
177 struct FossilJsonBits {
178 int isJsonMode; /* True if running in JSON mode, else
179 false. This changes how errors are
180 reported. In JSON mode we try to
181 always output JSON-form error
@@ -223,10 +225,11 @@
225 struct { /* response warnings */
226 cson_value * v;
227 cson_array * a;
228 } warnings;
229 } json;
230 #endif /* FOSSIL_ENABLE_JSON */
231 };
232
233 /*
234 ** Macro for debugging:
235 */
@@ -293,14 +296,15 @@
296 /*
297 ** atexit() handler which frees up "some" of the resources
298 ** used by fossil.
299 */
300 void fossil_atexit() {
301 #ifdef FOSSIL_ENABLE_JSON
302 cson_value_free(g.json.gc.v);
 
303 memset(&g.json, 0, sizeof(g.json));
304 #endif
305 free(g.zErrMsg);
306 if(g.db){
307 db_close(0);
308 }
309 }
310
@@ -390,10 +394,11 @@
394 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
395 memset(&g, 0, sizeof(g));
396 g.now = time(0);
397 g.argc = argc;
398 g.argv = argv;
399 #ifdef FOSSIL_ENABLE_JSON
400 #if defined(NDEBUG)
401 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
402 One problem we have here is that this
403 code is needed before the db is opened,
404 so we can't sql for it.*/;
@@ -401,10 +406,11 @@
406 g.json.errorDetailParanoia = 0;
407 #endif
408 g.json.outOpt = cson_output_opt_empty;
409 g.json.outOpt.addNewline = 1;
410 g.json.outOpt.indentation = 1 /* in CGI/server mode this can be configured */;
411 #endif /* FOSSIL_ENABLE_JSON */
412 expand_args_option();
413 argc = g.argc;
414 argv = g.argv;
415 for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
416 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
@@ -462,15 +468,10 @@
468 "%s: could be any of:%s\n"
469 "%s: use \"help\" for more information\n",
470 argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
471 fossil_exit(1);
472 }
 
 
 
 
 
473 atexit( fossil_atexit );
474 aCommand[idx].xFunc();
475 fossil_exit(0);
476 /*NOT_REACHED*/
477 return 0;
@@ -513,22 +514,28 @@
514 static int once = 1;
515 mainInFatalError = 1;
516 va_start(ap, zFormat);
517 z = vmprintf(zFormat, ap);
518 va_end(ap);
519 #ifdef FOSSIL_ENABLE_JSON
520 if( g.json.isJsonMode ){
521 json_err( 0, z, 1 );
522 if( g.isHTTP ){
523 rc = 0 /* avoid HTTP 500 */;
524 }
525 }
526 else
527 #endif
528 {
529 if( g.cgiOutput && once ){
530 once = 0;
531 cgi_printf("<p class=\"generalError\">%h</p>", z);
532 cgi_reply();
533 }else{
534 char *zOut = mprintf("%s: %s\n", fossil_nameofexe(), z);
535 fossil_puts(zOut, 1);
536 }
537 }
538 free(z);
539 db_force_rollback();
540 fossil_exit(rc);
541 }
@@ -539,23 +546,28 @@
546 va_list ap;
547 mainInFatalError = 1;
548 va_start(ap, zFormat);
549 z = vmprintf(zFormat, ap);
550 va_end(ap);
551 #ifdef FOSSIL_ENABLE_JSON
552 if( g.json.isJsonMode ){
553 json_err( g.json.resultCode, z, 1 );
554 if( g.isHTTP ){
555 rc = 0 /* avoid HTTP 500 */;
556 }
557 }
558 else
559 #endif
560 {
561 if( g.cgiOutput ){
562 g.cgiOutput = 0;
563 cgi_printf("<p class=\"generalError\">%h</p>", z);
564 cgi_reply();
565 }else{
566 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
567 fossil_puts(zOut, 1);
568 }
569 }
570 free(z);
571 db_force_rollback();
572 fossil_exit(rc);
573 }
@@ -576,23 +588,28 @@
588 if( mainInFatalError ) return;
589 mainInFatalError = 1;
590 va_start(ap, zFormat);
591 z = vmprintf(zFormat, ap);
592 va_end(ap);
593 #ifdef FOSSIL_ENABLE_JSON
594 if( g.json.isJsonMode ){
595 json_err( g.json.resultCode, z, 1 );
596 if( g.isHTTP ){
597 rc = 0 /* avoid HTTP 500 */;
598 }
599 } else
600 #endif
601 {
602 if( g.cgiOutput ){
603 g.cgiOutput = 0;
604 cgi_printf("<p class=\"generalError\">%h</p>", z);
605 cgi_reply();
606 }else{
607 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
608 fossil_puts(zOut, 1);
609 free(zOut);
610 }
611 }
612 db_force_rollback();
613 fossil_exit(rc);
614 }
615
@@ -602,18 +619,23 @@
619 char *z;
620 va_list ap;
621 va_start(ap, zFormat);
622 z = vmprintf(zFormat, ap);
623 va_end(ap);
624 #ifdef FOSSIL_ENABLE_JSON
625 if(g.json.isJsonMode){
626 json_warn( FSL_JSON_W_UNKNOWN, z );
627 }else
628 #endif
629 {
630 if( g.cgiOutput ){
631 cgi_printf("<p class=\"generalError\">%h</p>", z);
632 }else{
633 char *zOut = mprintf("\r%s: %s\n", fossil_nameofexe(), z);
634 fossil_puts(zOut, 1);
635 free(zOut);
636 }
637 }
638 free(z);
639 }
640
641 /*
@@ -1154,17 +1176,19 @@
1176
1177 if( szFile<1024 ){
1178 if( zNotFound ){
1179 cgi_redirect(zNotFound);
1180 }else{
1181 #ifdef FOSSIL_ENABLE_JSON
1182 if(g.json.isJsonMode){
1183 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1184 return;
 
 
 
1185 }
1186 #endif
1187 @ <h1>Not Found</h1>
1188 cgi_set_status(404, "not found");
1189 cgi_reply();
1190 }
1191 return;
1192 }
1193 break;
1194 }
@@ -1189,16 +1213,17 @@
1213 zPathInfo = "/xfer";
1214 }
1215 set_base_url();
1216 if( zPathInfo==0 || zPathInfo[0]==0
1217 || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
1218 #ifdef FOSSIL_ENABLE_JSON
1219 if(g.json.isJsonMode){
1220 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1221 fossil_exit(0);
 
 
1222 }
1223 #endif
1224 fossil_redirect_home() /*does not return*/;
1225 }else{
1226 zPath = mprintf("%s", zPathInfo);
1227 }
1228
1229 /* Make g.zPath point to the first element of the path. Make
@@ -1267,21 +1292,27 @@
1292 /* Locate the method specified by the path and execute the function
1293 ** that implements that method.
1294 */
1295 if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
1296 name_search("not_found", aWebpage, count(aWebpage), &idx) ){
1297 #ifdef FOSSIL_ENABLE_JSON
1298 if(g.json.isJsonMode){
1299 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
1300 }else
1301 #endif
1302 {
1303 cgi_set_status(404,"Not Found");
1304 @ <h1>Not Found</h1>
1305 @ <p>Page not found: %h(g.zPath)</p>
1306 }
1307 }else if( aWebpage[idx].xFunc!=page_xfer && db_schema_is_outofdate() ){
1308 #ifdef FOSSIL_ENABLE_JSON
1309 if(g.json.isJsonMode){
1310 json_err(FSL_JSON_E_DB_NEEDS_REBUILD,NULL,0);
1311 }else
1312 #endif
1313 {
1314 @ <h1>Server Configuration Error</h1>
1315 @ <p>The database schema on the server is out-of-date. Please ask
1316 @ the administrator to run <b>fossil rebuild</b>.</p>
1317 }
1318 }else{
1319
+2
--- src/name.c
+++ src/name.c
@@ -366,13 +366,15 @@
366366
** shows all possibilities and do not return.
367367
*/
368368
int name_to_rid_www(const char *zParamName){
369369
int rid;
370370
const char *zName = P(zParamName);
371
+#ifdef FOSSIL_ENABLE_JSON
371372
if(!zName && fossil_has_json()){
372373
zName = json_find_option_cstr(zParamName,NULL,NULL);
373374
}
375
+#endif
374376
if( zName==0 || zName[0]==0 ) return 0;
375377
rid = symbolic_name_to_rid(zName, "*");
376378
if( rid<0 ){
377379
cgi_redirectf("%s/ambiguous/%T?src=%t", g.zTop, zName, g.zPath);
378380
rid = 0;
379381
--- src/name.c
+++ src/name.c
@@ -366,13 +366,15 @@
366 ** shows all possibilities and do not return.
367 */
368 int name_to_rid_www(const char *zParamName){
369 int rid;
370 const char *zName = P(zParamName);
 
371 if(!zName && fossil_has_json()){
372 zName = json_find_option_cstr(zParamName,NULL,NULL);
373 }
 
374 if( zName==0 || zName[0]==0 ) return 0;
375 rid = symbolic_name_to_rid(zName, "*");
376 if( rid<0 ){
377 cgi_redirectf("%s/ambiguous/%T?src=%t", g.zTop, zName, g.zPath);
378 rid = 0;
379
--- src/name.c
+++ src/name.c
@@ -366,13 +366,15 @@
366 ** shows all possibilities and do not return.
367 */
368 int name_to_rid_www(const char *zParamName){
369 int rid;
370 const char *zName = P(zParamName);
371 #ifdef FOSSIL_ENABLE_JSON
372 if(!zName && fossil_has_json()){
373 zName = json_find_option_cstr(zParamName,NULL,NULL);
374 }
375 #endif
376 if( zName==0 || zName[0]==0 ) return 0;
377 rid = symbolic_name_to_rid(zName, "*");
378 if( rid<0 ){
379 cgi_redirectf("%s/ambiguous/%T?src=%t", g.zTop, zName, g.zPath);
380 rid = 0;
381
+4
--- src/wiki.c
+++ src/wiki.c
@@ -801,15 +801,19 @@
801801
" WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
802802
" ORDER BY x.mtime DESC LIMIT 1",
803803
zPageName
804804
);
805805
if( rid==0 && !isNew ){
806
+#ifdef FOSSIL_ENABLE_JSON
806807
g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
808
+#endif
807809
fossil_fatal("no such wiki page: %s", zPageName);
808810
}
809811
if( rid!=0 && isNew ){
812
+#ifdef FOSSIL_ENABLE_JSON
810813
g.json.resultCode = FSL_JSON_E_RESOURCE_ALREADY_EXISTS;
814
+#endif
811815
fossil_fatal("wiki page %s already exists", zPageName);
812816
}
813817
814818
blob_zero(&wiki);
815819
zDate = date_in_standard_format("now");
816820
--- src/wiki.c
+++ src/wiki.c
@@ -801,15 +801,19 @@
801 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
802 " ORDER BY x.mtime DESC LIMIT 1",
803 zPageName
804 );
805 if( rid==0 && !isNew ){
 
806 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
 
807 fossil_fatal("no such wiki page: %s", zPageName);
808 }
809 if( rid!=0 && isNew ){
 
810 g.json.resultCode = FSL_JSON_E_RESOURCE_ALREADY_EXISTS;
 
811 fossil_fatal("wiki page %s already exists", zPageName);
812 }
813
814 blob_zero(&wiki);
815 zDate = date_in_standard_format("now");
816
--- src/wiki.c
+++ src/wiki.c
@@ -801,15 +801,19 @@
801 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
802 " ORDER BY x.mtime DESC LIMIT 1",
803 zPageName
804 );
805 if( rid==0 && !isNew ){
806 #ifdef FOSSIL_ENABLE_JSON
807 g.json.resultCode = FSL_JSON_E_RESOURCE_NOT_FOUND;
808 #endif
809 fossil_fatal("no such wiki page: %s", zPageName);
810 }
811 if( rid!=0 && isNew ){
812 #ifdef FOSSIL_ENABLE_JSON
813 g.json.resultCode = FSL_JSON_E_RESOURCE_ALREADY_EXISTS;
814 #endif
815 fossil_fatal("wiki page %s already exists", zPageName);
816 }
817
818 blob_zero(&wiki);
819 zDate = date_in_standard_format("now");
820

Keyboard Shortcuts

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