aboutsummaryrefslogtreecommitdiff
path: root/std.c
diff options
context:
space:
mode:
authorMatthias-Christian Ott <ott@enolink.de>2008-06-10 17:56:57 +0200
committerMatthias-Christian Ott <ott@enolink.de>2008-06-10 17:56:57 +0200
commit5f287254715dd91f2c508a2a6b9853f0ef4ed785 (patch)
treed9c93f4d89197a5339f6e979b0cbd67519f37f0b /std.c
parent05ebee60843f24201f3e7c5c76ff94b6b5e868b2 (diff)
downloadst-5f287254715dd91f2c508a2a6b9853f0ef4ed785.tar.gz
st-5f287254715dd91f2c508a2a6b9853f0ef4ed785.zip
source utility functions out to util.c
Diffstat (limited to 'std.c')
-rw-r--r--std.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/std.c b/std.c
index 3fd07a4..a7b2f4a 100644
--- a/std.c
+++ b/std.c
@@ -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
21void buffer(char c); 17void buffer(char c);
22void cmd(const char *cmdstr, ...); 18void cmd(const char *cmdstr, ...);
23void *emallocz(unsigned int size);
24void eprint(const char *errstr, ...);
25void eprintn(const char *errstr, ...);
26void getpty(void); 19void getpty(void);
27void movea(int x, int y); 20void movea(int x, int y);
28void mover(int x, int y); 21void 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
71void *
72emallocz(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
80void
81eprint(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
90void
91eprintn(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
101void 64void
102movea(int x, int y) { 65movea(int x, int y) {
103 x = MAX(x, cols); 66 x = MAX(x, cols);