blob: e3dced22c449ee4731e9120468e0f3545a8b16fe [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 Landleyd3e9d642007-01-08 03:25:47 -050041void xaccess(char *path, int flags);
Rob Landley1322beb2007-01-07 22:51:12 -050042int xcreate(char *path, int flags, int mode);
43int xopen(char *path, int flags);
landley4f344e32006-10-05 16:18:03 -040044FILE *xfopen(char *path, char *mode);
landley64b2e232006-10-30 10:01:19 -050045ssize_t reread(int fd, void *buf, size_t count);
Rob Landleyf3e452a2007-01-08 02:49:39 -050046ssize_t rewrite(int fd, void *buf, size_t count);
landley64b2e232006-10-30 10:01:19 -050047ssize_t readall(int fd, void *buf, size_t count);
Rob Landleyf3e452a2007-01-08 02:49:39 -050048ssize_t writeall(int fd, void *buf, size_t count);
landley64b2e232006-10-30 10:01:19 -050049void xread(int fd, char *buf, size_t count);
Rob Landleyf3e452a2007-01-08 02:49:39 -050050void xwrite(int fd, char *buf, size_t count);
landley00f87f12006-10-25 18:38:37 -040051char *xgetcwd(void);
Rob Landleyfa98d012006-11-02 02:57:27 -050052char *xabspath(char *path);
Rob Landley0a04b3e2006-11-03 00:05:52 -050053struct string_list *find_in_path(char *path, char *filename);
landley09ea7ac2006-10-30 01:38:00 -050054void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
55void itoa_to_buf(int n, char *buf, unsigned buflen);
56char *utoa(unsigned n);
57char *itoa(int n);
landley4f344e32006-10-05 16:18:03 -040058
landleycd9dfc32006-10-18 18:38:16 -040059// getmountlist.c
landley4f344e32006-10-05 16:18:03 -040060struct mtab_list {
61 struct mtab_list *next;
landley09ea7ac2006-10-30 01:38:00 -050062 struct stat stat;
63 struct statvfs statvfs;
landley4f344e32006-10-05 16:18:03 -040064 char *dir;
65 char *device;
66 char type[0];
67};
68
69struct mtab_list *getmountlist(int die);
70
Rob Landley1322beb2007-01-07 22:51:12 -050071char *bunzipStream(int src_fd, int dst_fd);