diff options
| author | Matthias-Christian Ott <ott@enolink.de> | 2008-06-10 17:56:57 +0200 |
|---|---|---|
| committer | Matthias-Christian Ott <ott@enolink.de> | 2008-06-10 17:56:57 +0200 |
| commit | 5f287254715dd91f2c508a2a6b9853f0ef4ed785 (patch) | |
| tree | d9c93f4d89197a5339f6e979b0cbd67519f37f0b /std.c | |
| parent | add copyright comment (diff) | |
| download | st-5f287254715dd91f2c508a2a6b9853f0ef4ed785.tar.gz st-5f287254715dd91f2c508a2a6b9853f0ef4ed785.zip | |
source utility functions out to util.c
Diffstat (limited to '')
| -rw-r--r-- | std.c | 39 |
1 files changed, 1 insertions, 38 deletions
| @@ -1,12 +1,8 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | #include <sys/ioctl.h> | 2 | #include "util.h" |
| 3 | #include <sys/select.h> | ||
| 4 | #include <sys/stat.h> | ||
| 5 | #include <sys/types.h> | 3 | #include <sys/types.h> |
| 6 | #include <sys/wait.h> | 4 | #include <sys/wait.h> |
| 7 | #include <ctype.h> | 5 | #include <ctype.h> |
| 8 | #include <errno.h> | ||
| 9 | #include <fcntl.h> | ||
| 10 | #include <signal.h> | 6 | #include <signal.h> |
| 11 | #include <stdarg.h> | 7 | #include <stdarg.h> |
| 12 | #include <stdio.h> | 8 | #include <stdio.h> |
| @@ -20,9 +16,6 @@ | |||
| 20 | 16 | ||
| 21 | void buffer(char c); | 17 | void buffer(char c); |
| 22 | void cmd(const char *cmdstr, ...); | 18 | void cmd(const char *cmdstr, ...); |
| 23 | void *emallocz(unsigned int size); | ||
| 24 | void eprint(const char *errstr, ...); | ||
| 25 | void eprintn(const char *errstr, ...); | ||
| 26 | void getpty(void); | 19 | void getpty(void); |
| 27 | void movea(int x, int y); | 20 | void movea(int x, int y); |
| 28 | void mover(int x, int y); | 21 | void mover(int x, int y); |
| @@ -68,36 +61,6 @@ cmd(const char *cmdstr, ...) { | |||
| 68 | va_end(ap); | 61 | va_end(ap); |
| 69 | } | 62 | } |
| 70 | 63 | ||
| 71 | void * | ||
| 72 | emallocz(unsigned int size) { | ||
| 73 | void *res = calloc(1, size); | ||
| 74 | |||
| 75 | if(!res) | ||
| 76 | eprint("fatal: could not malloc() %u bytes\n", size); | ||
| 77 | return res; | ||
| 78 | } | ||
| 79 | |||
| 80 | void | ||
| 81 | eprint(const char *errstr, ...) { | ||
| 82 | va_list ap; | ||
| 83 | |||
| 84 | va_start(ap, errstr); | ||
| 85 | vfprintf(stderr, errstr, ap); | ||
| 86 | va_end(ap); | ||
| 87 | exit(EXIT_FAILURE); | ||
| 88 | } | ||
| 89 | |||
| 90 | void | ||
| 91 | eprintn(const char *errstr, ...) { | ||
| 92 | va_list ap; | ||
| 93 | |||
| 94 | va_start(ap, errstr); | ||
| 95 | vfprintf(stderr, errstr, ap); | ||
| 96 | va_end(ap); | ||
| 97 | fprintf(stderr, ": %s\n", strerror(errno)); | ||
| 98 | exit(EXIT_FAILURE); | ||
| 99 | } | ||
| 100 | |||
| 101 | void | 64 | void |
| 102 | movea(int x, int y) { | 65 | movea(int x, int y) { |
| 103 | x = MAX(x, cols); | 66 | x = MAX(x, cols); |
