2 // Copyright (c) 1996-2021 by the citadel.org team
4 // This program is open source software. It runs great on the
5 // Linux operating system (and probably elsewhere). You can use,
6 // copy, and run it under the terms of the GNU General Public
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.
17 // /ctdl/c/info returns a JSON representation of the output of an INFO command.
18 void serv_info(struct http_transaction *h, struct ctdlsession *c) {
21 ctdl_printf(c, "INFO");
22 ctdl_readline(c, buf, sizeof(buf));
28 JsonValue *j = NewJsonObject(HKEY("serv_info"));
30 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000"))
33 JsonObjectAppend(j, NewJsonNumber(HKEY("serv_pid"), atol(buf)));
36 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_nodename"), buf, -1));
39 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_humannode"), buf, -1));
42 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_fqdn"), buf, -1));
45 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_software"), buf, -1));
48 JsonObjectAppend(j, NewJsonNumber(HKEY("serv_rev_level"), atol(buf)));
51 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_bbs_city"), buf, -1));
54 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_sysadm"), buf, -1));
57 JsonObjectAppend(j, NewJsonBool(HKEY("serv_supports_ldap"), atoi(buf)));
60 JsonObjectAppend(j, NewJsonBool(HKEY("serv_newuser_disabled"), atoi(buf)));
63 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_default_cal_zone"), buf, -1));
66 JsonObjectAppend(j, NewJsonBool(HKEY("serv_supports_sieve"), atoi(buf)));
69 JsonObjectAppend(j, NewJsonBool(HKEY("serv_fulltext_enabled"), atoi(buf)));
72 JsonObjectAppend(j, NewJsonPlainString(HKEY("serv_svn_revision"), buf, -1));
75 JsonObjectAppend(j, NewJsonBool(HKEY("serv_supports_openid"), atoi(buf)));
78 JsonObjectAppend(j, NewJsonBool(HKEY("serv_supports_guest"), atoi(buf)));
82 StrBuf *sj = NewStrBuf();
83 SerializeJson(sj, j, 1); // '1' == free the source array
85 add_response_header(h, strdup("Content-type"), strdup("application/json"));
86 h->response_code = 200;
87 h->response_string = strdup("OK");
88 h->response_body_length = StrLength(sj);
89 h->response_body = SmashStrBuf(&sj);
93 // Dispatcher for paths starting with /ctdl/c/
94 void ctdl_c(struct http_transaction *h, struct ctdlsession *c) {
95 if (!strcasecmp(h->uri, "/ctdl/c/info")) {