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