summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/parser.c b/parser.c
index de3e9af..39f6fe2 100644
--- a/parser.c
+++ b/parser.c
@@ -53,13 +53,13 @@ static int Go_int_eprom_48(gchar** response, int channel, char *loc_string,char
static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
static int Go_char_eprom_70(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
static int Go_eprom_siz_86(gchar** response, int channel, int command_type);
-static int Go_sys_net_91(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
+static int Go_sys_net_91(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_ampl_26(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode);
static int Go_pw_36(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_duty_37(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_offset_29(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode);
-static int Go_idn_5(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
+static int Go_idn_5(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_period_35(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_delay_39(gchar** response, int channel, char *parameter,char *units,int command_type);
@@ -1172,6 +1172,10 @@ static int Go_Str_eprom_47(gchar** response, int channel, char *loc_string,char
/* diag:eprom:string - 47 */
int eprom_loc;
+ if (!String_is_it_pos_int(loc_string)) {
+ return SyntaxError;
+ }
+
eprom_loc = atoi(loc_string);
/* convert location string to a number */
@@ -1217,6 +1221,10 @@ static int Go_int_eprom_48(gchar** response, int channel, char *loc_string,char
int eprom_loc;
short the_number;
+ if (!String_is_it_pos_int(loc_string)) {
+ return SyntaxError;
+ }
+
eprom_loc = atoi(loc_string);
/* convert location string to a number */
@@ -1226,6 +1234,9 @@ static int Go_int_eprom_48(gchar** response, int channel, char *loc_string,char
switch (command_type) {
case command_param_units:
+ if (!String_is_it_pos_neg_int(store_string)) {
+ return SyntaxError;
+ }
the_number=(short) atoi(store_string);
*(short *)(&globals.Flash.flash_start + eprom_loc) = the_number;
writeUserBlock(&globals.Flash, eprom_loc, sizeof (the_number));
@@ -1251,6 +1262,10 @@ static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char
int eprom_loc;
float the_number;
+ if (!String_is_it_pos_int(loc_string)) {
+ return SyntaxError;
+ }
+
eprom_loc = atoi(loc_string);
/* convert location string to a number */
@@ -1261,6 +1276,9 @@ static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char
switch (command_type) {
case command_param_units:
+ if (!String_is_it_numeric(store_string)) {
+ return SyntaxError;
+ }
the_number=atof(store_string);
*(float *)(&globals.Flash.flash_start + eprom_loc)=the_number;
writeUserBlock(&globals.Flash, eprom_loc, sizeof(the_number));
@@ -1303,6 +1321,10 @@ static int Go_char_eprom_70(gchar** response, int channel, char *loc_string,char
int eprom_loc;
char the_number;
+ if (!String_is_it_pos_int(loc_string)) {
+ return SyntaxError;
+ }
+
eprom_loc = atoi(loc_string);
/* convert location string to a number */
@@ -1312,6 +1334,9 @@ static int Go_char_eprom_70(gchar** response, int channel, char *loc_string,char
switch (command_type) {
case command_param_units:
+ if (!String_is_it_pos_int(store_string)) {
+ return SyntaxError;
+ }
the_number=(char) atoi(store_string);
*(char *)(&globals.Flash.flash_start + eprom_loc)=the_number;
writeUserBlock(&globals.Flash, eprom_loc, sizeof(the_number));
@@ -1348,7 +1373,7 @@ static int Go_eprom_siz_86(gchar** response, int channel, int command_type)
}
-static int Go_sys_net_91(gchar **response, int channel, char *loc_string,char *store_string,int command_type)
+static int Go_sys_net_91(gchar **response, int channel, char *parameter,char *units,int command_type)
{
nicinfo info;
@@ -1556,7 +1581,7 @@ static int process_int_param (char *parameter, int *value, int item_count, int *
min_val = valid_nums[0];
max_val = valid_nums[item_count - 1];
- if (String_is_it_numeric(parameter)) {
+ if (String_is_it_pos_neg_int(parameter)) {
*value = atoi(parameter);
int i;
for (i = 0; (i < item_count) && (is_valid == 0); i++) {
@@ -1587,7 +1612,7 @@ static int process_int_range (char *parameter, int *value, int min_val, int max_
int status;
status = OK;
- if (String_is_it_numeric(parameter)) {
+ if (String_is_it_pos_neg_int(parameter)) {
*value = atoi(parameter);
if ((*value<min_val) || (*value>max_val)) {
status = OutOfRange;
@@ -1896,7 +1921,7 @@ static int Go_offset_29(gchar** response, int channel, char *parameter,char *uni
}
-static int Go_idn_5(gchar** response, int channel, char *loc_string,char *store_string,int command_type)
+static int Go_idn_5(gchar** response, int channel, char *parameter,char *units,int command_type)
{
/* *idn? - 5 */
@@ -3357,14 +3382,14 @@ static int Go_dly_shift_82(gchar** response, int channel, char *parameter,char *
switch (command_type) {
case command_param_units:
/* if param=point number, and units=measurement, then update calibration */
- if (String_is_it_numeric(parameter) && String_is_it_numeric(units)) {
+ if (String_is_it_pos_int(parameter) && String_is_it_numeric(units)) {
value=atoi(parameter);
if (value>num_of_dly_shift_points || value<1) {
return IllegalParameter;
}
cal_point=atof(units);
return Set_Dly_Shr_Cal(channel,value,cal_point);
- } else if (String_is_it_numeric(parameter) && !strcmp(units,"go")) {
+ } else if (String_is_it_pos_int(parameter) && !strcmp(units,"go")) {
value=atoi(parameter);
if (value>num_of_dly_shift_points || value<1) {
return IllegalParameter;
@@ -3470,14 +3495,14 @@ static int Go_amp_pnt_83(gchar** response, int channel, char *parameter,char *un
switch (command_type) {
case command_param_units:
/* if param=point number, and units=measurement, then update calibration */
- if (String_is_it_numeric(parameter) && String_is_it_numeric(units)) {
+ if (String_is_it_pos_int(parameter) && String_is_it_numeric(units)) {
value=atoi(parameter);
if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
return IllegalParameter;
}
cal_point=atof(units);
return Set_VI_Cal_Pnt(cal_type,channel,value,cal_point);
- } else if (String_is_it_numeric(parameter) && !strcmp(units,"go")) {
+ } else if (String_is_it_pos_int(parameter) && !strcmp(units,"go")) {
value=atoi(parameter);
if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
return IllegalParameter;
@@ -3485,7 +3510,7 @@ static int Go_amp_pnt_83(gchar** response, int channel, char *parameter,char *un
if (status=Set_Cal_Nom(channel,value,cal_type,NULL)) {
return status;
}
- } else if (String_is_it_numeric(parameter) && !strcmp(units,"delete")) {
+ } else if (String_is_it_pos_int(parameter) && !strcmp(units,"delete")) {
value=atoi(parameter);
if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
return IllegalParameter;