1 /* Written by Kris Maglione <fbsdaemon at gmail dot com> */
10 #include "mixp_local.h"
13 ixp_eprint(const char *fmt
, ...) {
18 fprintf(stderr
, "libixp: fatal: ");
21 vfprintf(stderr
, fmt
, ap
);
24 if(fmt
[strlen(fmt
)-1] == ':')
25 fprintf(stderr
, " %s\n", strerror(err
));
27 fprintf(stderr
, "\n");
34 ixp_mfatal(char *name
, unsigned int size
) {
36 couldnot
[] = "libixp: fatal: Could not ",
44 sizestr
[--i
] = '0' + (size
%10);
48 write(1, couldnot
, sizeof(couldnot
)-1);
49 write(1, name
, strlen(name
));
50 write(1, paren
, sizeof(paren
)-1);
51 write(1, sizestr
+i
, sizeof(sizestr
)-i
);
52 write(1, bytes
, sizeof(bytes
)-1);
58 ixp_emalloc(unsigned int size
) {
59 void *ret
= malloc(size
);
61 ixp_mfatal("malloc", size
);
66 ixp_erealloc(void *ptr
, unsigned int size
) {
67 void *ret
= realloc(ptr
, size
);
69 ixp_mfatal("realloc", size
);
73 unsigned int ixp_tokenize(char *res
[], unsigned int reslen
, char *str
, char delim
) {
79 while(i
< reslen
&& *s
) {
84 while(*s
&& *s
!= delim
)