+ WCC->upload = NewStrBufPlain(content, length);
+ WCC->upload_length = length;
+ WCC->upload_filename = NewStrBufPlain(filename, -1);
+ safestrncpy(WCC->upload_content_type, cbtype, sizeof(WC->upload_content_type));
+#ifdef DEBUG_URLSTRINGS
+ syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int)length);
+#endif
+
+ }
+
+}
+
+void PutBstr(const char *key, long keylen, StrBuf *Value)
+{
+ urlcontent *u;
+
+ if(keylen >= sizeof(u->url_key)) {
+ syslog(LOG_WARNING, "%s:%d: invalid url_key of size %ld", __FILE__, __LINE__, keylen);
+ FreeStrBuf(&Value);
+ return;
+ }
+ u = (urlcontent*)malloc(sizeof(urlcontent));
+ memcpy(u->url_key, key, keylen + 1);
+ u->klen = keylen;
+ u->url_data = Value;
+ u->sub = NULL;
+ Put(WC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
+}
+void PutlBstr(const char *key, long keylen, long Value)
+{
+ StrBuf *Buf;
+
+ Buf = NewStrBufPlain(NULL, sizeof(long) * 16);
+ StrBufPrintf(Buf, "%ld", Value);
+ PutBstr(key, keylen, Buf);
+}
+
+
+
+int ConditionalBstr(StrBuf *Target, WCTemplputParams *TP)
+{
+ if(TP->Tokens->nParameters == 3)
+ return HaveBstr(TKEY(2));
+ else {
+ if (IS_NUMBER(TP->Tokens->Params[3]->Type))
+ {
+ return LBstr(TKEY(2)) ==
+ GetTemplateTokenNumber(Target,
+ TP,
+ 3,
+ 0);
+ }
+ else {
+ const char *pch;
+ long len;
+
+ GetTemplateTokenString (Target, TP, 3, &pch, &len);
+ return strcmp(Bstr(TKEY(2)), pch) == 0;
+ }
+ }
+}
+
+void tmplput_bstr(StrBuf *Target, WCTemplputParams *TP)
+{
+ const StrBuf *Buf = SBstr(TKEY(0));
+ if (Buf != NULL)
+ StrBufAppendTemplate(Target, TP, Buf, 1);
+}
+
+
+void tmplput_bstrforward(StrBuf *Target, WCTemplputParams *TP)
+{
+ const StrBuf *Buf = SBstr(TKEY(0));
+ if (Buf != NULL) {
+ StrBufAppendBufPlain(Target, HKEY("?"), 0);
+ StrBufAppendBufPlain(Target, TKEY(0), 0);
+ StrBufAppendBufPlain(Target, HKEY("="), 0);
+ StrBufAppendTemplate(Target, TP, Buf, 1);
+ }
+}
+
+void diagnostics(void)
+{
+ output_headers(1, 1, 1, 0, 0, 0);
+ wc_printf("Session: %d<hr />\n", WC->wc_session);
+ wc_printf("Command: <br><PRE>\n");
+/*
+StrEscAppend(WC->WBuf, NULL, WC->UrlFragment1, 0, 0);
+ wc_printf("<br>\n");
+StrEscAppend(WC->WBuf, NULL, WC->UrlFragment12 0, 0);
+ wc_printf("<br>\n");
+StrEscAppend(WC->WBuf, NULL, WC->UrlFragment3, 0, 0);
+*/
+ wc_printf("</PRE><hr />\n");
+ wc_printf("Variables: <br><PRE>\n");
+ dump_vars();
+ wc_printf("</PRE><hr />\n");
+ wDumpContent(1);
+}
+
+
+void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBuf *Name = NULL;
+ StrBuf *UrlBuf = NULL;
+ wcsession *WCC = WC;
+
+ if (WCC != NULL) {
+ long n;
+
+ n = GetTemplateTokenNumber(Target, TP, 0, 0);
+ if (n == 0) {
+ if (WCC->Hdr->HR.Handler != NULL)
+ UrlBuf = Name = WCC->Hdr->HR.Handler->Name;
+ }
+ else if (n == 1) {
+ UrlBuf = NewStrBuf();
+ StrBufExtract_token(UrlBuf, WCC->Hdr->HR.ReqLine, 0, '/');