static float adjust_sensor(gchar * name, float value) { GSList *postfix; postfix = g_hash_table_lookup(sensor_compute, name); if (!postfix) return value; return math_postfix_eval(postfix, value); }
gfloat math_string_eval(gchar *string, gfloat at_value) { GSList *postfix; gfloat val; postfix = math_string_to_postfix(string); val = math_postfix_eval(postfix, at_value); math_postfix_free(postfix, TRUE); return val; }
int main(void) { GSList *postfix; gchar *expr = "0.9*(@+(5.2*0.923+3*(2.0)))"; postfix = math_string_to_postfix(expr); g_print("%s = %f (must be 18.71964)\n", expr, math_postfix_eval(postfix, 10)); math_postfix_free(postfix, TRUE); return 0; }