795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
|
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
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
839
840
841
842
843
844
845
846
847
848
849
850
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
g.iErrPriority = iPriority;
}
void fossil_error_reset(void){
free(g.zErrMsg);
g.zErrMsg = 0;
g.iErrPriority = 0;
}
/*
** Write to standard output or standard error.
**
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen. If output is redirected into
** a file, no translation occurs. No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){
#if defined(_WIN32)
extern char *sqlite3_win32_utf8_to_mbcs(const char*);
static int once = 1;
static int istty[2];
char *zToFree = 0;
if( once ){
istty[0] = _isatty(fileno(stdout));
istty[1] = _isatty(fileno(stderr));
once = 0;
}
assert( toStdErr==0 || toStdErr==1 );
if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z);
fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
free(zToFree);
#else
fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
#endif
}
/*
** Write output for user consumption. If g.cgiOutput is enabled, then
** send the output as part of the CGI reply. If g.cgiOutput is false,
** then write on standard output.
*/
void fossil_print(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
if( g.cgiOutput ){
cgi_vprintf(zFormat, ap);
}else{
Blob b = empty_blob;
vxprintf(&b, zFormat, ap);
fwrite(blob_buffer(&b), 1, blob_size(&b), stdout);
fossil_puts(blob_str(&b), 0);
blob_reset(&b);
}
}
/*
** Case insensitive string comparison.
*/
|