struct terrace_linedata_s { char type; unsigned int level; }; typedef struct terrace_linedata_s terrace_linedata_t; void terrace_parse_line(char* line, terrace_linedata_t *lineData) { char type = 0; unsigned int level = 0; if (line[0] == '\n') { if (lineData->type == 1) level++; if (lineData->type == 0) level = lineData->level; } else { type = 1; while(line[level] == ' ' && level <= lineData->level + 1) ++level; } lineData->type = type; lineData->level = level; }