카타 7급 HTML Generator

C[ | ]

char *genHTML(const char *startTag, const char *innerHTML, const char *endTag) {
  return strcat(strcat(strcpy((char *)malloc(strlen(innerHTML) + strlen(startTag) + strlen(endTag) + 1), startTag), innerHTML), endTag);
}
char *HTMLGenA(const char *innerHTML)       { return genHTML("<a>",     innerHTML, "</a>");     }
char *HTMLGenB(const char *innerHTML)       { return genHTML("<b>",     innerHTML, "</b>");     }
char *HTMLGenBody(const char *innerHTML)    { return genHTML("<body>",  innerHTML, "</body>");  }
char *HTMLGenDiv(const char *innerHTML)     { return genHTML("<div>",   innerHTML, "</div>");   }
char *HTMLGenSpan(const char *innerHTML)    { return genHTML("<span>",  innerHTML, "</span>");  }
char *HTMLGenTitle(const char *innerHTML)   { return genHTML("<title>", innerHTML, "</title>"); }
char *HTMLGenComment(const char *innerHTML) { return genHTML("<!--",    innerHTML, "-->");      }
char *HTMLGenA(const char *innerHTML) {
  char *r;
  asprintf(&r, "<a>%s</a>", innerHTML);
  return r;
}
char *HTMLGenB(const char *innerHTML) {
  char *r;
  asprintf(&r, "<b>%s</b>", innerHTML);
  return r;
}
char *HTMLGenBody(const char *innerHTML) {
  char *r;
  asprintf(&r, "<body>%s</body>", innerHTML);
  return r;
}
char *HTMLGenDiv(const char *innerHTML) {
  char *r;
  asprintf(&r, "<div>%s</div>", innerHTML);
  return r;
}
char *HTMLGenSpan(const char *innerHTML) {
  char *r;
  asprintf(&r, "<span>%s</span>", innerHTML);
  return r;
}
char *HTMLGenTitle(const char *innerHTML) {
  char *r;
  asprintf(&r, "<title>%s</title>", innerHTML);
  return r;
}
char *HTMLGenComment(const char *innerHTML) {
  char *r;
  asprintf(&r, "<!--%s-->", innerHTML);
  return r;
}
char *HTMLConcat(const char *s1, const char *s2, const *s3) {
    char *res = malloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
    strcpy(res, s1);
    strcat(res, s2);
    strcat(res, s3);
    return res;
}
char *HTMLGenA(const char *innerHTML) { return HTMLConcat("<a>", innerHTML, "</a>"); }
char *HTMLGenB(const char *innerHTML) { return HTMLConcat("<b>", innerHTML, "</b>"); }
char *HTMLGenBody(const char *innerHTML) { return HTMLConcat("<body>", innerHTML, "</body>"); }
char *HTMLGenDiv(const char *innerHTML) { return HTMLConcat("<div>", innerHTML, "</div>"); }
char *HTMLGenSpan(const char *innerHTML) { return HTMLConcat("<span>", innerHTML, "</span>"); }
char *HTMLGenTitle(const char *innerHTML) { return HTMLConcat("<title>", innerHTML, "</title>"); }
char *HTMLGenComment(const char *innerHTML) { return HTMLConcat("<!--", innerHTML, "-->"); }
char *HTMLConcat(const char *s1, const char *s2, const *s3) {
    char *res = malloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
    strcpy(res, s1);
    strcat(res, s2);
    strcat(res, s3);
    return res;
}
char *HTMLGenA(const char *innerHTML) { return HTMLConcat("<a>", innerHTML, "</a>"); }
char *HTMLGenB(const char *innerHTML) { return HTMLConcat("<b>", innerHTML, "</b>"); }
char *HTMLGenBody(const char *innerHTML) { return HTMLConcat("<body>", innerHTML, "</body>"); }
char *HTMLGenDiv(const char *innerHTML) { return HTMLConcat("<div>", innerHTML, "</div>"); }
char *HTMLGenSpan(const char *innerHTML) { return HTMLConcat("<span>", innerHTML, "</span>"); }
char *HTMLGenTitle(const char *innerHTML) { return HTMLConcat("<title>", innerHTML, "</title>"); }
char *HTMLGenComment(const char *innerHTML) { return HTMLConcat("<!--", innerHTML, "-->"); }
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}