]> code.citadel.org Git - citadel.git/blobdiff - webcit/webserver.c
* missing openssl ifdef here too...
[citadel.git] / webcit / webserver.c
index 788eb25e6c5560288ec72afe051fbc7a45428672..72d090c16485b21ed5460f24aea75588c2e1eb6c 100644 (file)
@@ -271,13 +271,13 @@ long end_burst(void)
         fd_set wset;
         int fdflags;
 
-#ifdef HAVE_ZLIB
+       //#ifdef HAVE_ZLIB
        /* Perform gzip compression, if enabled and supported by client */
        if (!DisableGzip && (WCC->gzip_ok) && CompressBuffer(WCC->WBuf))
        {
                hprintf("Content-encoding: gzip\r\n");
        }
-#endif /* HAVE_ZLIB */
+       //#endif        /* HAVE_ZLIB */
 
        hprintf("Content-length: %d\r\n\r\n", StrLength(WCC->WBuf));
 
@@ -389,11 +389,12 @@ void graceful_shutdown_watcher(int signum) {
 }
 
 
-int ClientGetLine(int *sock, StrBuf *Target, StrBuf *CLineBuf)
+int ClientGetLine(int *sock, StrBuf *Target, StrBuf *CLineBuf, const char **Pos)
 {
        const char *Error, *pch, *pchs;
        int rlen, len, retval = 0;
 
+#ifdef HAVE_OPENSSL
        if (is_https) {
                int ntries = 0;
                if (StrLength(CLineBuf) > 0) {
@@ -441,12 +442,14 @@ int ClientGetLine(int *sock, StrBuf *Target, StrBuf *CLineBuf)
                        return -1;
        }
        else 
-               return StrBufTCP_read_buffered_line(Target, 
-                                                   CLineBuf,
-                                                   sock,
-                                                   5,
-                                                   1,
-                                                   &Error);
+#endif
+               return StrBufTCP_read_buffered_line_fast(Target, 
+                                                        CLineBuf,
+                                                        Pos,
+                                                        sock,
+                                                        5,
+                                                        1,
+                                                        &Error);
 }
 
 
@@ -612,6 +615,8 @@ const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return fo
 #endif 
 extern int dbg_analyze_msg;
 extern int dbg_bactrace_template_errors;
+extern int DumpTemplateI18NStrings;
+extern StrBuf *I18nDump;
 void InitTemplateCache(void);
 extern int LoadTemplates;
 extern void LoadZoneFiles(void);
@@ -640,6 +645,7 @@ int main(int argc, char **argv)
        char *mo = NULL;
 #endif /* ENABLE_NLS */
        char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */
+       const char *I18nDumpFile = NULL;
 
        WildFireInitBacktrace(argv[0], 2);
 
@@ -675,9 +681,9 @@ int main(int argc, char **argv)
 
        /* Parse command line */
 #ifdef HAVE_OPENSSL
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfsZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfsZ")) != EOF)
 #else
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfZ")) != EOF)
 #endif
                switch (a) {
                case 'h':
@@ -746,12 +752,17 @@ int main(int argc, char **argv)
                case 's':
                        is_https = 1;
                        break;
+               case 'G':
+                       DumpTemplateI18NStrings = 1;
+                       I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
+                       I18nDumpFile = optarg;
+                       break;
                default:
                        fprintf(stderr, "usage: webcit "
                                "[-i ip_addr] [-p http_port] "
                                "[-t tracefile] [-c] [-f] "
                                "[-T Templatedebuglevel] "
-                               "[-d] [-Z] "
+                               "[-d] [-Z] [-G i18ndumpfile] "
 #ifdef HAVE_OPENSSL
                                "[-s] "
 #endif
@@ -766,7 +777,7 @@ int main(int argc, char **argv)
        }
 
        /* daemonize, if we were asked to */
-       if (running_as_daemon) {
+       if (!DumpTemplateI18NStrings && running_as_daemon) {
                start_daemon(pidfile);
        }
        else {
@@ -785,6 +796,7 @@ int main(int argc, char **argv)
 #ifdef ENABLE_NLS
        initialize_locales();
 
+
        locale = setlocale(LC_ALL, "");
 
        mo = malloc(strlen(webcitdir) + 20);
@@ -792,7 +804,6 @@ int main(int argc, char **argv)
        free(mo);
        lprintf(9, "Text domain: %s\n", textdomain("webcit"));
        lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
-       preset_locale();
 #endif
 
 
@@ -842,6 +853,26 @@ int main(int argc, char **argv)
        initialize_axdefs();
 
        InitTemplateCache();
+       if (DumpTemplateI18NStrings) {
+               FILE *fd;
+               StrBufAppendBufPlain(I18nDump, HKEY("}\n"), 0);
+               if (StrLength(I18nDump) < 50) {
+                       lprintf(1, "********************************************************************************\n");
+                       lprintf(1, "*        No strings found in templates! are you shure they're there?           *\n");
+                       lprintf(1, "********************************************************************************\n");
+                       return -1;
+               }
+               fd = fopen(I18nDumpFile, "w");
+               if (fd == NULL) {
+                       lprintf(1, "********************************************************************************\n");
+                       lprintf(1, "*                  unable to open I18N dumpfile [%s]         *\n", I18nDumpFile);
+                       lprintf(1, "********************************************************************************\n");
+                       return -1;
+               }
+               fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd);
+               fclose(fd);
+               return 0;
+       }
 
        if (!access("static.local/webcit.css", R_OK)) {
                csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"));