4 * Copyright (c) 1996-2018 by the citadel.org team
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.
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.
19 * Client requested an object related to a user.
21 void object_in_user(struct http_transaction *h, struct ctdlsession *c)
25 char unescaped_euid[1024];
27 extract_token(buf, h->uri, 4, '/', sizeof buf);
29 if (!strcasecmp(buf, "userpic")) { // FIXME do this
34 do_404(h); // unknown object
40 * Handle REST/DAV requests for the user itself (such as /ctdl/u/username
41 * or /ctdl/i/username/ but *not* specific properties of the user)
43 void the_user_itself(struct http_transaction *h, struct ctdlsession *c)
50 * Dispatcher for "/ctdl/u" and "/ctdl/u/" for the user list
52 void user_list(struct http_transaction *h, struct ctdlsession *c)
59 * Dispatcher for paths starting with /ctdl/u/
61 void ctdl_u(struct http_transaction *h, struct ctdlsession *c)
63 char requested_username[128];
66 // All user-related functions require accessing the user in question.
67 extract_token(requested_username, h->uri, 3, '/', sizeof requested_username);
68 unescape_input(requested_username);
70 if (IsEmptyStr(requested_username)) { // /ctdl/u/
75 // Try to access the user...
76 if (strcasecmp(requested_username, c->room)) {
83 // At this point we have accessed the requested user account.
84 if (num_tokens(h->uri, '/') == 4) { // /ctdl/u/username
85 the_user_itself(h, c);
89 extract_token(buf, h->uri, 4, '/', sizeof buf);
90 if (num_tokens(h->uri, '/') == 5) {
91 if (IsEmptyStr(buf)) {
92 the_user_itself(h, c); // /ctdl/u/username/ ( same as /ctdl/u/username )
94 object_in_user(h, c); // /ctdl/u/username/object
99 if (num_tokens(h->uri, '/') == 6) {
100 object_in_user(h, c); // /ctdl/u/username/object/ or possibly /ctdl/u/username/object/component
104 // If we get to this point, the client specified a valid user but requested an action we don't know how to perform.