Refactor functions for easy reuse

This commit is contained in:
Ingo Bürk
2015-03-04 09:22:25 +01:00
parent bcc1314a2d
commit eb73059c61
5 changed files with 150 additions and 119 deletions

View File

@ -24,3 +24,25 @@ Con *output_get_content(Con *output) {
return NULL;
}
/*
* Returns an 'output' corresponding to one of left/right/down/up or a specific
* output name.
*
*/
Output *get_output_from_string(Output *current_output, const char *output_str) {
Output *output;
if (strcasecmp(output_str, "left") == 0)
output = get_output_next_wrap(D_LEFT, current_output);
else if (strcasecmp(output_str, "right") == 0)
output = get_output_next_wrap(D_RIGHT, current_output);
else if (strcasecmp(output_str, "up") == 0)
output = get_output_next_wrap(D_UP, current_output);
else if (strcasecmp(output_str, "down") == 0)
output = get_output_next_wrap(D_DOWN, current_output);
else
output = get_output_by_name(output_str);
return output;
}