summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-08-12 15:14:50 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-08-14 12:55:18 +0200
commit91c3a285ba937ef2de6a87320db5288bf3f8983b (patch)
treed287c14fc22a908a91c1fc8364002e47efff7975 /src
parent4ae9903dc380e2487a766d2198c4d64e9270323f (diff)
#980 Add 'ip' field in GET /scopes request
The 'ip' field is added to the json for scopes that have an IP (i.e. computers).
Diffstat (limited to 'src')
-rw-r--r--src/rest.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rest.c b/src/rest.c
index fd686d9..9be1bce 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -2192,7 +2192,7 @@ static int og_cmd_task_post(json_t *element, struct og_msg_params *params)
static int og_dbi_scope_get_computer(struct og_dbi *dbi, json_t *array,
uint32_t room_id)
{
- char computer_name[OG_DB_COMPUTER_NAME_MAXLEN + 1] = {};
+ const char *computer_name, *computer_ip;
uint32_t computer_id;
const char *msglog;
dbi_result result;
@@ -2211,9 +2211,8 @@ static int og_dbi_scope_get_computer(struct og_dbi *dbi, json_t *array,
while (dbi_result_next_row(result)) {
computer_id = dbi_result_get_uint(result, "idordenador");
- strncpy(computer_name,
- dbi_result_get_string(result, "nombreordenador"),
- OG_DB_CENTER_NAME_MAXLEN);
+ computer_name = dbi_result_get_string(result, "nombreordenador");
+ computer_ip = dbi_result_get_string(result, "ip");
computer = json_object();
if (!computer) {
@@ -2225,6 +2224,7 @@ static int og_dbi_scope_get_computer(struct og_dbi *dbi, json_t *array,
json_object_set_new(computer, "type", json_string("computer"));
json_object_set_new(computer, "id", json_integer(computer_id));
json_object_set_new(computer, "scope", json_array());
+ json_object_set_new(computer, "ip", json_string(computer_ip));
json_array_append(array, computer);
json_decref(computer);
}