blob: cb14027511f858bb386f5bb0cfad5df38c838ae3 [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, ...);
landley4f344e32006-10-05 16:18:03 -040033void strlcpy(char *dest, char *src, size_t size);
34void *xmalloc(size_t size);
landleycd9dfc32006-10-18 18:38:16 -040035void *xzalloc(size_t size);
36void xrealloc(void **ptr, size_t size);
landley4f344e32006-10-05 16:18:03 -040037void *xstrndup(char *s, size_t n);
Rob Landleyfa98d012006-11-02 02:57:27 -050038void *xstrdup(char *s);
landley00f87f12006-10-25 18:38:37 -040039char *xmsprintf(char *format, ...);
landley09ea7ac2006-10-30 01:38:00 -050040void xexec(char **argv);
Rob Landley1322beb2007-01-07 22:51:12 -050041int xcreate(char *path, int flags, int mode);
42int xopen(char *path, int flags);
landley4f344e32006-10-05 16:18:03 -040043FILE *xfopen(char *path, char *mode);
landley64b2e232006-10-30 10:01:19 -050044ssize_t reread(int fd, void *buf, size_t count);
45ssize_t readall(int fd, void *buf, size_t count);
46void xread(int fd, char *buf, size_t count);
landley00f87f12006-10-25 18:38:37 -040047char *xgetcwd(void);
Rob Landleyfa98d012006-11-02 02:57:27 -050048char *xabspath(char *path);
Rob Landley0a04b3e2006-11-03 00:05:52 -050049struct string_list *find_in_path(char *path, char *filename);
landley09ea7ac2006-10-30 01:38:00 -050050void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
51void itoa_to_buf(int n, char *buf, unsigned buflen);
52char *utoa(unsigned n);
53char *itoa(int n);
landley4f344e32006-10-05 16:18:03 -040054
landleycd9dfc32006-10-18 18:38:16 -040055// getmountlist.c
landley4f344e32006-10-05 16:18:03 -040056struct mtab_list {
57 struct mtab_list *next;
landley09ea7ac2006-10-30 01:38:00 -050058 struct stat stat;
59 struct statvfs statvfs;
landley4f344e32006-10-05 16:18:03 -040060 char *dir;
61 char *device;
62 char type[0];
63};
64
65struct mtab_list *getmountlist(int die);
66
Rob Landley1322beb2007-01-07 22:51:12 -050067char *bunzipStream(int src_fd, int dst_fd);