aboutsummaryrefslogtreecommitdiff
path: root/src/sensordashboard
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-07-27 01:23:58 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-07-27 01:23:58 +0000
commit0ea6bab62cd1d29e32c5d442d865e1b6bf82bef1 (patch)
treebde73567c1341bdff909f64de851dd7178e58ca3 /src/sensordashboard
parent29f73bb496a579a5a7600b3e3b2ab88b859bee65 (diff)
downloadgnunet-0ea6bab62cd1d29e32c5d442d865e1b6bf82bef1.tar.gz
gnunet-0ea6bab62cd1d29e32c5d442d865e1b6bf82bef1.zip
sensor: completed update functionality
Diffstat (limited to 'src/sensordashboard')
-rw-r--r--src/sensordashboard/gnunet-service-sensordashboard.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/sensordashboard/gnunet-service-sensordashboard.c b/src/sensordashboard/gnunet-service-sensordashboard.c
index a1f4318b8..0046ba488 100644
--- a/src/sensordashboard/gnunet-service-sensordashboard.c
+++ b/src/sensordashboard/gnunet-service-sensordashboard.c
@@ -597,6 +597,7 @@ create_full_sensor_msg (char *sensorname)
597 char *sensor_dir; 597 char *sensor_dir;
598 char *sensor_path; 598 char *sensor_path;
599 char *sensorscript_path; 599 char *sensorscript_path;
600 uint64_t sensorname_size;
600 uint64_t sensorfile_size; 601 uint64_t sensorfile_size;
601 uint64_t sensorscriptname_size; 602 uint64_t sensorscriptname_size;
602 uint64_t sensorscript_size; 603 uint64_t sensorscript_size;
@@ -619,6 +620,7 @@ create_full_sensor_msg (char *sensorname)
619 GNUNET_free (sensor_path); 620 GNUNET_free (sensor_path);
620 return NULL; 621 return NULL;
621 } 622 }
623 sensorname_size = strlen (sensorname) + 1;
622 sensorscript_size = 0; 624 sensorscript_size = 0;
623 sensorscriptname_size = 0; 625 sensorscriptname_size = 0;
624 /* Test if there is an associated script */ 626 /* Test if there is an associated script */
@@ -633,18 +635,26 @@ create_full_sensor_msg (char *sensorname)
633 &sensorscript_size, 635 &sensorscript_size,
634 GNUNET_NO, 636 GNUNET_NO,
635 GNUNET_YES)) 637 GNUNET_YES))
638 {
636 sensorscriptname_size = strlen (sensor->ext_process) + 1; 639 sensorscriptname_size = strlen (sensor->ext_process) + 1;
640 }
637 } 641 }
638 /* Construct the msg */ 642 /* Construct the msg */
639 total_size = sizeof (struct GNUNET_SENSOR_SensorFullMessage) + 643 total_size = sizeof (struct GNUNET_SENSOR_SensorFullMessage) +
640 sensorfile_size + sensorscriptname_size + sensorscript_size; 644 sensorname_size +
645 sensorfile_size +
646 sensorscriptname_size +
647 sensorscript_size;
641 msg = GNUNET_malloc (total_size); 648 msg = GNUNET_malloc (total_size);
642 msg->header.size = htons (total_size); 649 msg->header.size = htons (total_size);
643 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SENSOR_FULL); 650 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SENSOR_FULL);
644 msg->cfg_size = htons (sensorfile_size); 651 msg->sensorname_size = htons (sensorname_size);
652 msg->sensorfile_size = htons (sensorfile_size);
645 msg->scriptname_size = htons (sensorscriptname_size); 653 msg->scriptname_size = htons (sensorscriptname_size);
646 msg->script_size = htons (sensorscript_size); 654 msg->scriptfile_size = htons (sensorscript_size);
647 dummy = &msg[1]; 655 dummy = &msg[1];
656 memcpy (dummy, sensorname, sensorname_size);
657 dummy += sensorname_size;
648 GNUNET_DISK_fn_read (sensor_path, dummy, sensorfile_size); 658 GNUNET_DISK_fn_read (sensor_path, dummy, sensorfile_size);
649 dummy += sensorfile_size; 659 dummy += sensorfile_size;
650 if (sensorscriptname_size > 0) 660 if (sensorscriptname_size > 0)
@@ -652,10 +662,10 @@ create_full_sensor_msg (char *sensorname)
652 memcpy (dummy, sensor->ext_process, sensorscriptname_size); 662 memcpy (dummy, sensor->ext_process, sensorscriptname_size);
653 dummy += sensorscriptname_size; 663 dummy += sensorscriptname_size;
654 GNUNET_DISK_fn_read (sensorscript_path, dummy, sensorscript_size); 664 GNUNET_DISK_fn_read (sensorscript_path, dummy, sensorscript_size);
665 GNUNET_free (sensorscript_path);
655 } 666 }
656 GNUNET_free (sensor_dir); 667 GNUNET_free (sensor_dir);
657 GNUNET_free (sensor_path); 668 GNUNET_free (sensor_path);
658 GNUNET_free (sensorscript_path);
659 return msg; 669 return msg;
660} 670}
661 671