iptype.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <assert.h>
  5. #include <faux/str.h>
  6. #include <klish/khelper.h>
  7. #include <klish/kptype.h>
  8. #include <klish/kaction.h>
  9. #define ISCHEME_TAB " "
  10. char *iptype_to_text(const iptype_t *iptype, int level)
  11. {
  12. char *str = NULL;
  13. char *tmp = NULL;
  14. tmp = faux_str_sprintf("%*cPTYPE = {\n", level, ' ');
  15. faux_str_cat(&str, tmp);
  16. faux_str_free(tmp);
  17. /*
  18. // PTYPE list
  19. if (iptype->ptypes) {
  20. iptype_t **p_iptype = NULL;
  21. tmp = faux_str_sprintf("\n%*sPTYPE_LIST\n\n", level + 1, ISCHEME_TAB);
  22. faux_str_cat(&str, tmp);
  23. faux_str_free(tmp);
  24. for (p_iptype = *iptype->ptypes; *p_iptype; p_iptype++) {
  25. iptype_t *iptype = *p_iptype;
  26. tmp = iptype_to_text(iptype, level + 2);
  27. faux_str_cat(&str, tmp);
  28. faux_str_free(tmp);
  29. }
  30. tmp = faux_str_sprintf("\n%*sEND_PTYPE_LIST,\n", level + 1, ISCHEME_TAB);
  31. faux_str_cat(&str, tmp);
  32. faux_str_free(tmp);
  33. }
  34. */
  35. tmp = faux_str_sprintf("%*c},\n\n", level, ' ');
  36. faux_str_cat(&str, tmp);
  37. faux_str_free(tmp);
  38. iptype = iptype;
  39. return str;
  40. }