2 * Copyright (c) 1996-2016 by the citadel.org team
4 * This program is open source software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
17 * /ctdl/c/info returns a JSON representation of the output of an INFO command.
19 void serv_info(struct http_transaction *h, struct ctdlsession *c)
23 ctdl_printf(c, "INFO");
24 ctdl_readline(c, buf, sizeof(buf));
30 JsonValue *j = NewJsonObject(HKEY("serv_info"));
32 while (ctdl_readline(c, buf, sizeof(buf)) , strcmp(buf, "000")) switch(i++) {
34 JsonObjectAppend(j, NewJsonNumber( HKEY("serv_pid"), atol(buf)));
37 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_nodename"), buf, -1));
40 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_humannode"), buf, -1));
43 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_fqdn"), buf, -1));
46 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_software"), buf, -1));
49 JsonObjectAppend(j, NewJsonNumber( HKEY("serv_rev_level"), atol(buf)));
52 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_bbs_city"), buf, -1));
55 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_sysadm"), buf, -1));
58 JsonObjectAppend(j, NewJsonBool( HKEY("serv_supports_ldap"), atoi(buf)));
61 JsonObjectAppend(j, NewJsonBool( HKEY("serv_newuser_disabled"), atoi(buf)));
64 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_default_cal_zone"), buf, -1));
67 JsonObjectAppend(j, NewJsonBool( HKEY("serv_supports_sieve"), atoi(buf)));
70 JsonObjectAppend(j, NewJsonBool( HKEY("serv_fulltext_enabled"), atoi(buf)));
73 JsonObjectAppend(j, NewJsonPlainString( HKEY("serv_svn_revision"), buf, -1));
76 JsonObjectAppend(j, NewJsonBool( HKEY("serv_supports_openid"), atoi(buf)));
79 JsonObjectAppend(j, NewJsonBool( HKEY("serv_supports_guest"), atoi(buf)));
83 StrBuf *sj = NewStrBuf();
84 SerializeJson(sj, j, 1); // '1' == free the source array
86 add_response_header(h, strdup("Content-type"), strdup("application/json"));
87 h->response_code = 200;
88 h->response_string = strdup("OK");
89 h->response_body_length = StrLength(sj);
90 h->response_body = SmashStrBuf(&sj);
95 * Dispatcher for paths starting with /ctdl/c/
97 void ctdl_c(struct http_transaction *h, struct ctdlsession *c)
99 if (!strcasecmp(h->uri, "/ctdl/c/info")) {