summaryrefslogtreecommitdiff
path: root/app/bin/csensor.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/bin/csensor.c')
-rw-r--r--app/bin/csensor.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/app/bin/csensor.c b/app/bin/csensor.c
index 7ee842d..871b8d6 100644
--- a/app/bin/csensor.c
+++ b/app/bin/csensor.c
@@ -59,6 +59,7 @@ static const char rcsid[] = "@(#) : $Id$";
#include "track.h"
#include "trackx.h"
#include "utility.h"
+#include "messages.h"
EXPORT TRKTYP_T T_SENSOR = -1;
@@ -156,9 +157,9 @@ static struct {
typedef enum { NM, PS, SC } sensorDesc_e;
static descData_t sensorDesc[] = {
- /* NM */ { DESC_STRING, N_("Name"), &sensorProperties.name },
+ /* NM */ { DESC_STRING, N_("Name"), &sensorProperties.name, sizeof(sensorProperties.name) },
/* PS */ { DESC_POS, N_("Position"), &sensorProperties.pos },
- /* SC */ { DESC_STRING, N_("Script"), &sensorProperties.script },
+ /* SC */ { DESC_STRING, N_("Script"), &sensorProperties.script, sizeof(sensorProperties.script) },
{ DESC_NULL } };
static void UpdateSensorProperties ( track_p trk, int inx, descData_p
@@ -167,6 +168,7 @@ static void UpdateSensorProperties ( track_p trk, int inx, descData_p
sensorData_p xx = GetsensorData(trk);
const char *thename, *thescript;
char *newName, *newScript;
+ unsigned int max_str;
BOOL_T changed, nChanged, pChanged, sChanged;
switch (inx) {
@@ -181,13 +183,27 @@ static void UpdateSensorProperties ( track_p trk, int inx, descData_p
thename = wStringGetValue( (wString_p) sensorDesc[NM].control0 );
if (strcmp(thename,xx->name) != 0) {
nChanged = changed = TRUE;
- newName = MyStrdup(thename);
+ max_str = sensorDesc[NM].max_string;
+ if (max_str && strlen(thename)>max_str-1) {
+ newName = MyMalloc(max_str);
+ newName[max_str-1] = '\0';
+ strncat(newName,thename,max_str-1);
+ NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1);
+ } else newName = MyStrdup(thename);
}
+
thescript = wStringGetValue( (wString_p) sensorDesc[SC].control0 );
if (strcmp(thescript,xx->script) != 0) {
sChanged = changed = TRUE;
- newScript = MyStrdup(thescript);
+ max_str = sensorDesc[SC].max_string;
+ if (max_str && strlen(thename)>max_str-1) {
+ newScript = MyMalloc(max_str);
+ newScript[max_str-1] = '\0';
+ strncat(newScript,thescript,max_str-1);
+ NoticeMessage2(0, MSG_ENTERED_STRING_TRUNCATED, _("Ok"), NULL, max_str-1);
+ } else newScript = MyStrdup(thescript);
}
+
if (sensorProperties.pos.x != xx->orig.x ||
sensorProperties.pos.y != xx->orig.y) {
pChanged = changed = TRUE;
@@ -353,13 +369,13 @@ static char sensorEditScript[STR_LONG_SIZE];
static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 };
static paramData_t sensorEditPLs[] = {
#define I_SENSORNAME (0)
- /*0*/ { PD_STRING, sensorEditName, "name", PDO_NOPREF|PDO_STRINGLIMITLENGTH, (void*)200, N_("Name"), 0, (void *)sizeof(sensorEditName) },
+ /*0*/ { PD_STRING, sensorEditName, "name", PDO_NOPREF|PDO_STRINGLIMITLENGTH, (void*)200, N_("Name"), 0, 0, sizeof(sensorEditName)},
#define I_ORIGX (1)
/*1*/ { PD_FLOAT, &sensorEditOrig.x, "origx", PDO_DIM, &r_1000_1000, N_("Orgin X") },
#define I_ORIGY (2)
/*2*/ { PD_FLOAT, &sensorEditOrig.y, "origy", PDO_DIM, &r_1000_1000, N_("Origin Y") },
#define I_SENSORSCRIPT (3)
- /*3*/ { PD_STRING, sensorEditScript, "script", PDO_NOPREF|PDO_STRINGLIMITLENGTH, (void*)350, N_("Script"), 0, (void *)sizeof(sensorEditScript) },
+ /*3*/ { PD_STRING, sensorEditScript, "script", PDO_NOPREF|PDO_STRINGLIMITLENGTH, (void*)350, N_("Script"), 0, 0, sizeof(sensorEditScript)},
};
static paramGroup_t sensorEditPG = { "sensorEdit", 0, sensorEditPLs, sizeof sensorEditPLs/sizeof sensorEditPLs[0] };