3 // Copyright (c) 1996-2022 by the citadel.org team
5 // This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3.
10 // Dispatcher for "/ctdl/f" and "/ctdl/f/" for the floor list
11 void floor_list(struct http_transaction *h, struct ctdlsession *c) {
15 ctdl_printf(c, "LFLR");
16 ctdl_readline(c, buf, sizeof(buf));
22 JsonValue *j = NewJsonArray(HKEY("lflr"));
23 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
27 JsonValue *jr = NewJsonObject(HKEY("floor"));
29 extract_token(floorname, buf, 1, '|', sizeof floorname);
30 JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), floorname, -1));
32 JsonObjectAppend(jr, NewJsonNumber(HKEY("num"), extract_int(buf, 0)));
33 JsonObjectAppend(jr, NewJsonNumber(HKEY("refcount"), extract_int(buf, 2)));
35 JsonArrayAppend(j, jr); // add the room to the array
38 StrBuf *sj = NewStrBuf();
39 SerializeJson(sj, j, 1); // '1' == free the source array
41 add_response_header(h, strdup("Content-type"), strdup("application/json"));
42 h->response_code = 200;
43 h->response_string = strdup("OK");
44 h->response_body_length = StrLength(sj);
45 h->response_body = SmashStrBuf(&sj);
49 // Dispatcher for paths starting with /ctdl/f/
50 // (This is a stub ... we will need to add more functions when we can do more than just a floor list)
51 void ctdl_f(struct http_transaction *h, struct ctdlsession *c) {