| 664 | } |
| 665 | |
| 666 | int xsnprintf(char *dst, size_t max, const char *fmt, ...) |
| 667 | { |
| 668 | va_list ap; |
| 669 | int len; |
| 670 | |
| 671 | va_start(ap, fmt); |
| 672 | len = vsnprintf(dst, max, fmt, ap); |
| 673 | va_end(ap); |
| 674 | |
| 675 | if (len < 0) |
| 676 | die(_("unable to format message: %s"), fmt); |
| 677 | if (len >= max) |
| 678 | BUG("attempt to snprintf into too-small buffer"); |
| 679 | return len; |
| 680 | } |
| 681 | |
| 682 | void write_file_buf(const char *path, const char *buf, size_t len) |
| 683 | { |