Mailing list header changes (fuck you Google)
[citadel.git] / webcit-ng / room_functions.c
1 /*
2  * Room functions
3  *
4  * Copyright (c) 1996-2018 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include "webcit.h"
16
17
18 /*
19  * Return a "zero-terminated" array of message numbers in the current room.
20  * Caller owns the memory and must free it.  Returns NULL if any problems.
21  */
22 long *get_msglist(struct ctdlsession *c, char *which_msgs)
23 {
24         char buf[1024];
25         long *msglist = NULL;
26         int num_msgs = 0;
27         int num_alloc = 0;
28
29         ctdl_printf(c, "MSGS %s", which_msgs);
30         ctdl_readline(c, buf, sizeof(buf));
31         if (buf[0] == '1') {
32                 do {
33                         if (num_msgs >= num_alloc) {
34                                 if (num_alloc == 0) {
35                                         num_alloc = 1024;
36                                         msglist = malloc(num_alloc * sizeof(long));
37                                 } else {
38                                         num_alloc *= 2;
39                                         msglist = realloc(msglist, num_alloc * sizeof(long));
40                                 }
41                         }
42                         ctdl_readline(c, buf, sizeof(buf));
43                         msglist[num_msgs++] = atol(buf);
44                 } while (strcmp(buf, "000"));   // this makes the last element a "0" terminator
45         }
46         return msglist;
47 }
48
49
50 /*
51  * Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and
52  * a message number (which we always use as the entity tag in Citadel), return nonzero if the
53  * message number matches any of the supplied tags in the string.
54  */
55 int match_etags(char *taglist, long msgnum)
56 {
57         int num_tags = num_tokens(taglist, ',');
58         int i = 0;
59         char tag[1024];
60
61         if (msgnum <= 0) {                                      // no msgnum?  no match.
62                 return (0);
63         }
64
65         for (i = 0; i < num_tags; ++i) {
66                 extract_token(tag, taglist, i, ',', sizeof tag);
67                 striplt(tag);
68                 char *lq = (strchr(tag, '"'));
69                 char *rq = (strrchr(tag, '"'));
70                 if (lq < rq) {                                  // has two double quotes
71                         strcpy(rq, "");
72                         strcpy(tag, ++lq);
73                 }
74                 striplt(tag);
75                 if (!strcmp(tag, "*")) {                        // wildcard match
76                         return (1);
77                 }
78                 long tagmsgnum = atol(tag);
79                 if ((tagmsgnum > 0) && (tagmsgnum == msgnum)) { // match
80                         return (1);
81                 }
82         }
83
84         return (0);                                             // no match
85 }
86
87
88 /*
89  * Client is requesting a message list
90  */
91 void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which)
92 {
93         int i = 0;
94         long *msglist = get_msglist(c, which);
95         JsonValue *j = NewJsonArray(HKEY("msgs"));
96
97         if (msglist != NULL) {
98                 for (i = 0; msglist[i] > 0; ++i) {
99                         JsonArrayAppend(j, NewJsonNumber(HKEY("m"), msglist[i]));
100                 }
101                 free(msglist);
102         }
103
104         StrBuf *sj = NewStrBuf();
105         SerializeJson(sj, j, 1);        // '1' == free the source array
106
107         add_response_header(h, strdup("Content-type"), strdup("application/json"));
108         h->response_code = 200;
109         h->response_string = strdup("OK");
110         h->response_body_length = StrLength(sj);
111         h->response_body = SmashStrBuf(&sj);
112         return;
113 }
114
115
116 /*
117  * Client requested an object in a room.
118  */
119 void object_in_room(struct http_transaction *h, struct ctdlsession *c)
120 {
121         char buf[1024];
122         long msgnum = (-1);
123         char unescaped_euid[1024];
124
125         extract_token(buf, h->uri, 4, '/', sizeof buf);
126
127         if (!strncasecmp(buf, "msgs.", 5))      // Client is requesting a list of message numbers
128         {
129                 json_msglist(h, c, &buf[5]);
130                 return;
131         }
132 #if 0
133         if (!strncasecmp(buf, "threads", 5))    // Client is requesting a threaded view (still kind of fuzzy here)
134         {
135                 threaded_view(h, c, &buf[5]);
136                 return;
137         }
138
139         if (!strncasecmp(buf, "flat", 5))       // Client is requesting a flat view (still kind of fuzzy here)
140         {
141                 flat_view(h, c, &buf[5]);
142                 return;
143         }
144 #endif
145
146         if ((c->room_default_view == VIEW_CALENDAR)     // room types where objects are referenced by EUID
147             || (c->room_default_view == VIEW_TASKS)
148             || (c->room_default_view == VIEW_ADDRESSBOOK)
149             ) {
150                 safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
151                 unescape_input(unescaped_euid);
152                 msgnum = locate_message_by_uid(c, unescaped_euid);
153         } else {
154                 msgnum = atol(buf);
155         }
156
157         /*
158          * All methods except PUT require the message to already exist
159          */
160         if ((msgnum <= 0) && (strcasecmp(h->method, "PUT"))) {
161                 do_404(h);
162         }
163
164         /*
165          * If we get to this point we have a valid message number in an accessible room.
166          */
167         syslog(LOG_DEBUG, "msgnum is %ld, method is %s", msgnum, h->method);
168
169         /*
170          * A sixth component in the URL can be one of two things:
171          * (1) a MIME part specifier, in which case the client wants to download that component within the message
172          * (2) a content-type, in which ase the client wants us to try to render it a certain way
173          */
174         if (num_tokens(h->uri, '/') == 6) {
175                 extract_token(buf, h->uri, 5, '/', sizeof buf);
176                 if (!IsEmptyStr(buf)) {
177                         if (!strcasecmp(buf, "json")) {
178                                 json_render_one_message(h, c, msgnum);
179                         } else {
180                                 download_mime_component(h, c, msgnum, buf);
181                         }
182                         return;
183                 }
184         }
185
186         /*
187          * Ok, we want a full message, but first let's check for the if[-none]-match headers.
188          */
189         char *if_match = header_val(h, "If-Match");
190         if ((if_match != NULL) && (!match_etags(if_match, msgnum))) {
191                 do_412(h);
192                 return;
193         }
194
195         char *if_none_match = header_val(h, "If-None-Match");
196         if ((if_none_match != NULL) && (match_etags(if_none_match, msgnum))) {
197                 do_412(h);
198                 return;
199         }
200
201         /*
202          * DOOOOOO ITTTTT!!!
203          */
204
205         if (!strcasecmp(h->method, "DELETE")) {
206                 dav_delete_message(h, c, msgnum);
207         } else if (!strcasecmp(h->method, "GET")) {
208                 dav_get_message(h, c, msgnum);
209         } else if (!strcasecmp(h->method, "PUT")) {
210                 dav_put_message(h, c, unescaped_euid, msgnum);
211         } else {
212                 do_404(h);      // Got this far but the method made no sense?  Bummer.
213         }
214
215 }
216
217
218 /*
219  * Called by the_room_itself() when the HTTP method is REPORT
220  */
221 void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
222 {
223         if (c->room_default_view == VIEW_CALENDAR) {
224                 caldav_report(h, c);    // CalDAV REPORTs ... fmgwac
225                 return;
226         }
227
228         do_404(h);              // future implementations like CardDAV will require code paths here
229 }
230
231
232 /*
233  * Called by the_room_itself() when the HTTP method is OPTIONS
234  */
235 void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
236 {
237         h->response_code = 200;
238         h->response_string = strdup("OK");
239         if (c->room_default_view == VIEW_CALENDAR) {
240                 add_response_header(h, strdup("DAV"), strdup("1, calendar-access"));    // offer CalDAV
241         } else if (c->room_default_view == VIEW_ADDRESSBOOK) {
242                 add_response_header(h, strdup("DAV"), strdup("1, addressbook"));        // offer CardDAV
243         } else {
244                 add_response_header(h, strdup("DAV"), strdup("1"));     // ordinary WebDAV for all other room types
245         }
246         add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE"));
247 }
248
249
250 /*
251  * Called by the_room_itself() when the HTTP method is PROPFIND
252  */
253 void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
254 {
255         char *e;
256         long timestamp;
257         int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX);
258         syslog(LOG_DEBUG, "Client PROPFIND requested depth: %d", dav_depth);
259         StrBuf *Buf = NewStrBuf();
260
261         StrBufAppendPrintf(Buf, "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
262                            "<D:multistatus " "xmlns:D=\"DAV:\" " "xmlns:C=\"urn:ietf:params:xml:ns:caldav\"" ">");
263
264         /* Transmit the collection resource */
265         StrBufAppendPrintf(Buf, "<D:response>");
266         StrBufAppendPrintf(Buf, "<D:href>");
267         StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
268         StrBufAppendPrintf(Buf, "/ctdl/r/");
269         StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
270         StrBufAppendPrintf(Buf, "</D:href>");
271
272         StrBufAppendPrintf(Buf, "<D:propstat>");
273         StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
274         StrBufAppendPrintf(Buf, "<D:prop>");
275         StrBufAppendPrintf(Buf, "<D:displayname>");
276         StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
277         StrBufAppendPrintf(Buf, "</D:displayname>");
278
279         StrBufAppendPrintf(Buf, "<D:owner />"); // empty owner ought to be legal; see rfc3744 section 5.1
280
281         StrBufAppendPrintf(Buf, "<D:resourcetype><D:collection />");
282         switch (c->room_default_view) {
283         case VIEW_CALENDAR:
284                 StrBufAppendPrintf(Buf, "<C:calendar />");      // RFC4791 section 4.2
285                 break;
286         }
287         StrBufAppendPrintf(Buf, "</D:resourcetype>");
288
289         int enumerate_by_euid = 0;      // nonzero if messages will be retrieved by euid instead of msgnum
290         switch (c->room_default_view) {
291         case VIEW_CALENDAR:     // RFC4791 section 5.2
292                 StrBufAppendPrintf(Buf,
293                                    "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
294                 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
295                 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
296                 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
297                 enumerate_by_euid = 1;
298                 break;
299         case VIEW_TASKS:        // RFC4791 section 5.2
300                 StrBufAppendPrintf(Buf,
301                                    "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></C:supported-calendar-component-set>");
302                 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
303                 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
304                 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
305                 enumerate_by_euid = 1;
306                 break;
307         case VIEW_ADDRESSBOOK:  // FIXME put some sort of CardDAV crapola here when we implement it
308                 enumerate_by_euid = 1;
309                 break;
310         case VIEW_WIKI: // FIXME invent "WikiDAV" ?
311                 enumerate_by_euid = 1;
312                 break;
313         }
314
315
316         /* FIXME get the mtime
317            StrBufAppendPrintf(Buf, "<D:getlastmodified>");
318            escputs(datestring);
319            StrBufAppendPrintf(Buf, "</D:getlastmodified>");
320          */
321
322         StrBufAppendPrintf(Buf, "</D:prop>");
323         StrBufAppendPrintf(Buf, "</D:propstat>");
324         StrBufAppendPrintf(Buf, "</D:response>\n");
325
326         // If a depth greater than zero was specified, transmit the collection listing
327         // BEGIN COLLECTION
328         if (dav_depth > 0) {
329                 long *msglist = get_msglist(c, "ALL");
330                 if (msglist) {
331                         int i;
332                         for (i = 0; (msglist[i] > 0); ++i) {
333                                 if ((i % 10) == 0)
334                                         syslog(LOG_DEBUG, "PROPFIND enumerated %d messages", i);
335                                 e = NULL;       // EUID gets stored here
336                                 timestamp = 0;
337
338                                 char cbuf[1024];
339                                 ctdl_printf(c, "MSG0 %ld|3", msglist[i]);
340                                 ctdl_readline(c, cbuf, sizeof(cbuf));
341                                 if (cbuf[0] == '1')
342                                         while (ctdl_readline(c, cbuf, sizeof(cbuf)), strcmp(cbuf, "000")) {
343                                                 if ((enumerate_by_euid) && (!strncasecmp(cbuf, "exti=", 5))) {
344                                                         // e = strdup(&cbuf[5]);
345                                                         int elen = (2 * strlen(&cbuf[5]));
346                                                         e = malloc(elen);
347                                                         urlesc(e, elen, &cbuf[5]);
348                                                 }
349                                                 if (!strncasecmp(cbuf, "time=", 5)) {
350                                                         timestamp = atol(&cbuf[5]);
351                                                 }
352                                         }
353                                 if (e == NULL) {
354                                         e = malloc(20);
355                                         sprintf(e, "%ld", msglist[i]);
356                                 }
357                                 StrBufAppendPrintf(Buf, "<D:response>");
358
359                                 // Generate the 'href' tag for this message
360                                 StrBufAppendPrintf(Buf, "<D:href>");
361                                 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
362                                 StrBufAppendPrintf(Buf, "/ctdl/r/");
363                                 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
364                                 StrBufAppendPrintf(Buf, "/");
365                                 StrBufXMLEscAppend(Buf, NULL, e, strlen(e), 0);
366                                 StrBufAppendPrintf(Buf, "</D:href>");
367                                 StrBufAppendPrintf(Buf, "<D:propstat>");
368                                 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
369                                 StrBufAppendPrintf(Buf, "<D:prop>");
370
371                                 switch (c->room_default_view) {
372                                 case VIEW_CALENDAR:
373                                         StrBufAppendPrintf(Buf,
374                                                            "<D:getcontenttype>text/calendar; component=vevent</D:getcontenttype>");
375                                         break;
376                                 case VIEW_TASKS:
377                                         StrBufAppendPrintf(Buf,
378                                                            "<D:getcontenttype>text/calendar; component=vtodo</D:getcontenttype>");
379                                         break;
380                                 case VIEW_ADDRESSBOOK:
381                                         StrBufAppendPrintf(Buf, "<D:getcontenttype>text/x-vcard</D:getcontenttype>");
382                                         break;
383                                 }
384
385                                 if (timestamp > 0) {
386                                         char *datestring = http_datestring(timestamp);
387                                         if (datestring) {
388                                                 StrBufAppendPrintf(Buf, "<D:getlastmodified>");
389                                                 StrBufXMLEscAppend(Buf, NULL, datestring, strlen(datestring), 0);
390                                                 StrBufAppendPrintf(Buf, "</D:getlastmodified>");
391                                                 free(datestring);
392                                         }
393                                         if (enumerate_by_euid)  // FIXME ajc 2017oct30 should this be inside the timestamp conditional?
394                                         {
395                                                 StrBufAppendPrintf(Buf, "<D:getetag>\"%ld\"</D:getetag>", msglist[i]);
396                                         }
397                                 }
398                                 StrBufAppendPrintf(Buf, "</D:prop></D:propstat></D:response>\n");
399                                 free(e);
400                         }
401                         free(msglist);
402                 };
403         }
404         // END COLLECTION
405
406         StrBufAppendPrintf(Buf, "</D:multistatus>\n");
407
408         add_response_header(h, strdup("Content-type"), strdup("text/xml"));
409         h->response_code = 207;
410         h->response_string = strdup("Multi-Status");
411         h->response_body_length = StrLength(Buf);
412         h->response_body = SmashStrBuf(&Buf);
413 }
414
415 // some good examples here
416 // http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html
417
418
419 /*
420  * Called by the_room_itself() when the HTTP method is PROPFIND
421  */
422 void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
423 {
424         JsonValue *j = NewJsonObject(HKEY("gotoroom"));
425
426         JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), c->room, -1));
427         JsonObjectAppend(j, NewJsonNumber(HKEY("current_view"), c->room_current_view));
428         JsonObjectAppend(j, NewJsonNumber(HKEY("default_view"), c->room_default_view));
429         JsonObjectAppend(j, NewJsonNumber(HKEY("new_messages"), c->new_messages));
430         JsonObjectAppend(j, NewJsonNumber(HKEY("total_messages"), c->total_messages));
431         JsonObjectAppend(j, NewJsonNumber(HKEY("last_seen"), c->last_seen));
432
433         StrBuf *sj = NewStrBuf();
434         SerializeJson(sj, j, 1);        // '1' == free the source array
435
436         add_response_header(h, strdup("Content-type"), strdup("application/json"));
437         h->response_code = 200;
438         h->response_string = strdup("OK");
439         h->response_body_length = StrLength(sj);
440         h->response_body = SmashStrBuf(&sj);
441         return;
442 }
443
444
445 /*
446  * Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname
447  * or /ctdl/r/roomname/ but *not* specific objects within the room)
448  */
449 void the_room_itself(struct http_transaction *h, struct ctdlsession *c)
450 {
451         // OPTIONS method on the room itself usually is a DAV client assessing what's here.
452
453         if (!strcasecmp(h->method, "OPTIONS")) {
454                 options_the_room_itself(h, c);
455                 return;
456         }
457         // PROPFIND method on the room itself could be looking for a directory
458
459         if (!strcasecmp(h->method, "PROPFIND")) {
460                 propfind_the_room_itself(h, c);
461                 return;
462         }
463         // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
464
465         if (!strcasecmp(h->method, "REPORT")) {
466                 report_the_room_itself(h, c);
467                 return;
468         }
469         // GET method on the room itself is an API call, possibly from our JavaScript front end
470
471         if (!strcasecmp(h->method, "get")) {
472                 get_the_room_itself(h, c);
473                 return;
474         }
475         // we probably want a "go to this room" for interactive access
476         do_404(h);
477 }
478
479
480 /*
481  * Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list
482  */
483 void room_list(struct http_transaction *h, struct ctdlsession *c)
484 {
485         char buf[1024];
486         char roomname[1024];
487
488         ctdl_printf(c, "LKRA");
489         ctdl_readline(c, buf, sizeof(buf));
490         if (buf[0] != '1') {
491                 do_502(h);
492                 return;
493         }
494
495         JsonValue *j = NewJsonArray(HKEY("lkra"));
496         while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
497
498                 // name|QRflags|QRfloor|QRorder|QRflags2|ra|current_view|default_view|mtime
499                 JsonValue *jr = NewJsonObject(HKEY("room"));
500
501                 extract_token(roomname, buf, 0, '|', sizeof roomname);
502                 JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), roomname, -1));
503
504                 int ra = extract_int(buf, 5);
505                 JsonObjectAppend(jr, NewJsonBool(HKEY("known"), (ra && UA_KNOWN)));
506                 JsonObjectAppend(jr, NewJsonBool(HKEY("hasnewmsgs"), (ra && UA_HASNEWMSGS)));
507
508                 int floor = extract_int(buf, 2);
509                 JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), floor));
510
511                 int rorder = extract_int(buf, 3);
512                 JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), rorder));
513
514                 JsonArrayAppend(j, jr); // add the room to the array
515         }
516
517         StrBuf *sj = NewStrBuf();
518         SerializeJson(sj, j, 1);        // '1' == free the source array
519
520         add_response_header(h, strdup("Content-type"), strdup("application/json"));
521         h->response_code = 200;
522         h->response_string = strdup("OK");
523         h->response_body_length = StrLength(sj);
524         h->response_body = SmashStrBuf(&sj);
525 }
526
527
528 /*
529  * Dispatcher for paths starting with /ctdl/r/
530  */
531 void ctdl_r(struct http_transaction *h, struct ctdlsession *c)
532 {
533         char requested_roomname[128];
534         char buf[1024];
535
536         // All room-related functions require being "in" the room specified.  Are we in that room already?
537         extract_token(requested_roomname, h->uri, 3, '/', sizeof requested_roomname);
538         unescape_input(requested_roomname);
539
540         if (IsEmptyStr(requested_roomname))     //      /ctdl/r/
541         {
542                 room_list(h, c);
543                 return;
544         }
545         // If not, try to go there.
546         if (strcasecmp(requested_roomname, c->room)) {
547                 ctdl_printf(c, "GOTO %s", requested_roomname);
548                 ctdl_readline(c, buf, sizeof(buf));
549                 if (buf[0] == '2') {
550                         // buf[3] will indicate whether any instant messages are waiting
551                         extract_token(c->room, &buf[4], 0, '|', sizeof c->room);
552                         c->new_messages = extract_int(&buf[4], 1);
553                         c->total_messages = extract_int(&buf[4], 2);
554                         //      3       (int)info                       Info flag: set to nonzero if the user needs to read this room's info file
555                         //      4       (int)CCC->room.QRflags          Various flags associated with this room.
556                         //      5       (long)CCC->room.QRhighest       The highest message number present in this room
557                         c->last_seen = extract_long(&buf[4], 6);        // The highest message number the user has read in this room
558                         //      7       (int)rmailflag                  Boolean flag: 1 if this is a Mail> room, 0 otherwise.
559                         //      8       (int)raideflag                  Nonzero if user is either Aide or a Room Aide in this room
560                         //      9       (int)newmailcount               The number of new Mail messages the user has
561                         //      10      (int)CCC->room.QRfloor          The floor number this room resides on
562                         c->room_current_view = extract_int(&buf[4], 11);
563                         c->room_default_view = extract_int(&buf[4], 12);
564                         //      13      (int)is_trash                   Boolean flag: 1 if this is the user's Trash folder, 0 otherwise.
565                         //      14      (int)CCC->room.QRflags2         More flags associated with this room
566                         //      15      (long)CCC->room.QRmtime         Timestamp of the last write activity in this room
567                 } else {
568                         do_404(h);
569                         return;
570                 }
571         }
572         // At this point our Citadel client session is "in" the specified room.
573
574         if (num_tokens(h->uri, '/') == 4)       //      /ctdl/r/roomname
575         {
576                 the_room_itself(h, c);
577                 return;
578         }
579
580         extract_token(buf, h->uri, 4, '/', sizeof buf);
581         if (num_tokens(h->uri, '/') == 5) {
582                 if (IsEmptyStr(buf)) {
583                         the_room_itself(h, c);  //      /ctdl/r/roomname/       ( same as /ctdl/r/roomname )
584                 } else {
585                         object_in_room(h, c);   //      /ctdl/r/roomname/object
586                 }
587                 return;
588         }
589         if (num_tokens(h->uri, '/') == 6) {
590                 object_in_room(h, c);   //      /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
591                 return;
592         }
593         // If we get to this point, the client specified a valid room but requested an action we don't know how to perform.
594         do_404(h);
595 }