diff options
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -26,7 +26,7 @@ static int Handle_Units(float *mult,char *units, char *base); static int Is_Min_Command(char *text);
static int Is_Max_Command(char *text);
static int Go_syst_err_11(gchar** response, int channel, char *parameter,char *units,int command_type);
-static int Go_syst_errcnt66(gchar* response, int channel, char *parameter,char *units,int command_type);
+static int Go_syst_errcnt66(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Parser_id_word(char *id_me, int *channel, int *with_id_code)
{
@@ -528,7 +528,7 @@ static int Parser_get_unit(char *parameter,char *units) return units_present;
}
-void Parser_main (char *in, gchar** response, int allow_unrequested_responses)
+void Parser_main (char *in, int allow_unrequested_responses, void(*cbfunc)(gpointer, gchar *), gpointer user_data)
{
int in_pos; /* this identifies the single character of in being processed */
int command_depth; /* how many command words have been parsed */
@@ -550,7 +550,6 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses) int compound_message; /* this indicates that at least one semicolon has been found, so */
/* the message is a compound one */
-// char response[max_output_length];
int is_query;
int command_type; /* combination of is_query, parameter_found, and units_found */
@@ -684,7 +683,8 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses) /* add end of tokens marker (0) */
int error_num=OK;
- response[0]=0;
+ gchar *response = NULL;
+ gchar *error_response = NULL;
if (parameter_found) {
units_found = Parser_get_unit(parameter,units);
@@ -715,18 +715,18 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses) switch (routine_num) {
case 0:
- *response = g_strdup_printf("routine_num: %d, channel: %d, parameter: %s, units: %s, command type: %d\n\r",routine_num,channel,parameter,units,command_type);
+ response = g_strdup_printf("routine_num: %d, channel: %d, parameter: %s, units: %s, command type: %d\n\r",routine_num,channel,parameter,units,command_type);
error_num=Unrecognized;
break;
case 11:
- error_num=Go_syst_err_11(response,channel,parameter,units,command_type);
+ error_num=Go_syst_err_11(&response,channel,parameter,units,command_type);
break;
case 32:
case 33:
- error_num=Go_freq_32_33(response,channel,parameter,units,command_type);
+ error_num=Go_freq_32_33(&response,channel,parameter,units,command_type);
break;
case 66:
- error_num=Go_syst_errcnt66(*response,channel,parameter,units,command_type);
+ error_num=Go_syst_errcnt66(&response,channel,parameter,units,command_type);
break;
case 9999:
@@ -735,24 +735,24 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses) default:
/* valid but not implemented yet */
- *response = g_strdup_printf("routine_num: %d, channel: %d, parameter: %s, units: %s, command type: %d\n\r",routine_num,channel,parameter,units,command_type);
+ response = g_strdup_printf("routine_num: %d, channel: %d, parameter: %s, units: %s, command type: %d\n\r",routine_num,channel,parameter,units,command_type);
break;
}
}
- // FIXME
if (error_num) {
- g_free (*response);
- *response = NULL;
- queue_error_from_parser(response, error_num);
+ queue_error_from_parser(&error_response, error_num);
if (allow_unrequested_responses) {
- ; // SEND ERROR RESPONSE TO CLIENT NOW!
+ (*cbfunc)(user_data, error_response);
}
} else {
- ; // SEND RESPONSE TO CLIENT NOW!
+ (*cbfunc)(user_data, response);
}
+ g_free (response);
+ g_free (error_response);
+
if (!is_query) {
Main_update_shift_registers(); /* update values in pulse generator circuit */
}
@@ -1024,7 +1024,7 @@ static int Go_syst_err_11(gchar** response, int channel, char *parameter,char *u }
}
-static int Go_syst_errcnt66(gchar* response, int channel, char *parameter,char *units,int command_type)
+static int Go_syst_errcnt66(gchar** response, int channel, char *parameter,char *units,int command_type)
{
switch (command_type) {
case query_simple:
|