blob: e2dc13ec675a7a057d6a6a8e0365dbdd262e08e1 [file] [log] [blame]
landley4f344e32006-10-05 16:18:03 -04001/* vi: set ts=4 :*/
landley09ea7ac2006-10-30 01:38:00 -05002/* lib.h - header file for lib directory
3 *
4 * Copyright 2006 Rob Landley <rob@landley.net>
5 */
landley4f344e32006-10-05 16:18:03 -04006
Rob Landley1521a9e2006-11-25 16:06:55 -05007// libc generally has this, but the headers are screwed up
8ssize_t getline(char **lineptr, size_t *n, FILE *stream);
9
Rob Landley0a04b3e2006-11-03 00:05:52 -050010// llist.c
11void llist_free(void *list, void (*freeit)(void *data));
12void *llist_pop(void *list); // actually void **list, but the compiler's dumb
13
14struct string_list {
15 struct string_list *next;
16 char str[0];
17};
18
Rob Landley8324b892006-11-19 02:49:22 -050019struct arg_list {
20 struct arg_list *next;
21 char *arg;
22};
23
24// args.c
25void get_optflags(void);
26
landleycd9dfc32006-10-18 18:38:16 -040027// functions.c
landley09ea7ac2006-10-30 01:38:00 -050028void verror_msg(char *msg, int err, va_list va);
29void error_msg(char *msg, ...);
30void perror_msg(char *msg, ...);
landley4f344e32006-10-05 16:18:03 -040031void error_exit(char *msg, ...);
landley09ea7ac2006-10-30 01:38:00 -050032void perror_exit(char *msg, ...);
Rob Landley055cfcb2007-01-14 20:20:06 -050033void usage_exit(void);
landley4f344e32006-10-05 16:18:03 -040034void strlcpy(char *dest, char *src, size_t size);
35void *xmalloc(size_t size);
landleycd9dfc32006-10-18 18:38:16 -040036void *xzalloc(size_t size);
37void xrealloc(void **ptr, size_t size);
landley4f344e32006-10-05 16:18:03 -040038void *xstrndup(char *s, size_t n);
Rob Landleyfa98d012006-11-02 02:57:27 -050039void *xstrdup(char *s);
landley00f87f12006-10-25 18:38:37 -040040char *xmsprintf(char *format, ...);
Rob Landley24d1d452007-01-20 18:04:20 -050041void xprintf(char *format, ...);
42void xputc(char c);
43void xflush(void);
landley09ea7ac2006-10-30 01:38:00 -050044void xexec(char **argv);
Rob Landleyd3e9d642007-01-08 03:25:47 -050045void xaccess(char *path, int flags);
Rob Landley1322beb2007-01-07 22:51:12 -050046int xcreate(char *path, int flags, int mode);
47int xopen(char *path, int flags);
landley4f344e32006-10-05 16:18:03 -040048FILE *xfopen(char *path, char *mode);
Rob Landley90163772007-01-18 21:54:08 -050049ssize_t readall(int fd, void *buf, size_t len);
50ssize_t writeall(int fd, void *buf, size_t len);
51size_t xread(int fd, void *buf, size_t len);
52void xreadall(int fd, void *buf, size_t len);
53void xwrite(int fd, void *buf, size_t len);
landley00f87f12006-10-25 18:38:37 -040054char *xgetcwd(void);
Rob Landleyfa98d012006-11-02 02:57:27 -050055char *xabspath(char *path);
Rob Landley0a04b3e2006-11-03 00:05:52 -050056struct string_list *find_in_path(char *path, char *filename);
landley09ea7ac2006-10-30 01:38:00 -050057void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
58void itoa_to_buf(int n, char *buf, unsigned buflen);
59char *utoa(unsigned n);
60char *itoa(int n);
Rob Landleye2580db2007-01-23 13:20:38 -050061off_t fdlength(int fd);
landley4f344e32006-10-05 16:18:03 -040062
landleycd9dfc32006-10-18 18:38:16 -040063// getmountlist.c
landley4f344e32006-10-05 16:18:03 -040064struct mtab_list {
65 struct mtab_list *next;
landley09ea7ac2006-10-30 01:38:00 -050066 struct stat stat;
67 struct statvfs statvfs;
landley4f344e32006-10-05 16:18:03 -040068 char *dir;
69 char *device;
70 char type[0];
71};
72
73struct mtab_list *getmountlist(int die);
74
Rob Landley6000f132007-01-18 22:00:12 -050075void bunzipStream(int src_fd, int dst_fd);