annotate lib/lib.h @ 49:bb4c38853a7d

xopen() wants 2 arguments unless you're creating a file, in which case you need 3. Doing varargs for this doesn't really appeal to me (bugs in waiting) so I made an xcreate() that takes 3 args, and had xopen() call it with 0 for the third argument. That way, if we feed O_CREAT to xopen() the permission 000 result should be easy to spot.
author Rob Landley <rob@landley.net>
date Sun, 07 Jan 2007 22:51:12 -0500
parents f2c7f0799ebe
children 63c168b65fa6
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
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
24 // args.c
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
25 void get_optflags(void);
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
26
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
27 // functions.c
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
28 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
29 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
30 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
31 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
32 void perror_exit(char *msg, ...);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
33 void strlcpy(char *dest, char *src, size_t size);
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
34 void *xmalloc(size_t size);
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
35 void *xzalloc(size_t size);
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
36 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
37 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
38 void *xstrdup(char *s);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
39 char *xmsprintf(char *format, ...);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
40 void xexec(char **argv);
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
41 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
42 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
43 FILE *xfopen(char *path, char *mode);
8
04f66da2bdbf Add reread(), readall(), and xread() on the bus ride in to work...
landley@driftwood
parents: 7
diff changeset
44 ssize_t reread(int fd, void *buf, size_t count);
04f66da2bdbf Add reread(), readall(), and xread() on the bus ride in to work...
landley@driftwood
parents: 7
diff changeset
45 ssize_t readall(int fd, void *buf, size_t count);
04f66da2bdbf Add reread(), readall(), and xread() on the bus ride in to work...
landley@driftwood
parents: 7
diff changeset
46 void xread(int fd, char *buf, size_t count);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
47 char *xgetcwd(void);
16
dd10785b6532 Add xabspath(), is_file_type(), which_in_path(), and find_in_path().
Rob Landley <rob@landley.net>
parents: 8
diff changeset
48 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
49 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
50 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
51 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
52 char *utoa(unsigned n);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
53 char *itoa(int n);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
54
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
55 // getmountlist.c
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
56 struct mtab_list {
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
57 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
58 struct stat stat;
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
59 struct statvfs statvfs;
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
60 char *dir;
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
61 char *device;
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
62 char type[0];
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
63 };
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
64
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
65 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
66
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
67 char *bunzipStream(int src_fd, int dst_fd);