/* $Id$ */
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+
+#ifdef HAVE_ICAL_H
+#ifdef HAVE_LIBICAL
+#define WEBCIT_WITH_CALENDAR_SERVICE 1
+#endif
+#endif
+
+#ifdef WEBCIT_WITH_CALENDAR_SERVICE
+#include <ical.h>
+#endif
+
+#define CALENDAR_ROOM_NAME "Calendar"
+#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
+
+#define SIZ 4096 /* generic buffer size */
+
#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
#define SLEEPING 180 /* TCP connection timeout */
#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
#define PORT_NUM 2000 /* port number to listen on */
-#define SERVER "WebCit v2.12" /* who's in da house */
+#define SERVER "WebCit v5.00" /* who's in da house */
#define DEVELOPER_ID 0
#define CLIENT_ID 4
-#define CLIENT_VERSION 212
+#define CLIENT_VERSION 500 /* This version of WebCit */
+#define MINIMUM_CIT_VERSION 607 /* min required Citadel vers */
#define DEFAULT_HOST "localhost" /* Default Citadel server */
#define DEFAULT_PORT "504"
#define LB (1) /* Internal escape chars */
#define RB (2)
#define QU (3)
#define TARGET "webcit01" /* Target for inline URL's */
-#define HOUSEKEEPING 60 /* Housekeeping frequency */
+#define HOUSEKEEPING 15 /* Housekeeping frequency */
#define INITIAL_WORKER_THREADS 5
-#define LISTEN_QUEUE_LENGTH 20 /* listen() backlog queue */
-
-
-/* Room flags (from Citadel) */
-#define QR_PERMANENT 1 /* Room does not purge */
-#define QR_INUSE 2 /* Set if in use, clear if avail */
-#define QR_PRIVATE 4 /* Set for any type of private room */
-#define QR_PASSWORDED 8 /* Set if there's a password too */
-#define QR_GUESSNAME 16 /* Set if it's a guessname room */
-#define QR_DIRECTORY 32 /* Directory room */
-#define QR_UPLOAD 64 /* Allowed to upload */
-#define QR_DOWNLOAD 128 /* Allowed to download */
-#define QR_VISDIR 256 /* Visible directory */
-#define QR_ANONONLY 512 /* Anonymous-Only room */
-#define QR_ANONOPT 1024 /* Anonymous-Option room */
-#define QR_NETWORK 2048 /* Shared network room */
-#define QR_PREFONLY 4096 /* Preferred status needed to enter */
-#define QR_READONLY 8192 /* Aide status required to post */
-#define QR_MAILBOX 16384 /* Set if this is a private mailbox */
+#define LISTEN_QUEUE_LENGTH 100 /* listen() backlog queue */
+
+#define USERCONFIGROOM "My Citadel Config"
+
+
+/*
+ * Room flags (from Citadel)
+ *
+ * bucket one...
+ */
+#define QR_PERMANENT 1 /* Room does not purge */
+#define QR_INUSE 2 /* Set if in use, clear if avail */
+#define QR_PRIVATE 4 /* Set for any type of private room */
+#define QR_PASSWORDED 8 /* Set if there's a password too */
+#define QR_GUESSNAME 16 /* Set if it's a guessname room */
+#define QR_DIRECTORY 32 /* Directory room */
+#define QR_UPLOAD 64 /* Allowed to upload */
+#define QR_DOWNLOAD 128 /* Allowed to download */
+#define QR_VISDIR 256 /* Visible directory */
+#define QR_ANONONLY 512 /* Anonymous-Only room */
+#define QR_ANONOPT 1024 /* Anonymous-Option room */
+#define QR_NETWORK 2048 /* Shared network room */
+#define QR_PREFONLY 4096 /* Preferred status needed to enter */
+#define QR_READONLY 8192 /* Aide status required to post */
+#define QR_MAILBOX 16384 /* Set if this is a private mailbox */
+
+/*
+ * bucket two...
+ */
+#define QR2_SYSTEM 1 /* System room; hide by default */
+#define QR2_SELFLIST 2 /* Self-service mailing list mgmt */
+
+
+#define UA_KNOWN 2
+#define UA_GOTOALLOWED 4
+#define UA_HASNEWMSGS 8
+#define UA_ZAPPED 16
+
+
+
+
struct httprequest {
struct httprequest *next;
- char line[256];
+ char line[SIZ];
};
struct urlcontent {
int serv_rev_level;
char serv_bbs_city[64];
char serv_sysadm[64];
- char serv_moreprompt[256];
+ char serv_moreprompt[SIZ];
int serv_ok_floors;
};
+/*
+ * Dynamic content for variable substitution in templates
+ */
+struct wcsubst {
+ struct wcsubst *next;
+ int wcs_type;
+ char wcs_key[32];
+ void *wcs_value;
+ void (*wcs_function)(void);
+};
+/*
+ * Values for wcs_type
+ */
+enum {
+ WCS_STRING,
+ WCS_FUNCTION,
+ WCS_SERVCMD
+};
+struct wc_attachment {
+ struct wc_attachment *next;
+ size_t length;
+ char content_type[SIZ];
+ char filename[SIZ];
+ char *data;
+};
+
/*
* One of these is kept for each active Citadel session.
struct wcsession {
struct wcsession *next; /* Linked list */
int wc_session; /* WebCit session ID */
- char wc_username[256];
- char wc_password[256];
- char wc_roomname[256];
+ char wc_username[SIZ];
+ char wc_password[SIZ];
+ char wc_roomname[SIZ];
int connected;
int logged_in;
int axlevel;
int http_sock;
int serv_sock;
unsigned room_flags;
+ int wc_view;
+ int wc_default_view;
char ugname[128];
long uglsn;
int upload_length;
char *upload;
+ char upload_filename[SIZ];
+ char upload_content_type[SIZ];
int new_mail;
- int need_vali;
+ int remember_new_mail;
+ int need_regi; /* This user needs to register. */
+ int need_vali; /* New users require validation. */
+ char cs_inet_email[SIZ]; /* User's preferred Internet addr. */
pthread_mutex_t SessionMutex; /* mutex for exclusive access */
time_t lastreq; /* Timestamp of most recent HTTP */
int killthis; /* Nonzero == purge this session */
struct march *march; /* march mode room list */
- char reply_to[512]; /* reply-to address */
- long msgarr[1024]; /* for read operations */
+ char reply_to[SIZ]; /* reply-to address */
+ long msgarr[4096]; /* for read operations */
int fake_frames;
+ int is_wap; /* Client is a WAP gateway */
struct urlcontent *urlstrings;
int HaveExpressMessages; /* Nonzero if incoming msgs exist */
+ struct wcsubst *vars;
+ char this_page[SIZ]; /* address of current page */
+ char http_host[SIZ]; /* HTTP Host: header */
+ char *preferences;
+#ifdef HAVE_ICAL_H
+ icalcomponent **disp_cal; /* store calendar items for display */
+ long *cal_msgnum; /* store calendar msgids for display */
+ int num_cal;
+#endif
+ struct wc_attachment *first_attachment;
+ char ImportantMessage[SIZ];
};
-
+#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|')
+#define num_parms(source) num_tokens(source, '|')
#define WC ((struct wcsession *)pthread_getspecific(MyConKey))
extern pthread_key_t MyConKey;
struct serv_info serv_info;
-extern char floorlist[128][256];
+extern char floorlist[128][SIZ];
extern char *axdefs[];
-extern char *defaulthost, *defaultport;
+extern char *ctdlhost, *ctdlport;
+extern char *server_cookie;
+
+extern struct wcsubst *global_subst;
void stuff_to_cookie(char *cookie, int session,
void do_logout(void);
void display_main_menu(void);
void display_advanced_menu(void);
-void list_all_rooms_by_floor(void);
void slrp_highest(void);
void gotonext(void);
void ungoto(void);
void serv_gets(char *strbuf);
void serv_puts(char *string);
void whobbs(void);
-void fmout(FILE * fp);
+void fmout(FILE *fp, char *align);
void wDumpContent(int);
void serv_printf(const char *format,...);
char *bstr(char *key);
-char *urlesc(char *);
+void urlesc(char *, char *);
void urlescputs(char *);
void output_headers(int);
void wprintf(const char *format,...);
-void extract(char *dest, char *source, int parmnum);
-int extract_int(char *source, int parmnum);
void output_static(char *what);
+void stresc(char *target, char *strbuf, int nbsp);
void escputs(char *strbuf);
void url(char *buf);
void escputs1(char *strbuf, int nbsp);
long extract_long(char *source, long int parmnum);
+int extract_int(char *source, int parmnum);
+void stripout(char *str, char leftboundary, char rightboundary);
void dump_vars(void);
void embed_main_menu(void);
void serv_read(char *buf, int bytes);
int haschar(char *, char);
void readloop(char *oper);
-void text_to_server(char *ptr);
+void text_to_server(char *ptr, int convert_to_html);
void display_enter(void);
void post_message(void);
void confirm_delete_msg(void);
void zapped_list(void);
void display_zap(void);
void zap(void);
-void display_error(char *);
void display_success(char *);
void display_entroom(void);
void entroom(void);
void display_editroom(void);
+void netedit(void);
void editroom(void);
+void display_whok(void);
void server_to_text(void);
void save_edit(char *description, char *enter_cmd, int regoto);
void display_edit(char *description, char *check_cmd,
- char *read_cmd, char *save_cmd);
+ char *read_cmd, char *save_cmd, int headers_type);
void gotoroom(char *gname, int display_name);
void confirm_delete_room(void);
void delete_room(void);
void serv_puts(char *string);
void serv_printf(const char *format,...);
void load_floorlist(void);
-void select_floor_to_edit_pic(void);
void display_reg(int);
-void register_user(void);
void display_changepw(void);
void changepw(void);
void display_edit_node(void);
+void edit_node(void);
void display_netconf(void);
-void display_confirm_unshare(void);
void display_confirm_delete_node(void);
void delete_node(void);
-void unshare(void);
void display_add_node(void);
void add_node(void);
-void display_share(void);
-void share(void);
void terminate_session(void);
void edit_me(void);
void display_siteconfig(void);
void smart_goto(char *);
void worker_entry(void);
void session_loop(struct httprequest *);
-void mime_parser(char *content,
- int ContentLength,
- char *ContentType,
- void (*CallBack)
- (char *cbname,
- char *cbfilename,
- char *cbencoding,
- void *cbcontent, char *cbtype, size_t cblength)
-);
void fmt_date(char *buf, time_t thetime);
+void fmt_time(char *buf, time_t thetime);
void httpdate(char *buf, time_t thetime);
void end_webcit_session(void);
void page_popup(void);
+void http_redirect(char *);
+void clear_local_substs(void);
+void svprintf(char *keyname, int keytype, const char *format,...);
+void svcallback(char *keyname, void (*fcn_ptr)() );
+void do_template(void *templatename);
+int lingering_close(int fd);
+char *memreadline(char *start, char *buf, int maxlen);
+int num_tokens (char *source, char tok);
+void extract_token(char *dest, char *source, int parmnum, char separator);
+void remove_token(char *source, int parmnum, char separator);
+char *load_mimepart(long msgnum, char *partnum);
+int pattern2(char *search, char *patn);
+void do_edit_vcard(long, char *, char *);
+void edit_vcard(void);
+void submit_vcard(void);
+void striplt(char *);
+void select_user_to_edit(char *message, char *preselect);
+void display_edituser(char *who);
+void create_user(void);
+void edituser(void);
+void change_view(void);
+void folders(void);
+void do_stuff_to_msgs(void);
+void load_preferences(void);
+void save_preferences(void);
+void get_preference(char *key, char *value);
+void set_preference(char *key, char *value);
+void knrooms(void);
+int is_msg_in_mset(char *mset, long msgnum);
+char *safestrncpy(char *dest, const char *src, size_t n);
+void display_addressbook(long msgnum, char alpha);
+void offer_start_page(void);
+void change_start_page(void);
+void output_html(void);
+void display_floorconfig(char *);
+void delete_floor(void);
+void create_floor(void);
+void rename_floor(void);
+void do_listsub(void);
+void toggle_self_service(void);
+void summary(void);
+ssize_t write(int fd, const void *buf, size_t count);
+void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum);
+void display_calendar(long msgnum);
+void display_task(long msgnum);
+void do_calendar_view(void);
+void free_calendar_buffer(void);
+void calendar_summary_view(void);
+int load_msg_ptrs(char *servcmd);
+void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen);
+int CtdlDecodeBase64(char *dest, const char *source, size_t length);
+void free_attachments(struct wcsession *sess);
+
+
+#ifdef HAVE_ICAL_H
+void display_edit_task(void);
+void save_task(void);
+void display_edit_event(void);
+void save_event(void);
+void display_icaltimetype_as_webform(struct icaltimetype *, char *);
+struct icaltimetype icaltime_from_webform(char *prefix);
+void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum);
+void save_individual_event(icalcomponent *supplied_vtodo, long msgnum);
+void generate_new_uid(char *);
+void respond_to_request(void);
+void handle_rsvp(void);
+void ical_dezonify(icalcomponent *cal);
+void partstat_as_string(char *buf, icalproperty *attendee);
+icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
+void check_attendee_availability(icalcomponent *supplied_vevent);
+void do_freebusy(char *req);
+#endif
+
+extern char *months[];
+extern char *days[];
+void read_server_binary(char *buffer, size_t total_len);
+char *read_server_text(void);
+int goto_config_room(void);
+long locate_user_vcard(char *username, long usernum);
+void sleeeeeeeeeep(int);
+void http_transmit_thing(char *thing, size_t length, char *content_type,
+ int is_static);
+void unescape_input(char *buf);