]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/webcit.h
/ctdl/f/ to get a list of all floors
[citadel.git] / webcit-ng / webcit.h
index a818260d3824a9c23fab689d797f11b35b8c1fc6..c98be4b71eeb2ccb763d682e2a6179818913f8e3 100644 (file)
@@ -1,11 +1,11 @@
-/*
- * webcit.h - "header of headers"
- *
- * Copyright (c) 1996-2018 by the citadel.org team
- *
- * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License, version 3.
- */
+// webcit.h - "header of headers"
+//
+// Copyright (c) 1996-2022 by the citadel.org team
+//
+// This program is open source software.  You can redistribute it and/or
+// modify it under the terms of the GNU General Public License, version 3.
+
+#define SHOW_ME_VAPPEND_PRINTF
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -22,6 +22,7 @@
 #include <netdb.h>
 #include <sys/un.h>
 #include <sys/poll.h>
+#include <sys/time.h>
 #include <string.h>
 #include <pwd.h>
 #include <errno.h>
@@ -39,9 +40,9 @@
 #include <openssl/rand.h>
 #include <expat.h>
 #define _(x)   x                               // temporary hack until we add i18n back in
-//#define DEBUG_HTTP                           // uncomment to debug HTTP headers
+#define DEBUG_HTTP                             // uncomment to debug HTTP headers
 
-/* XML_StopParser is present in expat 2.x */
+// XML_StopParser is present in expat 2.x
 #if XML_MAJOR_VERSION > 1
 #define HAVE_XML_STOPPARSER
 #endif
@@ -51,23 +52,23 @@ struct client_handle {                              // this gets passed up the stack from the webserver to
        SSL *ssl_handle;
 };
 
-struct http_header {                           // request and response headers in struct http_transaction use this format
-       struct http_header *next;
+struct keyval {                                        // key/value pair (for array)
        char *key;
        char *val;
 };
 
 struct http_transaction {                      // The lifetime of an HTTP request goes through this data structure.
        char *method;                           // The top half is built up by the web server and sent up to the
-       char *uri;                              // application stack.  The second half is built up by the application
+       char *url;                              // application stack.  The second half is built up by the application
        char *http_version;                     // stack and sent back down to the web server, which transmits it to
        char *site_prefix;                      // the client.
-       struct http_header *request_headers;
+       Array *request_headers;
        char *request_body;
        long request_body_length;
+       Array *request_parms;                   // anything after the "?" in the URL
        int response_code;
        char *response_string;
-       struct http_header *response_headers;
+       Array *response_headers;
        char *response_body;
        long response_body_length;
 };
@@ -91,8 +92,7 @@ struct ctdlsession {
 
 extern char *ssl_cipher_list;
 extern int is_https;                           // nonzero if we are an HTTPS server today
-extern char *ctdlhost;
-extern char *ctdlport;
+extern char *ctdl_dir;                         // directory where Citadel Server is running
 void init_ssl(void);
 void starttls(struct client_handle *);
 void endtls(struct client_handle *);
@@ -108,19 +108,13 @@ enum {
 #define TRACE syslog(LOG_DEBUG, "\033[3%dmCHECKPOINT: %s:%d\033[0m", ((__LINE__%6)+1), __FILE__, __LINE__)
 #define SLEEPING               180             // TCP connection timeout
 #define MAX_WORKER_THREADS     32              // Maximum number of worker threads permitted to exist
-#define        CTDL_CRYPTO_DIR         "keys"
-#define CTDL_KEY_PATH          CTDL_CRYPTO_DIR "/webcit.key"
-#define CTDL_CSR_PATH          CTDL_CRYPTO_DIR "/webcit.csr"
-#define CTDL_CER_PATH          CTDL_CRYPTO_DIR "/webcit.cer"
-#define SIGN_DAYS              3650            // how long our certificate should live
 #define DEFAULT_SSL_CIPHER_LIST "DEFAULT"       // See http://openssl.org/docs/apps/ciphers.html
 #define WEBSERVER_PORT         80
 #define WEBSERVER_INTERFACE    "*"
-#define CTDLHOST               "uncensored.citadel.org"
-#define CTDLPORT               "504"
+#define CTDL_DIR               "/usr/local/citadel"
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4
-#define TARGET                 "webcit01"      /* Window target for inline URL's */
+#define TARGET                 "webcit02"      /* Window target for inline URL's */
 
 void worker_entry(int *pointer_to_master_socket);
 void perform_one_http_transaction(struct client_handle *ch);
@@ -129,12 +123,14 @@ void perform_request(struct http_transaction *);
 void do_404(struct http_transaction *);
 void output_static(struct http_transaction *);
 int uds_connectsock(char *sockpath);
-int tcp_connectsock(char *host, char *service);
 void ctdl_a(struct http_transaction *, struct ctdlsession *);
+void ctdl_f(struct http_transaction *, struct ctdlsession *);
 void ctdl_r(struct http_transaction *, struct ctdlsession *);
+void ctdl_u(struct http_transaction *, struct ctdlsession *);
 struct ctdlsession *connect_to_citadel(struct http_transaction *);
 void disconnect_from_citadel(struct ctdlsession *);
 char *header_val(struct http_transaction *h, char *requested_header);
+char *get_url_param(struct http_transaction *h, char *requested_param);
 int unescape_input(char *);
 void http_redirect(struct http_transaction *h, char *to_where);
 char *http_datestring(time_t xtime);
@@ -147,14 +143,13 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg
 void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *euid, long old_msgnum);
 ssize_t ctdl_write(struct ctdlsession *ctdl, const void *buf, size_t count);
 int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf);
-void threaded_view(struct http_transaction *h, struct ctdlsession *c, char *which);
-void flat_view(struct http_transaction *h, struct ctdlsession *c, char *which);
 StrBuf *ctdl_readtextmsg(struct ctdlsession *ctdl);
 StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source);
 void download_mime_component(struct http_transaction *h, struct ctdlsession *c, long msgnum, char *partnum);
 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source);
 StrBuf *variformat2html(StrBuf *Source);
 int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes);
+int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested);
 void ctdl_c(struct http_transaction *h, struct ctdlsession *c);
 int webserver(char *webserver_interface, int webserver_port, int webserver_protocol);
 void ctdl_printf(struct ctdlsession *ctdl, const char *format,...);
@@ -163,3 +158,4 @@ void do_502(struct http_transaction *h);
 void do_404(struct http_transaction *h);
 void do_412(struct http_transaction *h);
 void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf);
+void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum);