annotate lib/lib.h @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 2b957eaa00c7
children 078138791b5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
1 /* 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
2 *
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
3 * 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
4 */
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
5
417
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
6 // Unfortunately, sizeof() doesn't work in a preprocessor test. TODO.
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
7
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
8 //#if sizeof(double) <= sizeof(long)
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
9 //typedef double FLOAT;
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
10 //#else
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
11 typedef float FLOAT;
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
12 //#endif
57e1335e59f6 Commit 415 needs the other two files. (Oops.)
Rob Landley <rob@landley.net>
parents: 397
diff changeset
13
35
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
14 // libc generally has this, but the headers are screwed up
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
15 ssize_t getline(char **lineptr, size_t *n, FILE *stream);
f2c7f0799ebe Add cat -v.
Rob Landley <rob@landley.net>
parents: 25
diff changeset
16
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
17 // llist.c
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
18
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
19 // All these list types can be handled by the same code because first element
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
20 // is always next pointer, so next = (mytype *)&struct.
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
21
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
22 struct string_list {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
23 struct string_list *next;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
24 char str[0];
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
25 };
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
26
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
27 struct arg_list {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
28 struct arg_list *next;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
29 char *arg;
25
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
30 };
eb46bb5626cb New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents: 20
diff changeset
31
201
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
32 struct double_list {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
33 struct double_list *next, *prev;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
34 char *data;
201
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
35 };
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
36
624
1e8b9acdafeb Genericize llist code a bit: rename llist_free() to llist_traverse(), and no longer accept NULL as a synonym for free.
Rob Landley <rob@landley.net>
parents: 623
diff changeset
37 void llist_traverse(void *list, void (*using)(void *data));
238
630b2e12db16 Move dlist_add() to lib/llist.c
Rob Landley <rob@landley.net>
parents: 216
diff changeset
38 void *llist_pop(void *list); // actually void **list, but the compiler's dumb
540
c2f39708a4c4 Redo tail to use optargs and optionally support lseek. Add support to optargs and llist.c, plus add a test suite entry. Still no -f support though.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
39 void dlist_add_nomalloc(struct double_list **list, struct double_list *new);
315
aaac01796688 Upgrade patch to detect hunks that start after a false start.
Rob Landley <rob@landley.net>
parents: 311
diff changeset
40 struct double_list *dlist_add(struct double_list **list, char *data);
238
630b2e12db16 Move dlist_add() to lib/llist.c
Rob Landley <rob@landley.net>
parents: 216
diff changeset
41
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
42 // 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
43 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
44
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
45 // dirtree.c
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
46
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
47 // Values returnable from callback function (bitfield, or them together)
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
48 // Default with no callback is 0
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
49
580
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
50 // Add this node to the tree
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
51 #define DIRTREE_SAVE 1
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
52 // Recurse into children
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
53 #define DIRTREE_RECURSE 2
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
54 // Call again after handling all children of this directory
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
55 // (Ignored for non-directories, sets linklen = -1 before second call.)
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
56 #define DIRTREE_COMEAGAIN 4
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
57 // Follow symlinks to directories
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
58 #define DIRTREE_SYMFOLLOW 8
580
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
59 // Don't look at any more files in this directory.
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
60 #define DIRTREE_ABORT 256
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
61
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
62 #define DIRTREE_ABORTVAL ((struct dirtree *)1)
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
63
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
64 struct dirtree {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
65 struct dirtree *next, *parent, *child;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
66 long extra; // place for user to store their stuff (can be pointer)
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
67 struct stat st;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
68 char *symlink;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
69 int data; // dirfd for directory, linklen for symlink, -1 = comeagain
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
70 char name[];
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
71 };
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
72
593
fb582378a36a Implement DIRTREE_SYMFOLLOW and ls -cSHL.
Rob Landley <rob@landley.net>
parents: 590
diff changeset
73 struct dirtree *dirtree_add_node(int dirfd, char *name, int symfollow);
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
74 char *dirtree_path(struct dirtree *node, int *plen);
580
4877cff01b25 dirtree logic cleanup: switch DIRTREE_NORECURSE and DIRTREE_NOSAVE to DIRTREE_RECURSE and DIRTREE_SAVE.
Rob Landley <rob@landley.net>
parents: 565
diff changeset
75 int dirtree_notdotdot(struct dirtree *catch);
601
a6a541b7fc34 Add dirtree_parentfd()
Rob Landley <rob@landley.net>
parents: 593
diff changeset
76 int dirtree_parentfd(struct dirtree *node);
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
77 struct dirtree *handle_callback(struct dirtree *new,
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
78 int (*callback)(struct dirtree *node));
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
79 void dirtree_recurse(struct dirtree *node,
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
80 int (*callback)(struct dirtree *node), int symfollow);
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
81 struct dirtree *dirtree_read(char *path, 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
82
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
83 // lib.c
167
f16c8e5e9435 Replace strlcpy() with xstrcpy(), which exits if the string won't fit.
Rob Landley <rob@landley.net>
parents: 166
diff changeset
84 void xstrcpy(char *dest, char *src, size_t size);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
85 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
86 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
87 void perror_msg(char *msg, ...);
166
5f1d3ad8a888 Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents: 144
diff changeset
88 void error_exit(char *msg, ...) noreturn;
5f1d3ad8a888 Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents: 144
diff changeset
89 void perror_exit(char *msg, ...) noreturn;
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
90 void *xmalloc(size_t size);
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
91 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
92 void *xrealloc(void *ptr, size_t size);
369
5715eed39575 Correct return types of xstrdup() and xstrndup()
Rob Landley <rob@landley.net>
parents: 340
diff changeset
93 char *xstrndup(char *s, size_t n);
5715eed39575 Correct return types of xstrdup() and xstrndup()
Rob Landley <rob@landley.net>
parents: 340
diff changeset
94 char *xstrdup(char *s);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
95 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
96 void xprintf(char *format, ...);
128
0a90a5fbc1bf Add xputs() to detect EOF on writes.
Rob Landley <rob@landley.net>
parents: 124
diff changeset
97 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
98 void xputc(char c);
a1b464bbef08 Add "echo". Has -n and -e (but not \0123 yet).
Rob Landley <rob@landley.net>
parents: 64
diff changeset
99 void xflush(void);
7
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
100 void xexec(char **argv);
51
63edd4de94dd Add xaccess()
Rob Landley <rob@landley.net>
parents: 50
diff changeset
101 void xaccess(char *path, int flags);
214
98820d1eaa79 Upgrade patch to understand creating and deleting files.
Rob Landley <rob@landley.net>
parents: 209
diff changeset
102 void xunlink(char *path);
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
103 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
104 int xopen(char *path, int flags);
201
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
105 void xclose(int fd);
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
106 int xdup(int fd);
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
107 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
108 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
109 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
110 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
111 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
112 void xwrite(int fd, void *buf, size_t len);
340
6e03d6a8df23 Add mkswap.
Rob Landley <rob@landley.net>
parents: 337
diff changeset
113 off_t xlseek(int fd, off_t offset, int whence);
623
f51beec92738 New infrastructure for od (oops).
Rob Landley <rob@landley.net>
parents: 607
diff changeset
114 off_t lskip(int fd, off_t offset);
311
962bbf7341f8 Tweak from Roberto Foglietta.
Rob Landley <rob@landley.net>
parents: 308
diff changeset
115 char *readfile(char *name);
962bbf7341f8 Tweak from Roberto Foglietta.
Rob Landley <rob@landley.net>
parents: 308
diff changeset
116 char *xreadfile(char *name);
4
732b055e17f7 Add xmsprintf(), xgetcwd(), xgetcwd(), find_in_path().
landley@driftwood
parents: 3
diff changeset
117 char *xgetcwd(void);
95
a636e4d20f13 Add xstat(), read_dirtree(), and read_dirtree_node().
Rob Landley <rob@landley.net>
parents: 75
diff changeset
118 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
119 char *xabspath(char *path);
585
1dcd7994abea Add xrealpath() at suggestion of Ashish Briggers.
Rob Landley <rob@landley.net>
parents: 580
diff changeset
120 char *xrealpath(char *path);
292
b4077be6c746 Update mdev to work around the newest sysfs api breakage in the 2.6.25 kernel.
Rob Landley <rob@landley.net>
parents: 284
diff changeset
121 void xchdir(char *path);
216
5697a3f7c8cf Make patch's file add actually work, including directory creating and
Rob Landley <rob@landley.net>
parents: 214
diff changeset
122 void xmkpath(char *path, int mode);
370
c7a26e26ad08 Add TOYBOX_SUID.
Rob Landley <rob@landley.net>
parents: 369
diff changeset
123 void xsetuid(uid_t uid);
20
3981c96f9285 Implement which. Add hello world to menuconfig. Wrap the various applet main
Rob Landley <rob@landley.net>
parents: 16
diff changeset
124 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
125 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
126 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
127 char *utoa(unsigned n);
fc9c0503d5e2 Implement df. Add -Wall to build and fix up warnings. Add copyright notices.
landley@driftwood
parents: 4
diff changeset
128 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
129 long atolx(char *c);
565
44abf4d901f3 Rewrite dirtree so we don't need readdir, scandir, and fts.h. Rewrite ls (from scratch) to use new dirtree infrastructure. (This breaks everything else that currently uses dirtree.)
Rob Landley <rob@landley.net>
parents: 551
diff changeset
130 int numlen(long l);
623
f51beec92738 New infrastructure for od (oops).
Rob Landley <rob@landley.net>
parents: 607
diff changeset
131 int stridx(char *haystack, char needle);
75
89ca591a9236 More random progress on mke2fs. Nothing to see yet.
Rob Landley <rob@landley.net>
parents: 70
diff changeset
132 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
133 char *xreadlink(char *name);
397
b7afbc6b753a Forgot to check in loopfiles_rw changes needed by truncate.
Rob Landley <rob@landley.net>
parents: 370
diff changeset
134 void loopfiles_rw(char **argv, int flags, int permissions, int failok,
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
135 void (*function)(int fd, char *name));
185
29e2051296fd Add loopfiles() function, make catv use it.
Rob Landley <rob@landley.net>
parents: 167
diff changeset
136 void loopfiles(char **argv, void (*function)(int fd, char *name));
284
603275a05524 Teach get_rawline() to continue until a configurable char, and xstrndup()
Rob Landley <rob@landley.net>
parents: 263
diff changeset
137 char *get_rawline(int fd, long *plen, char end);
201
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
138 char *get_line(int fd);
5d523752715a Start of "patch" support. Writes to stdout at the moment.
Rob Landley <rob@landley.net>
parents: 185
diff changeset
139 void xsendfile(int in, int out);
590
7becb497c3c4 Update chmod to work with new dirtree, and fix bugs in string_to_mode().
Rob Landley <rob@landley.net>
parents: 589
diff changeset
140 int wfchmodat(int rc, char *name, mode_t mode);
209
9a0d4e8a9c61 Patch command.
Rob Landley <rob@landley.net>
parents: 201
diff changeset
141 int copy_tempfile(int fdin, char *name, char **tempname);
9a0d4e8a9c61 Patch command.
Rob Landley <rob@landley.net>
parents: 201
diff changeset
142 void delete_tempfile(int fdin, int fdout, char **tempname);
9a0d4e8a9c61 Patch command.
Rob Landley <rob@landley.net>
parents: 201
diff changeset
143 void replace_tempfile(int fdin, int fdout, char **tempname);
337
aaafa1ceaa91 Add -N, -I, -L, and -P options to cksum.
Rob Landley <rob@landley.net>
parents: 334
diff changeset
144 void crc_init(unsigned int *crc_table, int little_endian);
419
af0cca0aba9d Quick and dirty terminal_size() and yesno() functions, both of which need to be improved.
Rob Landley <rob@landley.net>
parents: 417
diff changeset
145 void terminal_size(unsigned *x, unsigned *y);
503
3b9dea897dc0 Upgrade yesno() and make cp -i use it.
Rob Landley <rob@landley.net>
parents: 498
diff changeset
146 int yesno(char *prompt, int def);
478
7f292460d268 And again, I forgot to check in a file. Oops.
Rob Landley <rob@landley.net>
parents: 475
diff changeset
147 void for_each_pid_with_name_in(char **names, void (*callback)(pid_t pid));
419
af0cca0aba9d Quick and dirty terminal_size() and yesno() functions, both of which need to be improved.
Rob Landley <rob@landley.net>
parents: 417
diff changeset
148
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
149
3
266a462ed18c Next drop of toysh, plus more infratructure.
landley@driftwood
parents: 2
diff changeset
150 // getmountlist.c
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
151 struct mtab_list {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
152 struct mtab_list *next;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
153 struct stat stat;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
154 struct statvfs statvfs;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
155 char *dir;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
156 char *device;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 658
diff changeset
157 char type[0];
2
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
158 };
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
159
67b517913e56 Infrastructure, first drop of toy shell, and a bit of work on df.
landley@driftwood
parents:
diff changeset
160 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
161
64
67ee3a0b76e1 In bunzip replace setjmp/longjmp handling with error_exit(), replace string
Rob Landley <rob@landley.net>
parents: 63
diff changeset
162 void bunzipStream(int src_fd, int dst_fd);
498
c9aaceccd6bd Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Rob Landley <rob@landley.net>
parents: 478
diff changeset
163
c9aaceccd6bd Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Rob Landley <rob@landley.net>
parents: 478
diff changeset
164 // signal
c9aaceccd6bd Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Rob Landley <rob@landley.net>
parents: 478
diff changeset
165
643
7bdebd2af1d6 Add signal handler to clean up tempfile.
Rob Landley <rob@landley.net>
parents: 637
diff changeset
166 void sigatexit(void *handler);
498
c9aaceccd6bd Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Rob Landley <rob@landley.net>
parents: 478
diff changeset
167 int sig_to_num(char *pidstr);
c9aaceccd6bd Factor out common code between killall/kill and move it to lib/lib.c, plus cleanups on kill.c.
Rob Landley <rob@landley.net>
parents: 478
diff changeset
168 char *num_to_sig(int sig);
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 540
diff changeset
169
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 540
diff changeset
170 mode_t string_to_mode(char *mode_str, mode_t base);
626
77d94b36aff0 Add passwd by Kyungwan Han.
Rob Landley <rob@landley.net>
parents: 624
diff changeset
171
77d94b36aff0 Add passwd by Kyungwan Han.
Rob Landley <rob@landley.net>
parents: 624
diff changeset
172 // password helper functions
637
9aeea680acc7 Use "_password" instead of "_passwd" for names in lib/password.c.
Rob Landley <rob@landley.net>
parents: 626
diff changeset
173 int read_password(char * buff, int buflen, char* mesg);
9aeea680acc7 Use "_password" instead of "_passwd" for names in lib/password.c.
Rob Landley <rob@landley.net>
parents: 626
diff changeset
174 int update_password(char *filename, char* username, char* encrypted);
626
77d94b36aff0 Add passwd by Kyungwan Han.
Rob Landley <rob@landley.net>
parents: 624
diff changeset
175
658
2b957eaa00c7 Add du command.
Ashwini Kumar <ak.ashwini@gmail.com>
parents: 643
diff changeset
176 // du helper functions
2b957eaa00c7 Add du command.
Ashwini Kumar <ak.ashwini@gmail.com>
parents: 643
diff changeset
177 char* make_human_readable(unsigned long long size, unsigned long unit);