summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/parser.c b/parser.c
index 6ad0892..2f8a52c 100644
--- a/parser.c
+++ b/parser.c
@@ -3163,6 +3163,7 @@ static int Go_routeclose_78(gchar** response, int channel, char *parameter,char
} else {
Set_Route(channel,ROUTE_PRIMARY,temp1);
Set_Route(channel,ROUTE_SECONDARY,temp2);
+ return OK;
}
break;
@@ -3196,11 +3197,7 @@ static int Parse_chan_list(int channel,char *parameter,int *primary_selected, in
int *value_pointer;
#define PARSE_MAX_STRING 20
- char temp[PARSE_MAX_STRING+1]; // FIXME
- if (*response) {
- *response[0]=0;
- }
if ( !(parameter[0]=='(' && parameter[1]=='@')) {
return SyntaxError;
@@ -3214,53 +3211,72 @@ static int Parse_chan_list(int channel,char *parameter,int *primary_selected, in
return Route_Range_Error;
}
+
pointer=1;
do {
+ int error_num = OK;
+
pointer++;
has_module_name = FALSE;
/* get module name, if any */
+
+ GString *name = g_string_new ("");
+
for (i=0; isalpha(parameter[pointer]) && (i<PARSE_MAX_STRING); i++) {
- temp[i]=parameter[pointer];
+ name = g_string_append_c (name, parameter[pointer]);
pointer++;
}
- temp[i]=0;
value_pointer = primary_selected;
if (i>0) {
has_module_name = TRUE;
- if (!strcmp (temp, "anod")) {
+ if (!strcmp (name->str, "anod")) {
value_pointer = primary_selected;
- } else if (!strcmp (temp, "cath")) {
+ } else if (!strcmp (name->str, "cath")) {
if (globals.Flash.routing_required[channel]<2) {
- return IllegalParameter;
+ error_num = IllegalParameter;
}
value_pointer = secondary_selected;
} else {
- return IllegalParameter;
+ error_num = IllegalParameter;
}
- if (parameter[pointer] == '(' ) {
+ if (!error_num && (parameter[pointer] == '(' )) {
pointer++;
} else {
- return SyntaxError;
+ error_num =SyntaxError;
}
+
}
+ g_string_free (name, TRUE);
+
+ if (error_num) {
+ return error_num;
+ }
+
+ GString *digits = g_string_new ("");
+
/* get digits */
for (i=0; isdigit(parameter[pointer]) && (i<PARSE_MAX_STRING); i++) {
- temp[i]=parameter[pointer];
+ digits = g_string_append_c (digits, parameter[pointer]);
pointer++;
}
- temp[i]=0;
if (i==0) {
- return SyntaxError;
+ error_num = SyntaxError;
+ }
+
+ n = atoi(digits->str);
+ g_string_free (digits, TRUE);
+
+ if (error_num) {
+ return error_num;
}
- n = atoi(temp);
if ((n < 1) || (n > globals.Flash.routing_max_pins[channel])) {
return OutOfRange;
}
@@ -3274,11 +3290,11 @@ static int Parse_chan_list(int channel,char *parameter,int *primary_selected, in
}
/* query or command? */
- if (*response) {
+ if (response) {
if (*value_pointer == n) {
- strcat(*response,"1 ");
+ *response = g_strdup ("1 ");
} else {
- strcat(*response,"0 ");
+ *response = g_strdup ("0 ");
}
} else {
if (value_pointer) {