void do_welcome(void) {
-
- fprintf(stderr, "DO_WELCOME CALLED, NOFRAMES=%d\n", noframes);
-
if (noframes) {
printf("HTTP/1.0 200 OK\n");
output_headers(1, "_top");
escputs(wc_username);
wprintf("</H1>\n");
/* FIX add user stats here */
-
- wprintf("<HR>");
- embed_main_menu();
-
wDumpContent(1);
}
else wprintf("Goodbye\n");
wprintf("<HR><A HREF=\"/\">Log in again</A></CENTER>\n");
- wDumpContent(1);
+ wDumpContent(2);
serv_puts("QUIT");
exit(0);
}
/*
- * Locate the room on the march list which we most want to go to
+ * Locate the room on the march list which we most want to go to. Each room
+ * is measured given a "weight" of preference based on various factors.
*/
char *pop_march(int desired_floor) {
static char TheRoom[64];
int TheFloor = 0;
int TheOrder = 32767;
+ int TheWeight = 0;
+ int weight;
struct march *mptr = NULL;
strcpy(TheRoom, "_BASEROOM_");
if (march == NULL) return(TheRoom);
for (mptr = march; mptr != NULL; mptr = mptr->next) {
- if ((strcasecmp(mptr->march_name, "_BASEROOM_"))
- &&(!strcasecmp(TheRoom, "_BASEROOM_"))) {
- strcpy(TheRoom, mptr->march_name);
- TheFloor = mptr->march_floor;
- TheOrder = mptr->march_order;
- }
- else if ( (mptr->march_floor == desired_floor)
- && (TheFloor != desired_floor)
- && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
- strcpy(TheRoom, mptr->march_name);
- TheFloor = mptr->march_floor;
- TheOrder = mptr->march_order;
- }
- else if ((mptr->march_floor < TheFloor)
- && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
- strcpy(TheRoom, mptr->march_name);
- TheFloor = mptr->march_floor;
- TheOrder = mptr->march_order;
- }
- else if ((mptr->march_order < TheOrder)
- && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
+ weight = 0;
+ if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
+ weight = weight + 10000;
+ if (mptr->march_floor == desired_floor)
+ weight = weight + 5000;
+
+ weight = weight + ((128-(mptr->march_floor))*128);
+ weight = weight + (128-(mptr->march_order));
+
+ if (weight > TheWeight) {
+ TheWeight = weight;
strcpy(TheRoom, mptr->march_name);
TheFloor = mptr->march_floor;
TheOrder = mptr->march_order;
return(len);
}
+/*
+ * wDumpContent() takes all the stuff that's been queued up using
+ * the wprintf() and escputs() functions, and sends it out to the browser.
+ * By queuing instead of transmitting as it's generated, we're able to
+ * calculate a Content-length: header.
+ *
+ * print_standard_html_footer should be set to 0 to transmit only, 1 to
+ * append the main menu (if in noframes mode) and closing tags, or 2 to
+ * append the closing tags only.
+ */
void wDumpContent(int print_standard_html_footer) {
struct webcontent *wptr;
if (print_standard_html_footer) {
- if (noframes) {
+ if ( (noframes) && (print_standard_html_footer != 2) ) {
wprintf("<BR>");
embed_main_menu();
}