| ︙ | | | ︙ | |
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
}
/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){
int i;
while( isspace(*zOrig) ){ zOrig++; }
i = strlen(zOrig);
while( i>0 && isspace(zOrig[i-1]) ){ i--; }
return mprintf("%.*s", i, zOrig);
}
/*
** Extract a numeric (integer) value from a string.
*/
char *extract_integer(const char *zOrig){
if( zOrig == NULL || zOrig[0] == 0 ) return "";
while( *zOrig && !isdigit(*zOrig) ){ zOrig++; }
if( *zOrig ){
/* we have a digit. atoi() will get as much of the number as it
** can. We'll run it through mprintf() to get a string. Not
** an efficient way to do it, but effective.
*/
return mprintf("%d", atoi(zOrig));
}
return "";
}
/*
** Remove blank lines from the beginning of a string and
** all whitespace from the end. Removes whitespace preceeding a NL,
** which also converts any CRNL sequence into a single NL.
*/
char *remove_blank_lines(const char *zOrig){
int i, j, n;
char *z;
for(i=j=0; isspace(zOrig[i]); i++){ if( zOrig[i]=='\n' ) j = i+1; }
n = strlen(&zOrig[j]);
while( n>0 && isspace(zOrig[j+n-1]) ){ n--; }
z = mprintf("%.*s", n, &zOrig[j]);
for(i=j=0; z[i]; i++){
if( z[i+1]=='\n' && z[i]!='\n' && isspace(z[i]) ){
z[j] = z[i];
while(isspace(z[j]) && z[j] != '\n' ){ j--; }
j++;
continue;
}
z[j++] = z[i];
}
z[j] = 0;
|
|
|
|
|
|
|
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
}
/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){
int i;
while( fossil_isspace(*zOrig) ){ zOrig++; }
i = strlen(zOrig);
while( i>0 && fossil_isspace(zOrig[i-1]) ){ i--; }
return mprintf("%.*s", i, zOrig);
}
/*
** Extract a numeric (integer) value from a string.
*/
char *extract_integer(const char *zOrig){
if( zOrig == NULL || zOrig[0] == 0 ) return "";
while( *zOrig && !fossil_isdigit(*zOrig) ){ zOrig++; }
if( *zOrig ){
/* we have a digit. atoi() will get as much of the number as it
** can. We'll run it through mprintf() to get a string. Not
** an efficient way to do it, but effective.
*/
return mprintf("%d", atoi(zOrig));
}
return "";
}
/*
** Remove blank lines from the beginning of a string and
** all whitespace from the end. Removes whitespace preceeding a NL,
** which also converts any CRNL sequence into a single NL.
*/
char *remove_blank_lines(const char *zOrig){
int i, j, n;
char *z;
for(i=j=0; fossil_isspace(zOrig[i]); i++){ if( zOrig[i]=='\n' ) j = i+1; }
n = strlen(&zOrig[j]);
while( n>0 && fossil_isspace(zOrig[j+n-1]) ){ n--; }
z = mprintf("%.*s", n, &zOrig[j]);
for(i=j=0; z[i]; i++){
if( z[i+1]=='\n' && z[i]!='\n' && fossil_isspace(z[i]) ){
z[j] = z[i];
while(fossil_isspace(z[j]) && z[j] != '\n' ){ j--; }
j++;
continue;
}
z[j++] = z[i];
}
z[j] = 0;
|
| ︙ | | | ︙ | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
const char *zTail;
sqlite3_stmt *pStmt;
int rc;
/* First make sure the SQL is a single query command by verifying that
** the first token is "SELECT" and that there are no unquoted semicolons.
*/
for(i=0; isspace(zSql[i]); i++){}
if( strncasecmp(&zSql[i],"select",6)!=0 ){
return mprintf("The SQL must be a SELECT statement");
}
for(i=0; zSql[i]; i++){
if( zSql[i]==';' ){
int bad;
int c = zSql[i+1];
|
|
|
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
const char *zTail;
sqlite3_stmt *pStmt;
int rc;
/* First make sure the SQL is a single query command by verifying that
** the first token is "SELECT" and that there are no unquoted semicolons.
*/
for(i=0; fossil_isspace(zSql[i]); i++){}
if( strncasecmp(&zSql[i],"select",6)!=0 ){
return mprintf("The SQL must be a SELECT statement");
}
for(i=0; zSql[i]; i++){
if( zSql[i]==';' ){
int bad;
int c = zSql[i+1];
|
| ︙ | | | ︙ | |
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
@ title AS 'Title',
@ wiki(substr(description,0,80)) AS 'Description'
@ FROM ticket
@ </pre></blockquote>
@
}
#if 0 /* NOT USED */
static void column_header(int rn,const char *zCol, int nCol, int nSorted,
const char *zDirection, const char *zExtra
){
int set = (nCol==nSorted);
int desc = !strcmp(zDirection,"DESC");
/*
** Clicking same column header 3 times in a row resets any sorting.
** Note that we link to rptview, which means embedded reports will get
** sent to the actual report view page as soon as a user tries to do
** any sorting. I don't see that as a Bad Thing.
*/
if(set && desc){
@ <th bgcolor="%s(BG1)" class="bkgnd1">
@ <a href="rptview?rn=%d(rn)%s(zExtra)">%h(zCol)</a></th>
}else{
if(set){
@ <th bgcolor="%s(BG1)" class="bkgnd1"><a
}else{
@ <th><a
}
@ href="rptview?rn=%d(rn)&order_by=%d(nCol)&\
@ order_dir=%s(desc?"ASC":"DESC")\
@ %s(zExtra)">%h(zCol)</a></th>
}
}
#endif
/*
** The state of the report generation.
*/
struct GenerateHTML {
int rn; /* Report number */
int nCount; /* Row number */
int nCol; /* Number of columns */
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
@ title AS 'Title',
@ wiki(substr(description,0,80)) AS 'Description'
@ FROM ticket
@ </pre></blockquote>
@
}
/*
** The state of the report generation.
*/
struct GenerateHTML {
int rn; /* Report number */
int nCount; /* Row number */
int nCol; /* Number of columns */
|
| ︙ | | | ︙ | |
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
|
/*
** Output the text given in the argument. Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs(const char *z){
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
cgi_printf("%.*s", i, z);
}
for(j=i; isspace(z[j]); j++){}
if( j>i ){
cgi_printf("%*s", j-i, "");
}
z += j;
}
}
|
|
|
|
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
|
/*
** Output the text given in the argument. Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs(const char *z){
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
cgi_printf("%.*s", i, z);
}
for(j=i; fossil_isspace(z[j]); j++){}
if( j>i ){
cgi_printf("%*s", j-i, "");
}
z += j;
}
}
|
| ︙ | | | ︙ | |
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
|
/*
** Generate HTML that describes a color key.
*/
void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){
int i, j, k;
char *zSafeKey, *zToFree;
while( isspace(*zClrKey) ) zClrKey++;
if( zClrKey[0]==0 ) return;
@ <table %s(zTabArgs)>
if( horiz ){
@ <tr>
}
zToFree = zSafeKey = mprintf("%h", zClrKey);
while( zSafeKey[0] ){
while( isspace(*zSafeKey) ) zSafeKey++;
for(i=0; zSafeKey[i] && !isspace(zSafeKey[i]); i++){}
for(j=i; isspace(zSafeKey[j]); j++){}
for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){}
if( !horiz ){
cgi_printf("<tr style=\"background-color: %.*s;\"><td>%.*s</td></tr>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
}else{
cgi_printf("<td style=\"background-color: %.*s;\">%.*s</td>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
|
|
|
|
|
|
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
/*
** Generate HTML that describes a color key.
*/
void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){
int i, j, k;
char *zSafeKey, *zToFree;
while( fossil_isspace(*zClrKey) ) zClrKey++;
if( zClrKey[0]==0 ) return;
@ <table %s(zTabArgs)>
if( horiz ){
@ <tr>
}
zToFree = zSafeKey = mprintf("%h", zClrKey);
while( zSafeKey[0] ){
while( fossil_isspace(*zSafeKey) ) zSafeKey++;
for(i=0; zSafeKey[i] && !fossil_isspace(zSafeKey[i]); i++){}
for(j=i; fossil_isspace(zSafeKey[j]); j++){}
for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){}
if( !horiz ){
cgi_printf("<tr style=\"background-color: %.*s;\"><td>%.*s</td></tr>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
}else{
cgi_printf("<td style=\"background-color: %.*s;\">%.*s</td>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
|
| ︙ | | | ︙ | |
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
|
free(zFosZ);
}
break;
}
default:
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
printf("%.*s", i, z);
}
for(j=i; isspace(z[j]); j++){}
if( j>i ){
printf("%*s", j-i, "");
}
z += j;
}
break;
}
|
|
|
|
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
|
free(zFosZ);
}
break;
}
default:
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
printf("%.*s", i, z);
}
for(j=i; fossil_isspace(z[j]); j++){}
if( j>i ){
printf("%*s", j-i, "");
}
z += j;
}
break;
}
|
| ︙ | | | ︙ | |
1103
1104
1105
1106
1107
1108
1109
1110
|
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
sqlite3_exec(g.db, zSql, output_separated_file, &count, &zErr2);
sqlite3_set_authorizer(g.db, 0, 0);
if( zFilter ){
free(zSql);
}
}
|
<
|
1074
1075
1076
1077
1078
1079
1080
|
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
sqlite3_exec(g.db, zSql, output_separated_file, &count, &zErr2);
sqlite3_set_authorizer(g.db, 0, 0);
if( zFilter ){
free(zSql);
}
}
|