diff options
-rw-r--r-- | parser.c | 10 | ||||
-rw-r--r-- | response.c | 4 |
2 files changed, 9 insertions, 5 deletions
@@ -527,7 +527,7 @@ static int Parser_get_unit(char *parameter,char *units) return units_present;
}
-void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gchar *), gpointer user_data)
+void Parser_main (char *raw_in, int interactive_terminal, 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 */
@@ -556,7 +556,10 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc int channel;
int with_id_code;
- strcpy(in+strlen(in)," "); /* add white space to the end of the input string */
+ g_strstrip (raw_in);
+
+ // add white space to the end of the input string - FIXME?
+ gchar *in = g_strdup_printf ("%s ", raw_in);
in_pos = 0; /* start at the beginning of the input string */
semicolon_found = 0;
@@ -768,8 +771,11 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc if (interactive_terminal) {
(*cbfunc)(user_data, "");
}
+
+ g_free (in);
}
+
static int Parser_channel (int *channel,int with_id_code,int routine_num)
{
/* return if no channel suffixes appeared */
@@ -131,15 +131,13 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) GPollableOutputStream* stream = (GPollableOutputStream*)data->outStream; gchar* str = data->data; + // I2C/LCD test functions - start - FIXME g_strstrip(str); - - // I2C/LCD test functions - start guchar status = I2C_Read (PCF8574A + Upper_Encoder_Port); gchar *lcd_str = g_strdup_printf ("%s %x",str,status); LCD_display_error_message(lcd_str); // I2C/LCD test functions - stop - // FIXME - Parser_main may generate multiple responses Parser_main(str, 1, data->cb, stream); g_static_mutex_unlock (&mutex); |