* tmplput_HOST_DISPLAYNAME() to output our current hostname
authorWilfried Göesgens <willi@citadel.org>
Thu, 22 Jul 2010 22:31:41 +0000 (22:31 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 22 Jul 2010 22:31:41 +0000 (22:31 +0000)
* if citserver tells us, we're already logged in, its also ok to continue

webcit/webcit.c

index 251c7df9a74422f98d62295a6e5d4269c8cc7228..8ca820422829922ba51664caf718311c757474c0 100644 (file)
@@ -47,6 +47,13 @@ void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
        if (WCC->Hdr->HR.Handler != NULL)
                StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.Handler->DisplayName, 0);
 }
+
+void tmplput_HOST_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+       StrBufAppendTemplate(Target, TP, WCC->Hdr->HR.http_host, 0);
+}
+
 /*
  * web-printing funcion. uses our vsnprintf wrapper
  */
@@ -658,10 +665,12 @@ void session_loop(void)
            && (StrLength(WCC->Hdr->c_username) > 0)
            && (StrLength(WCC->Hdr->c_password) > 0))
        {
+               long Status;
+
                FlushStrBuf(Buf);
                serv_printf("USER %s", ChrPtr(WCC->Hdr->c_username));
                StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) == 3) {
+               if (GetServerStatus(Buf, &Status) == 3) {
                        serv_printf("PASS %s", ChrPtr(WCC->Hdr->c_password));
                        StrBuf_ServGetln(Buf);
                        if (GetServerStatus(Buf, NULL) == 2) {
@@ -675,6 +684,9 @@ void session_loop(void)
                                goto SKIP_ALL_THIS_CRAP;
                        }
                }
+               else if (Status == 541) {
+                       WCC->logged_in = 1;
+               }
        }
 
        xhttp = (WCC->Hdr->HR.eReqType != eGET) &&
@@ -837,7 +849,9 @@ InitModule_WEBCIT
        RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, NULL, CTX_NONE);
        RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, NULL, CTX_NONE);
        RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE);
+       RegisterNamespace("URL:HOSTNAME", 0, 1, tmplput_HOST_DISPLAYNAME, NULL, CTX_NONE);
 
+       
        snprintf(dir, SIZ, "%s/webcit.css", static_local_dir);
        if (!access(dir, R_OK)) {
                lprintf(9, "Using local Stylesheet [%s]\n", dir);