123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include <sys/stat.h>
- #include <ctype.h>
- #include <errno.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #define vwarnx(fmt, args) ({ fprintf(stderr, "unifdef: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); })
- #define warnx(fmt, args...) fprintf(stderr, "unifdef: " fmt "\n", ## args)
- #define warn(fmt, args...) warnx(fmt ": %s", ## args, strerror(errno))
- #define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); })
- #define err(exit_code, fmt, args...) errx(exit_code, fmt ": %s", ## args, strerror(errno))
- #define fbinmode(fp) (fp)
- #define replace(old,new) rename(old,new)
- static FILE *
- mktempmode(char *tmp, int mode)
- {
- int fd = mkstemp(tmp);
- if (fd < 0) return (NULL);
- fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO));
- return (fdopen(fd, "wb"));
- }
|