Created
November 21, 2013 09:05
-
-
Save yuanshanxiaoni/7578225 to your computer and use it in GitHub Desktop.
c print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| */ | |
| static void pr_do(FILE *stream, | |
| const char *label, | |
| const char *fmt, | |
| va_list ap); | |
| void pr_info(const char *fmt, ...) { | |
| va_list ap; | |
| va_start(ap, fmt); | |
| pr_do(stdout, "info", fmt, ap); | |
| va_end(ap); | |
| } | |
| void pr_warn(const char *fmt, ...) { | |
| va_list ap; | |
| va_start(ap, fmt); | |
| pr_do(stderr, "warn", fmt, ap); | |
| va_end(ap); | |
| } | |
| void pr_err(const char *fmt, ...) { | |
| va_list ap; | |
| va_start(ap, fmt); | |
| pr_do(stderr, "error", fmt, ap); | |
| va_end(ap); | |
| } | |
| static void pr_do(FILE *stream, | |
| const char *label, | |
| const char *fmt, | |
| va_list ap) { | |
| char fmtbuf[1024]; | |
| vsnprintf(fmtbuf, sizeof(fmtbuf), fmt, ap); | |
| fprintf(stream, "%s:%s: %s\n", _getprogname(), label, fmtbuf); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment