Skip to content

Instantly share code, notes, and snippets.

@msalvadores
Created March 2, 2011 18:25
Show Gist options
  • Save msalvadores/851417 to your computer and use it in GitHub Desktop.
Save msalvadores/851417 to your computer and use it in GitHub Desktop.
code to get all var names hanging from a rasqal_expression
/*
code to get all var names hanging from a rasqal_expression
author: Manuel Salvadores (msalvadores@gmail.com)
*/
static void get_var_names(rasqal_expression *e,GList **list_vars) {
GList *l = *list_vars;
if (!e) return;
if (e->literal != NULL) {
rasqal_literal *lit = e->literal;
if (lit->type == RASQAL_LITERAL_VARIABLE) {
l = g_list_append(l,(gpointer)e->literal->value.variable->name);
}
} else {
if (e->arg1 != NULL)
get_var_names(e->arg1,&l);
if (e->arg2 != NULL)
get_var_names(e->arg2,&l);
if (e->arg3 != NULL)
get_var_names(e->arg3,&l);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment