/*
* Extract variables from the URL.
*/
-void addurls(char *url)
+void addurls(char *url, long ulen)
{
char *aptr, *bptr, *eptr;
char *up;
- char buf[SIZ] = "";
- int len, n, keylen;
+ char *buf;
+ int len, keylen;
urlcontent *u;
struct wcsession *WCC = WC;
if (WCC->urlstrings == NULL)
WCC->urlstrings = NewHash(1, NULL);
- eptr = buf + sizeof (buf);
- up = url;
- /** locate the = sign */
- n = safestrncpy(buf, up, sizeof buf);
- if (n < 0) /* hm, we exceeded the buffer... hmmm what to do now? */
- n = -n;
+ buf = (char*) malloc (ulen + 1);
+ memcpy(buf, url, ulen);
+ buf[ulen] = '\0';
+ eptr = buf + ulen;
up = buf;
while (!IsEmptyStr(up)) {
aptr = up;
u->url_data[u->url_data_size] = '\0';
up = bptr;
++up;
-
#ifdef DEBUG_URLSTRINGS
lprintf(9, "%s = [%ld] %s\n", u->url_key, u->url_data_size, u->url_data);
#endif
*tptr = '\0';
}
-/**
- * \brief print a string to the client after cleaning it with msgesc() and stresc()
- * \param strbuf string to be printed
+/*
+ * print a string to the client after cleaning it with msgesc() and stresc()
*/
void msgescputs1( char *strbuf)
{
free(outbuf2);
}
-/**
- * \brief print a string to the client after cleaning it with msgesc()
- * \param strbuf string to be printed
+/*
+ * print a string to the client after cleaning it with msgesc()
*/
void msgescputs(char *strbuf) {
char *outbuf;
}
if (cache) {
+ char httpTomorow[128];
+
+ http_datestring(httpTomorow, sizeof httpTomorow,
+ time(NULL) + 60 * 60 * 24 * 2);
+
wprintf("Pragma: public\r\n"
"Cache-Control: max-age=3600, must-revalidate\r\n"
- "Last-modified: %s\r\n",
- httpnow
+ "Last-modified: %s\r\n"
+ "Expires: %s\r\n",
+ httpnow,
+ httpTomorow
);
}
else {
client_write(thing, (size_t)length);
}
-/**
- * \brief print menu box like used in the floor view or admin interface.
+/*
+ * print menu box like used in the floor view or admin interface.
* This function takes pair of strings as va_args,
- * \param Title Title string of the box
- * \param Class CSS Class for the box
- * \param nLines How many string pairs should we print? (URL, UrlText)
- * \param ... Pairs of URL Strings and their Names
+ * Title Title string of the box
+ * Class CSS Class for the box
+ * nLines How many string pairs should we print? (URL, UrlText)
+ * ... Pairs of URL Strings and their Names
*/
void print_menu_box(char* Title, char *Class, int nLines, ...)
{
}
-/**
- * \brief dump out static pages from disk
- * \param what the file urs to print
+/*
+ * dump out static pages from disk
*/
void output_static(char *what)
{
}
}
-/**
- * \brief When the browser requests an image file from the Citadel server,
+/*
+ * When the browser requests an image file from the Citadel server,
* this function is called to transmit it.
*/
void output_image()
}
- /**
+ /*
* Instead of an ugly 404, send a 1x1 transparent GIF
* when there's no such image on the server.
*/
output_static(blank_gif);
}
-/**
- * \brief Extract an embedded photo from a vCard for display on the client
- *
- * \param msgnum
- */
+/*
+ * Extract an embedded photo from a vCard for display on the client
+ */
void display_vcard_photo_img(char *msgnum_as_string)
{
long msgnum = 0L;
free(xferbuf);
}
-/**
- * \brief Generic function to output an arbitrary MIME part from an arbitrary
- * message number on the server.
+/*
+ * Generic function to output an arbitrary MIME part from an arbitrary
+ * message number on the server.
*
- * \param msgnum Number of the item on the citadel server
- * \param partnum The MIME part to be output
- * \param force_download Nonzero to force set the Content-Type: header
- * to "application/octet-stream"
+ * msgnum Number of the item on the citadel server
+ * partnum The MIME part to be output
+ * force_download Nonzero to force set the Content-Type: header to "application/octet-stream"
*/
void mimepart(char *msgnum, char *partnum, int force_download)
{
}
-/**
- * \brief Read any MIME part of a message, from the server, into memory.
- * \param msgnum number of the message on the citadel server
- * \param partnum the MIME part to be loaded
+/*
+ * Read any MIME part of a message, from the server, into memory.
*/
char *load_mimepart(long msgnum, char *partnum)
{
}
-/**
- * \brief Convenience functions to display a page containing only a string
- * \param titlebarcolor color of the titlebar of the frame
- * \param titlebarmsg text to display in the title bar
- * \param messagetext body of the box
+/*
+ * Convenience functions to display a page containing only a string
+ *
+ * titlebarcolor color of the titlebar of the frame
+ * titlebarmsg text to display in the title bar
+ * messagetext body of the box
*/
void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
{
}
-/**
- * \brief Display a blank page.
+/*
+ * Display a blank page.
*/
void blank_page(void) {
output_headers(1, 1, 0, 0, 0, 0);
}
-/**
- * \brief A template has been requested
+/*
+ * A template has been requested
*/
void url_do_template(void) {
do_template(bstr("template"));
-/**
- * \brief Offer to make any page the user's "start page."
+/*
+ * Offer to make any page the user's "start page."
*/
void offer_start_page(void) {
wprintf("<a href=\"change_start_page?startpage=");
}
-/**
- * \brief Change the user's start page
+/*
+ * Change the user's start page
*/
void change_start_page(void) {
-/**
- * \brief convenience function to indicate success
- * \param successmessage the mesage itself
+/*
+ * convenience function to indicate success
*/
void display_success(char *successmessage)
{
}
-/**
- * \brief Authorization required page
+/*
+ * Authorization required page
* This is probably temporary and should be revisited
- * \param message message to put in header
-*/
+ */
void authorization_required(const char *message)
{
wprintf("HTTP/1.1 401 Authorization Required\r\n");
wDumpContent(0);
}
-/**
- * \brief This function is called by the MIME parser to handle data uploaded by
- * the browser. Form data, uploaded files, and the data from HTTP PUT
- * operations (such as those found in GroupDAV) all arrive this way.
+/*
+ * This function is called by the MIME parser to handle data uploaded by
+ * the browser. Form data, uploaded files, and the data from HTTP PUT
+ * operations (such as those found in GroupDAV) all arrive this way.
*
- * \param name Name of the item being uploaded
- * \param filename Filename of the item being uploaded
- * \param partnum MIME part identifier (not needed)
- * \param disp MIME content disposition (not needed)
- * \param content The actual data
- * \param cbtype MIME content-type
- * \param cbcharset Character set
- * \param length Content length
- * \param encoding MIME encoding type (not needed)
- * \param userdata Not used here
+ * name Name of the item being uploaded
+ * filename Filename of the item being uploaded
+ * partnum MIME part identifier (not needed)
+ * disp MIME content disposition (not needed)
+ * content The actual data
+ * cbtype MIME content-type
+ * cbcharset Character set
+ * length Content length
+ * encoding MIME encoding type (not needed)
+ * userdata Not used here
*/
void upload_handler(char *name, char *filename, char *partnum, char *disp,
void *content, char *cbtype, char *cbcharset,
size_t length, char *encoding, void *userdata)
{
urlcontent *u;
-/*
+#ifdef DEBUG_URLSTRINGS
lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n", name, cbtype, length);
-*/
+#endif
if (WC->urlstrings == NULL)
WC->urlstrings = NewHash(1, NULL);
memcpy(u->url_data, content, length);
u->url_data[length] = 0;
Put(WC->urlstrings, u->url_key, strlen(u->url_key), u, free_url);
-
-/* lprintf(9, "Key: <%s> len: [%ld] Data: <%s>\n", u->url_key, u->url_data_size, u->url_data);*/
+#ifdef DEBUG_URLSTRINGS
+ lprintf(9, "Key: <%s> len: [%ld] Data: <%s>\n", u->url_key, u->url_data_size, u->url_data);
+#endif
}
/** Uploaded files */
}
-/**
- * \brief Convenience functions to wrap around asynchronous ajax responses
+/*
+ * Convenience functions to wrap around asynchronous ajax responses
*/
void begin_ajax_response(void) {
output_headers(0, 0, 0, 0, 0, 0);
begin_burst();
}
-/**
- * \brief print ajax response footer
+/*
+ * print ajax response footer
*/
void end_ajax_response(void) {
wprintf("\r\n");
wDumpContent(0);
}
-/**
- * \brief Wraps a Citadel server command in an AJAX transaction.
+/*
+ * Wraps a Citadel server command in an AJAX transaction.
*/
void ajax_servcmd(void)
{
end_ajax_response();
- /**
+ /*
* This is kind of an ugly hack, but this is the only place it can go.
* If the command was GEXP, then the instant messenger window must be
* running, so reset the "last_pager_check" watchdog timer so
}
-/**
- * \brief Helper function for the asynchronous check to see if we need
+/*
+ * Helper function for the asynchronous check to see if we need
* to open the instant messenger window.
*/
void seconds_since_last_gexp(void)
-/**
- * \brief Entry point for WebCit transaction
+/*
+ * Entry point for WebCit transaction
*/
void session_loop(struct httprequest *req)
{
char pathname[1024];
int a, b, nBackDots, nEmpty;
int ContentLength = 0;
- int BytesRead = 0;
char ContentType[512];
char *content = NULL;
char *content_end = NULL;
int is_static = 0;
int n_static = 0;
int len = 0;
- /**
+ /*
* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
*/
}
if (ContentLength > 0) {
- content = malloc(ContentLength + SIZ);
- memset(content, 0, ContentLength + SIZ);
- snprintf(content, ContentLength + SIZ, "Content-type: %s\n"
+ int BuffSize;
+
+ BuffSize = ContentLength + SIZ;
+ content = malloc(BuffSize);
+ memset(content, 0, BuffSize);
+ snprintf(content, BuffSize, "Content-type: %s\n"
"Content-length: %d\n\n",
ContentType, ContentLength);
body_start = strlen(content);
/** Read the entire input data at once. */
- client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
+ client_read(WC->http_sock, &content[body_start], ContentLength);
if (!strncasecmp(ContentType, "application/x-www-form-urlencoded", 33)) {
- addurls(&content[body_start]);
+ addurls(&content[body_start], ContentLength);
} else if (!strncasecmp(ContentType, "multipart", 9)) {
content_end = content + ContentLength + body_start;
mime_parser(content, content_end, *upload_handler, NULL, NULL, NULL, 0);
content = NULL;
}
- /** make a note of where we are in case the user wants to save it */
+ /* make a note of where we are in case the user wants to save it */
safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
remove_token(WC->this_page, 2, ' ');
remove_token(WC->this_page, 0, ' ');
- /** If there are variables in the URL, we must grab them now */
+ /* If there are variables in the URL, we must grab them now */
len = strlen(cmd);
for (a = 0; a < len; ++a) {
if ((cmd[a] == '?') || (cmd[a] == '&')) {
len = b - 1;
}
}
- addurls(&cmd[a + 1]);
+ addurls(&cmd[a + 1], len - a);
cmd[a] = 0;
len = a - 1;
}
}
- /** If it's a "force 404" situation then display the error and bail. */
+ /* If it's a "force 404" situation then display the error and bail. */
if (!strcmp(action, "404")) {
wprintf("HTTP/1.1 404 Not found\r\n");
wprintf("Content-Type: text/plain\r\n");
goto SKIP_ALL_THIS_CRAP;
}
- /** Static content can be sent without connecting to Citadel. */
+ /* Static content can be sent without connecting to Citadel. */
is_static = 0;
for (a=0; a<ndirs; ++a) {
if (!strcasecmp(action, (char*)static_content_dirs[a])) { /* map web to disk location */
}
}
- /**
+ /*
* If we're not connected to a Citadel server, try to hook up the
* connection now.
*/
}
}
- /**
+ /*
* Functions which can be performed without logging in
*/
if (!strcasecmp(action, "listsub")) {
goto SKIP_ALL_THIS_CRAP;
}
- /**
+ /*
* If we're not logged in, but we have HTTP Authentication data,
* try logging in to Citadel using that.
*/
safestrncpy(WC->httpauth_user, c_httpauth_user, sizeof WC->httpauth_user);
safestrncpy(WC->httpauth_pass, c_httpauth_pass, sizeof WC->httpauth_pass);
} else {
- /** Should only display when password is wrong */
+ /* Should only display when password is wrong */
authorization_required(&buf[4]);
goto SKIP_ALL_THIS_CRAP;
}
}
}
- /** This needs to run early */
+ /* This needs to run early */
#ifdef TECH_PREVIEW
if (!strcasecmp(action, "rss")) {
display_rss(bstr("room"), request_method);
}
#endif
- /**
+ /*
* The GroupDAV stuff relies on HTTP authentication instead of
* our session's authentication.
*/
}
- /**
+ /*
* Automatically send requests with any method other than GET or
* POST to the GroupDAV code as well.
*/
goto SKIP_ALL_THIS_CRAP;
}
- /**
+ /*
* If we're not logged in, but we have username and password cookies
* supplied by the browser, try using them to log in.
*/
}
}
}
- /**
+ /*
* If we don't have a current room, but a cookie specifying the
* current room is supplied, make an effort to go there.
*/
display_openid_login(NULL);
} else if ((!WC->logged_in) && (!strcasecmp(action, "openid_login"))) {
do_openid_login();
- } else if ((!WC->logged_in) && (!strcasecmp(action, "finish_openid_login"))) {
- finish_openid_login();
+ } else if (!strcasecmp(action, "finalize_openid_login")) {
+ finalize_openid_login();
} else if (!WC->logged_in) {
display_login(NULL);
}
download_file(index[1]);
} else if (!strcasecmp(action, "upload_file")) {
upload_file();
+ } else if (!strcasecmp(action, "display_openids")) {
+ display_openids();
+ } else if (!strcasecmp(action, "openid_attach")) {
+ openid_attach();
+ } else if (!strcasecmp(action, "openid_detach")) {
+ openid_detach();
}
- /** When all else fais, display the main menu. */
+ /* When all else fais, display the main menu. */
else {
display_main_menu();
}
}
}
-/**
- * \brief Replacement for sleep() that uses select() in order to avoid SIGALRM
- * \param seconds how many seconds should we sleep?
+/*
+ * Replacement for sleep() that uses select() in order to avoid SIGALRM
*/
void sleeeeeeeeeep(int seconds)
{
}
-/*@}*/