annotate lib/lib.h @ 143:9cbb323f297f

Break out dirtree.c and let it call a function instead of returning the data.
author Rob Landley <rob@landley.net>
date Thu, 04 Oct 2007 02:04:10 -0500
parents 0901b3b2bbe9
children 1fbc50374a30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
1 /* vi: set ts=4 :*/
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
2 /* lib.h - header file for lib directory
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
3 *
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
4 * Copyright 2006 Rob Landley <rob@landley.net>
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
5 */
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
6
35
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
7 // libc generally has this, but the headers are screwed up
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
8 ssize_t getline(char **lineptr, size_t *n, FILE *stream);
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
9
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
10 // llist.c
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
11 void llist_free(void *list, void (*freeit)(void *data));
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
12 void *llist_pop(void *list); // actually void **list, but the compiler's dumb
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
13
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
14 struct string_list {
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
15 struct string_list *next;
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
16 char str[0];
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
17 };
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
18
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
19 struct arg_list {
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
20 struct arg_list *next;
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
21 char *arg;
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
22 };
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
23
143
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
24 // args.c
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
25 void get_optflags(void);
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
26
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
27 // dirtree.c
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
28 struct dirtree {
97
4c81e6375719 Add parent pointer to dirtree, more work on mke2fs (populate dirtree, count
Rob Landley <rob@landley.net>
parents: 95
diff changeset
29 struct dirtree *next, *child, *parent;
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
30 struct stat st;
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
31 char name[];
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
32 };
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
33
143
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
34 struct dirtree *dirtree_add_node(char *path);
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
35 struct dirtree *dirtree_read(char *path, struct dirtree *parent,
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
36 int (*callback)(struct dirtree *node));
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
37
143
9cbb323f297f Break out dirtree.c and let it call a function instead of returning the data.
Rob Landley <rob@landley.net>
parents: 137
diff changeset
38 // lib.c
137
0901b3b2bbe9 More klibc fixes from Maximilian Attems, strlcpy() this time.
Rob Landley <rob@landley.net>
parents: 128
diff changeset
39 #if !defined(__UCLIBC__) && !defined(__KLIBC__)
124
ef2bc92d5fb0 Work around uClibc weirdness.
Rob Landley <rob@landley.net>
parents: 115
diff changeset
40 void strlcpy(char *dest, char *src, size_t size);
ef2bc92d5fb0 Work around uClibc weirdness.
Rob Landley <rob@landley.net>
parents: 115
diff changeset
41 #endif
ef2bc92d5fb0 Work around uClibc weirdness.
Rob Landley <rob@landley.net>
parents: 115
diff changeset
42
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
43 void verror_msg(char *msg, int err, va_list va);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
44 void error_msg(char *msg, ...);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
45 void perror_msg(char *msg, ...);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
46 void error_exit(char *msg, ...);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
47 void perror_exit(char *msg, ...);
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents: 52
diff changeset
48 void usage_exit(void);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
49 void *xmalloc(size_t size);
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
50 void *xzalloc(size_t size);
115
19b5567f0a1b Add readlink, xreadlink(), and change xrealloc() to not fight the stupid
Rob Landley <rob@landley.net>
parents: 102
diff changeset
51 void *xrealloc(void *ptr, size_t size);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
52 void *xstrndup(char *s, size_t n);
16
dd10785b6532 Add xabspath(), is_file_type(), which_in_path(), and find_in_path().
Rob Landley <rob@landley.net>
parents: 8
diff changeset
53 void *xstrdup(char *s);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
54 char *xmsprintf(char *format, ...);
70
a1b464bbef08 Add "echo". Has -n and -e (but not \0123 yet).
Rob Landley <rob@landley.net>
parents: 64
diff changeset
55 void xprintf(char *format, ...);
128
0a90a5fbc1bf Add xputs() to detect EOF on writes.
Rob Landley <rob@landley.net>
parents: 124
diff changeset
56 void xputs(char *s);
70
a1b464bbef08 Add "echo". Has -n and -e (but not \0123 yet).
Rob Landley <rob@landley.net>
parents: 64
diff changeset
57 void xputc(char c);
a1b464bbef08 Add "echo". Has -n and -e (but not \0123 yet).
Rob Landley <rob@landley.net>
parents: 64
diff changeset
58 void xflush(void);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
59 void xexec(char **argv);
51
63edd4de94dd Add xaccess()
Rob Landley <rob@landley.net>
parents: 50
diff changeset
60 void xaccess(char *path, int flags);
49
bb4c38853a7d xopen() wants 2 arguments unless you're creating a file, in which case you
Rob Landley <rob@landley.net>
parents: 35
diff changeset
61 int xcreate(char *path, int flags, int mode);
bb4c38853a7d xopen() wants 2 arguments unless you're creating a file, in which case you
Rob Landley <rob@landley.net>
parents: 35
diff changeset
62 int xopen(char *path, int flags);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
63 FILE *xfopen(char *path, char *mode);
63
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
64 ssize_t readall(int fd, void *buf, size_t len);
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
65 ssize_t writeall(int fd, void *buf, size_t len);
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
66 size_t xread(int fd, void *buf, size_t len);
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
67 void xreadall(int fd, void *buf, size_t len);
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
68 void xwrite(int fd, void *buf, size_t len);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
69 char *xgetcwd(void);
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
70 void xstat(char *path, struct stat *st);
16
dd10785b6532 Add xabspath(), is_file_type(), which_in_path(), and find_in_path().
Rob Landley <rob@landley.net>
parents: 8
diff changeset
71 char *xabspath(char *path);
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
72 struct string_list *find_in_path(char *path, char *filename);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
73 void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
74 void itoa_to_buf(int n, char *buf, unsigned buflen);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
75 char *utoa(unsigned n);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
76 char *itoa(int n);
102
aa4fa2543a65 Add atolx() which understands extensions for kilobytes and megabytes and such.
Rob Landley <rob@landley.net>
parents: 97
diff changeset
77 long atolx(char *c);
75
89ca591a9236 More random progress on mke2fs. Nothing to see yet.
Rob Landley <rob@landley.net>
parents: 70
diff changeset
78 off_t fdlength(int fd);
115
19b5567f0a1b Add readlink, xreadlink(), and change xrealloc() to not fight the stupid
Rob Landley <rob@landley.net>
parents: 102
diff changeset
79 char *xreadlink(char *name);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
80
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
81 // getmountlist.c
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
82 struct mtab_list {
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
83 struct mtab_list *next;
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
84 struct stat stat;
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
85 struct statvfs statvfs;
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
86 char *dir;
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
87 char *device;
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
88 char type[0];
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
89 };
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
90
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
91 struct mtab_list *getmountlist(int die);
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
92
64
67ee3a0b76e1 In bunzip replace setjmp/longjmp handling with error_exit(), replace string
Rob Landley <rob@landley.net>
parents: 63
diff changeset
93 void bunzipStream(int src_fd, int dst_fd);