iaction.c 892 B

1234567891011121314151617181920212223242526272829303132
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <assert.h>
  5. #include <faux/str.h>
  6. #include <faux/conv.h>
  7. #include <klish/iaction.h>
  8. char *iaction_to_text(const iaction_t *iaction, int level)
  9. {
  10. char *str = NULL;
  11. char *tmp = NULL;
  12. tmp = faux_str_sprintf("%*cACTION {\n", level, ' ');
  13. faux_str_cat(&str, tmp);
  14. faux_str_free(tmp);
  15. attr2ctext(&str, "sym", iaction->sym, level + 1);
  16. attr2ctext(&str, "lock", iaction->lock, level + 1);
  17. attr2ctext(&str, "interrupt", iaction->interrupt, level + 1);
  18. attr2ctext(&str, "interactive", iaction->interactive, level + 1);
  19. attr2ctext(&str, "exec_on", iaction->exec_on, level + 1);
  20. attr2ctext(&str, "update_retcode", iaction->update_retcode, level + 1);
  21. attr2ctext(&str, "script", iaction->script, level + 1);
  22. tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
  23. faux_str_cat(&str, tmp);
  24. faux_str_free(tmp);
  25. return str;
  26. }