annotate toys/other/readlink.c @ 944:b4faf2ae39e8

This inlines CRC64, and nothing more. The functions involved were called only once.
author Isaac Dunham <idunham@lavabit.com>
date Sat, 06 Jul 2013 11:26:15 -0500
parents 0027cfa330da
children 57f2a26fa92c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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: 656
diff changeset
1 /* readlink.c - Return string representation of a symbolic link.
194
30a6db5a95c2 Add comments about SUSv3 specs (or lack thereof).
Rob Landley <rob@landley.net>
parents: 186
diff changeset
2 *
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
3 * Copyright 2007 Rob Landley <rob@landley.net>
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
4
708
50d759f8b371 Remove readlink -m for being poorly defined ("readlink -m /dev/null/and/more" answers what question, exactly?), rewrite xabspath() to work right and not depend on realpath, fix subtle longstanding bug in llist_traverse().
Rob Landley <rob@landley.net>
parents: 707
diff changeset
5 USE_READLINK(NEWTOY(readlink, "<1>1fenq[-fe]", TOYFLAG_BIN))
234
163498bf547b Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents: 233
diff changeset
6
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
7 config READLINK
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: 656
diff changeset
8 bool "readlink"
792
0027cfa330da Switch readlink on by default, and fill out readlink.test.
Rob Landley <rob@landley.net>
parents: 708
diff changeset
9 default y
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: 656
diff changeset
10 help
707
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
11 usage: readlink FILE
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
12
707
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
13 With no options, show what symlink points to, return error if not symlink.
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
14
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
15 Options for producing cannonical paths (all symlinks/./.. resolved):
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
16
792
0027cfa330da Switch readlink on by default, and fill out readlink.test.
Rob Landley <rob@landley.net>
parents: 708
diff changeset
17 -e cannonical path to existing entry (fail if missing)
0027cfa330da Switch readlink on by default, and fill out readlink.test.
Rob Landley <rob@landley.net>
parents: 708
diff changeset
18 -f full path (fail if directory missing)
707
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
19 -n no trailing newline
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
20 -q quiet (no output, just error code)
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 223
diff changeset
21 */
129
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
22
707
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
23 #define FOR_readlink
129
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
24 #include "toys.h"
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
25
186
25447caf1b4b Change command main() functions to return void, and exit(toys.exitval) from
Rob Landley <rob@landley.net>
parents: 129
diff changeset
26 void readlink_main(void)
129
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
27 {
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: 656
diff changeset
28 char *s;
223
52a0c06b2dad Teach readlink to actually do -f.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
29
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: 656
diff changeset
30 // Calculating full cannonical path?
223
52a0c06b2dad Teach readlink to actually do -f.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
31
708
50d759f8b371 Remove readlink -m for being poorly defined ("readlink -m /dev/null/and/more" answers what question, exactly?), rewrite xabspath() to work right and not depend on realpath, fix subtle longstanding bug in llist_traverse().
Rob Landley <rob@landley.net>
parents: 707
diff changeset
32 if (toys.optflags & (FLAG_f|FLAG_e))
50d759f8b371 Remove readlink -m for being poorly defined ("readlink -m /dev/null/and/more" answers what question, exactly?), rewrite xabspath() to work right and not depend on realpath, fix subtle longstanding bug in llist_traverse().
Rob Landley <rob@landley.net>
parents: 707
diff changeset
33 s = xabspath(*toys.optargs, toys.optflags & FLAG_e);
50d759f8b371 Remove readlink -m for being poorly defined ("readlink -m /dev/null/and/more" answers what question, exactly?), rewrite xabspath() to work right and not depend on realpath, fix subtle longstanding bug in llist_traverse().
Rob Landley <rob@landley.net>
parents: 707
diff changeset
34 else s = xreadlink(*toys.optargs);
129
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
35
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: 656
diff changeset
36 if (s) {
707
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
37 if (!(toys.optflags & FLAG_q))
977e19296b3f Update readlink so -f works. Add -menq while there.
Rob Landley <rob@landley.net>
parents: 694
diff changeset
38 xprintf((toys.optflags & FLAG_n) ? "%s" : "%s\n", s);
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: 656
diff changeset
39 if (CFG_TOYBOX_FREE) free(s);
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: 656
diff changeset
40 } else toys.exitval = 1;
129
0dfead29c893 Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
Rob Landley <rob@landley.net>
parents:
diff changeset
41 }