ind.h (1518B)
1 /* 2 * Copy me if you can. 3 * by 20h 4 */ 5 6 #ifndef __IND_H__ 7 #define __IND_H__ 8 9 #define nelem(x) (sizeof(x) / sizeof((x)[0])) 10 11 #include <stdio.h> 12 #include <stdarg.h> 13 #include <time.h> 14 15 #define MAXLINESIZE 1048576 16 17 void die(char *fmt, ...); 18 void edie(char *fmt, ...); 19 void *reallocz(void *p, int l, int z); 20 void *mallocz(int l, int z); 21 void *memdup(void *p, int l); 22 void *memdupz(void *p, int l); 23 void *memdups(void *p); 24 void *memdupcat(void *p, int lp, void *c, int lc); 25 char *vsmprintf(char *fmt, va_list fmtargs, int size); 26 char *smprintf(char *fmt, ...); 27 28 void setnonblocking(int fd); 29 void setblocking(int fd); 30 31 int runcmd(char *cmd, int *infd, int *outfd, int *errfd, int keepold); 32 char *expandhome(char *path); 33 34 int writeall(FILE *fd, void *data, int len); 35 int writeallfd(int fd, void *data, int len); 36 int writefile(char *file, void *data, int len, char *mode); 37 int getfilesize(char *file); 38 char *readtoeof(FILE *fd, int *len); 39 char *readtoeoffd(int fd, int *len); 40 char *readfile(char *file, int *len); 41 char *readstdin(int *len); 42 43 char *sgets(char *s, int size, char **p); 44 char *sgetuntil(char *str, char **p, char *max, int *len); 45 char *strcsh(char *p, char *chars); 46 char *strncsh(char *p, char *chars); 47 char *strrlnspn(char *p, char *chars, int limit); 48 int strisascii(char *str); 49 void strnormalizespace(char *str); 50 char *findlimitws(char *str, int limit); 51 52 char *mktmpfile(char *prefix, char *suffix, int *fd); 53 54 int intcmp(const void *p1, const void *p2); 55 56 char *smftime(char *fmt, const struct tm *tm); 57 58 #endif 59