home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / duonly < prev    next >
SHell self-extracting ARchive  |  1991-08-07  |  21.5 KB

view JSON data     |     view as text     |     open on a Mac     |     open on a PC

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: duonly

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail text default
99% file C source text default
98% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 3a 20 64 65 | 6e 6e 69 73 40 72 6c 67 |From: de|nnis@rlg|
|00000010| 76 61 78 2e 55 55 43 50 | 20 28 44 65 6e 6e 69 73 |vax.UUCP| (Dennis|
|00000020| 2e 42 65 64 6e 61 72 29 | 0a 4e 65 77 73 67 72 6f |.Bednar)|.Newsgro|
|00000030| 75 70 73 3a 20 63 6f 6d | 70 2e 73 6f 75 72 63 65 |ups: com|p.source|
|00000040| 73 2e 6d 69 73 63 0a 53 | 75 62 6a 65 63 74 3a 20 |s.misc.S|ubject: |
|00000050| 76 30 32 69 30 36 30 3a | 20 64 75 6f 6e 6c 79 20 |v02i060:| duonly |
|00000060| 2d 20 50 72 6f 67 72 61 | 6d 20 74 6f 20 64 69 73 |- Progra|m to dis|
|00000070| 70 6c 61 79 20 64 75 20 | 6f 75 74 70 75 74 20 4f |play du |output O|
|00000080| 4e 4c 59 20 66 6f 72 20 | 61 20 64 69 72 65 63 74 |NLY for |a direct|
|00000090| 6f 72 79 0a 4d 65 73 73 | 61 67 65 2d 49 44 3a 20 |ory.Mess|age-ID: |
|000000a0| 3c 37 34 32 39 40 6e 63 | 6f 61 73 74 2e 55 55 43 |<7429@nc|oast.UUC|
|000000b0| 50 3e 0a 44 61 74 65 3a | 20 32 32 20 46 65 62 20 |P>.Date:| 22 Feb |
|000000c0| 38 38 20 30 32 3a 33 34 | 3a 33 37 20 47 4d 54 0a |88 02:34|:37 GMT.|
|000000d0| 41 70 70 72 6f 76 65 64 | 3a 20 61 6c 6c 62 65 72 |Approved|: allber|
|000000e0| 79 40 6e 63 6f 61 73 74 | 2e 55 55 43 50 0a 0a 43 |y@ncoast|.UUCP..C|
|000000f0| 6f 6d 70 2e 73 6f 75 72 | 63 65 73 2e 6d 69 73 63 |omp.sour|ces.misc|
|00000100| 3a 20 56 6f 6c 75 6d 65 | 20 32 2c 20 49 73 73 75 |: Volume| 2, Issu|
|00000110| 65 20 36 30 0a 53 75 62 | 6d 69 74 74 65 64 2d 42 |e 60.Sub|mitted-B|
|00000120| 79 3a 20 22 44 65 6e 6e | 69 73 2e 42 65 64 6e 61 |y: "Denn|is.Bedna|
|00000130| 72 22 20 3c 64 65 6e 6e | 69 73 40 72 6c 67 76 61 |r" <denn|is@rlgva|
|00000140| 78 2e 55 55 43 50 3e 0a | 41 72 63 68 69 76 65 2d |x.UUCP>.|Archive-|
|00000150| 4e 61 6d 65 3a 20 64 75 | 6f 6e 6c 79 0a 0a 53 48 |Name: du|only..SH|
|00000160| 4f 52 54 20 62 6c 75 72 | 62 20 66 72 6f 6d 20 74 |ORT blur|b from t|
|00000170| 68 65 20 64 75 6f 6e 6c | 79 2e 68 65 6c 70 20 66 |he duonl|y.help f|
|00000180| 69 6c 65 2c 20 6a 75 73 | 74 20 74 6f 20 73 75 6d |ile, jus|t to sum|
|00000190| 6d 61 72 69 7a 65 20 77 | 68 61 74 0a 74 68 69 73 |marize w|hat.this|
|000001a0| 20 69 73 20 70 72 6f 67 | 72 61 6d 20 69 73 20 66 | is prog|ram is f|
|000001b0| 6f 72 3a 0a 0a 50 72 69 | 6e 74 73 20 64 69 73 6b |or:..Pri|nts disk|
|000001c0| 20 75 73 61 67 65 20 62 | 6c 6f 63 6b 20 73 69 7a | usage b|lock siz|
|000001d0| 65 73 20 6f 6e 6c 79 20 | 66 6f 72 20 64 69 72 65 |es only |for dire|
|000001e0| 63 74 6f 72 69 65 73 2c | 0a 62 75 74 20 4e 4f 54 |ctories,|.but NOT|
|000001f0| 20 69 6e 63 6c 75 64 69 | 6e 67 20 73 69 7a 65 73 | includi|ng sizes|
|00000200| 20 63 6f 6e 74 72 69 62 | 75 74 65 64 20 62 79 20 | contrib|uted by |
|00000210| 73 75 62 2d 64 69 72 65 | 63 74 6f 72 69 65 73 2e |sub-dire|ctories.|
|00000220| 0a 0a 54 68 69 73 20 74 | 6f 6f 6c 20 77 61 73 20 |..This t|ool was |
|00000230| 64 65 76 65 6c 6f 70 65 | 64 20 62 65 63 61 75 73 |develope|d becaus|
|00000240| 65 20 77 68 65 6e 20 76 | 69 65 77 69 6e 67 20 74 |e when v|iewing t|
|00000250| 68 65 20 6f 75 74 70 75 | 74 20 6f 66 20 61 0a 72 |he outpu|t of a.r|
|00000260| 65 67 75 6c 61 72 20 64 | 75 2c 20 69 74 20 77 61 |egular d|u, it wa|
|00000270| 73 20 64 69 66 66 69 63 | 75 6c 74 20 74 6f 20 73 |s diffic|ult to s|
|00000280| 65 65 20 77 68 69 63 68 | 20 64 69 72 65 63 74 6f |ee which| directo|
|00000290| 72 69 65 73 20 77 65 72 | 65 0a 74 68 65 20 72 65 |ries wer|e.the re|
|000002a0| 61 6c 20 63 75 6c 70 72 | 69 74 73 20 66 6f 72 20 |al culpr|its for |
|000002b0| 6f 63 63 75 70 79 69 6e | 67 20 74 68 65 20 6d 6f |occupyin|g the mo|
|000002c0| 73 74 20 6e 75 6d 62 65 | 72 20 6f 66 20 64 69 73 |st numbe|r of dis|
|000002d0| 6b 20 62 6c 6f 63 6b 73 | 2e 0a 0a 23 2d 2d 2d 2d |k blocks|...#----|
|000002e0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 20 43 55 54 20 |--------|--- CUT |
|000002f0| 48 45 52 45 20 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |HERE ---|--------|
|00000300| 2d 2d 2d 2d 0a 23 21 20 | 2f 62 69 6e 2f 73 68 0a |----.#! |/bin/sh.|
|00000310| 23 20 54 68 69 73 20 69 | 73 20 61 20 73 68 65 6c |# This i|s a shel|
|00000320| 6c 20 61 72 63 68 69 76 | 65 2c 20 6d 65 61 6e 69 |l archiv|e, meani|
|00000330| 6e 67 3a 0a 23 20 31 2e | 20 52 65 6d 6f 76 65 20 |ng:.# 1.| Remove |
|00000340| 65 76 65 72 79 74 68 69 | 6e 67 20 61 62 6f 76 65 |everythi|ng above|
|00000350| 20 74 68 65 20 23 21 20 | 2f 62 69 6e 2f 73 68 20 | the #! |/bin/sh |
|00000360| 6c 69 6e 65 2e 0a 23 20 | 32 2e 20 53 61 76 65 20 |line..# |2. Save |
|00000370| 74 68 65 20 72 65 73 75 | 6c 74 69 6e 67 20 74 65 |the resu|lting te|
|00000380| 78 74 20 69 6e 20 61 20 | 66 69 6c 65 2e 0a 23 20 |xt in a |file..# |
|00000390| 33 2e 20 45 78 65 63 75 | 74 65 20 74 68 65 20 66 |3. Execu|te the f|
|000003a0| 69 6c 65 20 77 69 74 68 | 20 2f 62 69 6e 2f 73 68 |ile with| /bin/sh|
|000003b0| 20 28 6e 6f 74 20 63 73 | 68 29 20 74 6f 20 63 72 | (not cs|h) to cr|
|000003c0| 65 61 74 65 20 74 68 65 | 20 66 69 6c 65 73 3a 0a |eate the| files:.|
|000003d0| 23 09 64 75 6f 6e 6c 79 | 2e 63 0a 23 09 64 75 6f |#.duonly|.c.#.duo|
|000003e0| 6e 6c 79 2e 68 65 6c 70 | 0a 23 20 54 68 69 73 20 |nly.help|.# This |
|000003f0| 61 72 63 68 69 76 65 20 | 63 72 65 61 74 65 64 3a |archive |created:|
|00000400| 20 57 65 64 20 46 65 62 | 20 31 37 20 32 30 3a 33 | Wed Feb| 17 20:3|
|00000410| 31 3a 30 34 20 45 53 54 | 20 31 39 38 38 0a 23 0a |1:04 EST| 1988.#.|
|00000420| 69 66 20 74 65 73 74 20 | 2d 66 20 64 75 6f 6e 6c |if test |-f duonl|
|00000430| 79 2e 63 0a 74 68 65 6e | 0a 65 63 68 6f 20 73 68 |y.c.then|.echo sh|
|00000440| 61 72 3a 20 77 69 6c 6c | 20 6e 6f 74 20 6f 76 65 |ar: will| not ove|
|00000450| 72 2d 77 72 69 74 65 20 | 65 78 69 73 74 69 6e 67 |r-write |existing|
|00000460| 20 66 69 6c 65 20 27 64 | 75 6f 6e 6c 79 2e 63 27 | file 'd|uonly.c'|
|00000470| 0a 65 6c 73 65 0a 65 63 | 68 6f 20 78 20 2d 20 64 |.else.ec|ho x - d|
|00000480| 75 6f 6e 6c 79 2e 63 0a | 23 20 2e 2e 2e 2e 2e 2e |uonly.c.|# ......|
|00000490| 2e 2e 2e 2e 2e 2e 20 20 | 20 20 46 20 20 49 20 20 |...... | F I |
|000004a0| 20 4c 20 20 20 45 20 20 | 20 20 20 20 42 20 20 45 | L E | B E|
|000004b0| 20 20 47 20 20 2e 2e 2e | 2e 2e 2e 2e 2e 2e 2e 20 | G ...|....... |
|000004c0| 64 75 6f 6e 6c 79 2e 63 | 0a 63 61 74 20 3c 3c 20 |duonly.c|.cat << |
|000004d0| 27 5c 53 48 41 52 5f 45 | 4f 46 27 20 3e 20 64 75 |'\SHAR_E|OF' > du|
|000004e0| 6f 6e 6c 79 2e 63 0a 2f | 2a 0a 20 2a 20 64 75 6f |only.c./|*. * duo|
|000004f0| 6e 6c 79 2e 63 0a 20 2a | 20 64 65 6e 6e 69 73 20 |nly.c. *| dennis |
|00000500| 62 65 64 6e 61 72 20 46 | 65 62 20 31 37 2c 20 31 |bednar F|eb 17, 1|
|00000510| 39 38 38 0a 20 2a 0a 20 | 2a 20 52 65 61 64 73 20 |988. *. |* Reads |
|00000520| 73 74 64 69 6e 20 6f 66 | 20 64 75 20 6f 75 74 70 |stdin of| du outp|
|00000530| 75 74 2c 20 61 6e 64 20 | 6f 75 74 70 75 74 73 20 |ut, and |outputs |
|00000540| 73 69 7a 65 73 20 62 61 | 73 65 64 20 4f 4e 4c 59 |sizes ba|sed ONLY|
|00000550| 20 6f 6e 20 74 68 65 0a | 20 2a 20 73 70 61 63 65 | on the.| * space|
|00000560| 20 75 73 65 64 20 77 69 | 74 68 69 6e 20 61 20 64 | used wi|thin a d|
|00000570| 69 72 65 63 74 6f 72 79 | 20 6f 6e 6c 79 2e 20 20 |irectory| only. |
|00000580| 54 68 65 20 73 69 7a 65 | 20 77 69 6c 6c 20 62 65 |The size| will be|
|00000590| 20 74 68 65 0a 20 2a 20 | 6e 75 6d 62 65 72 20 6f | the. * |number o|
|000005a0| 66 20 62 6c 6f 63 6b 73 | 20 75 73 65 64 20 62 79 |f blocks| used by|
|000005b0| 20 74 68 65 20 64 69 72 | 65 63 74 6f 72 79 20 69 | the dir|ectory i|
|000005c0| 74 73 65 6c 66 2c 20 70 | 6c 75 73 20 61 6e 79 0a |tself, p|lus any.|
|000005d0| 20 2a 20 66 69 6c 65 73 | 20 63 6f 6e 74 61 69 6e | * files| contain|
|000005e0| 65 64 20 77 69 74 68 69 | 6e 20 74 68 61 74 20 64 |ed withi|n that d|
|000005f0| 69 72 65 63 74 6f 72 79 | 2e 0a 20 2a 0a 20 2a 20 |irectory|.. *. * |
|00000600| 4e 4f 54 45 3a 0a 20 2a | 20 4d 75 63 68 20 6f 66 |NOTE:. *| Much of|
|00000610| 20 74 68 65 20 73 6f 75 | 72 63 65 20 63 6f 64 65 | the sou|rce code|
|00000620| 20 69 6e 20 64 75 67 72 | 61 70 68 2e 63 20 28 63 | in dugr|aph.c (c|
|00000630| 6f 6e 74 72 69 62 75 74 | 65 64 20 74 6f 20 63 6f |ontribut|ed to co|
|00000640| 6d 70 2e 75 6e 69 78 2e | 6d 69 73 63 29 0a 20 2a |mp.unix.|misc). *|
|00000650| 20 49 20 62 6f 72 72 6f | 77 65 64 20 22 61 73 20 | I borro|wed "as |
|00000660| 69 73 22 2e 20 20 57 68 | 61 74 20 66 75 6e 63 74 |is". Wh|at funct|
|00000670| 69 6f 6e 73 20 49 20 61 | 64 64 65 64 20 61 72 65 |ions I a|dded are|
|00000680| 20 61 74 20 74 68 65 20 | 65 6e 64 2e 0a 20 2a 20 | at the |end.. * |
|00000690| 49 20 61 6c 73 6f 20 61 | 64 64 65 64 20 74 68 65 |I also a|dded the|
|000006a0| 20 22 66 61 74 68 65 72 | 22 20 6c 69 6e 6b 2e 20 | "father|" link. |
|000006b0| 20 41 6c 6c 20 6f 66 20 | 74 68 65 20 62 72 6f 74 | All of |the brot|
|000006c0| 68 65 72 73 20 6f 66 20 | 74 68 65 0a 20 2a 20 66 |hers of |the. * f|
|000006d0| 69 72 73 74 20 73 6f 6e | 2c 20 69 6e 63 6c 75 64 |irst son|, includ|
|000006e0| 69 6e 67 20 74 68 65 20 | 66 69 72 73 74 20 73 6f |ing the |first so|
|000006f0| 6e 2c 20 68 61 76 65 20 | 74 68 65 20 73 61 6d 65 |n, have |the same|
|00000700| 20 66 61 74 68 65 72 20 | 6e 6f 64 65 2e 0a 20 2a | father |node.. *|
|00000710| 20 54 68 61 74 20 69 73 | 2c 20 69 66 20 77 65 20 | That is|, if we |
|00000720| 68 61 76 65 20 2f 61 2f | 62 2c 20 61 6e 64 20 2f |have /a/|b, and /|
|00000730| 61 2f 63 2c 20 74 68 65 | 6e 20 22 62 22 20 61 6e |a/c, the|n "b" an|
|00000740| 64 20 22 63 22 20 61 72 | 65 20 62 72 6f 74 68 65 |d "c" ar|e brothe|
|00000750| 72 73 2c 0a 20 2a 20 61 | 6e 64 20 22 62 22 27 73 |rs,. * a|nd "b"'s|
|00000760| 20 61 6e 64 20 22 63 22 | 27 73 20 66 61 74 68 65 | and "c"|'s fathe|
|00000770| 72 20 61 72 65 20 62 6f | 74 68 20 22 61 22 2e 20 |r are bo|th "a". |
|00000780| 20 49 20 61 6c 73 6f 20 | 61 64 64 65 64 20 61 20 | I also |added a |
|00000790| 6e 65 77 0a 20 2a 20 76 | 61 72 69 61 62 6c 65 20 |new. * v|ariable |
|000007a0| 22 6d 65 5f 73 69 7a 65 | 22 20 77 68 69 63 68 20 |"me_size|" which |
|000007b0| 69 73 20 74 68 65 20 73 | 69 7a 65 20 6f 66 20 74 |is the s|ize of t|
|000007c0| 68 65 20 64 69 72 65 63 | 74 6f 72 79 2c 20 6e 6f |he direc|tory, no|
|000007d0| 74 20 69 6e 63 6c 75 64 | 69 6e 67 0a 20 2a 20 74 |t includ|ing. * t|
|000007e0| 68 65 20 73 69 7a 65 73 | 20 6f 66 20 74 68 65 20 |he sizes| of the |
|000007f0| 73 6f 6e 73 20 69 6d 6d | 65 64 69 61 74 65 6c 79 |sons imm|ediately|
|00000800| 20 62 65 6c 6f 77 20 69 | 74 2e 0a 20 2a 0a 20 2a | below i|t.. *. *|
|00000810| 20 4e 4f 54 45 3a 20 49 | 66 20 79 6f 75 20 64 6f | NOTE: I|f you do|
|00000820| 20 22 64 75 20 2f 64 69 | 72 31 2f 64 69 72 32 2f | "du /di|r1/dir2/|
|00000830| 64 69 72 33 7c 20 64 75 | 6f 6e 6c 79 22 2c 20 74 |dir3| du|only", t|
|00000840| 68 65 6e 20 74 68 65 20 | 73 69 7a 65 20 6f 66 0a |hen the |size of.|
|00000850| 20 2a 20 2f 64 69 72 31 | 2c 20 61 6e 64 20 2f 64 | * /dir1|, and /d|
|00000860| 69 72 32 20 77 69 6c 6c | 20 62 65 20 30 2c 20 73 |ir2 will| be 0, s|
|00000870| 69 6e 63 65 20 74 68 65 | 79 20 77 65 72 65 20 4e |ince the|y were N|
|00000880| 4f 54 20 69 6e 63 6c 75 | 64 65 64 20 69 6e 0a 20 |OT inclu|ded in. |
|00000890| 2a 20 74 68 65 20 6f 72 | 69 67 69 6e 61 6c 20 6f |* the or|iginal o|
|000008a0| 75 74 70 75 74 20 6f 66 | 20 64 75 21 21 21 0a 20 |utput of| du!!!. |
|000008b0| 2a 0a 20 2a 20 4e 4f 54 | 45 3a 20 69 66 20 79 6f |*. * NOT|E: if yo|
|000008c0| 75 20 64 6f 20 22 64 75 | 20 2f 64 69 72 31 2f 64 |u do "du| /dir1/d|
|000008d0| 69 72 32 2f 64 69 72 33 | 7c 20 64 75 6f 6e 6c 79 |ir2/dir3|| duonly|
|000008e0| 22 2c 20 74 68 65 6e 20 | 74 68 65 20 72 6f 6f 74 |", then |the root|
|000008f0| 0a 20 2a 20 70 6c 61 63 | 65 68 6f 6c 64 65 72 20 |. * plac|eholder |
|00000900| 70 6f 69 6e 74 73 20 74 | 6f 20 61 20 63 65 6c 6c |points t|o a cell|
|00000910| 20 66 6f 72 20 22 22 2c | 20 61 6e 64 20 4e 4f 54 | for "",| and NOT|
|00000920| 20 74 6f 20 22 64 69 72 | 31 22 20 61 73 0a 20 2a | to "dir|1" as. *|
|00000930| 20 79 6f 75 20 6d 69 67 | 68 74 20 65 78 70 65 63 | you mig|ht expec|
|00000940| 74 2e 20 20 54 68 69 73 | 20 69 73 20 62 65 63 61 |t. This| is beca|
|00000950| 75 73 65 20 6f 66 20 68 | 6f 77 20 72 65 61 64 5f |use of h|ow read_|
|00000960| 69 6e 70 75 74 28 29 20 | 70 61 72 73 65 73 0a 20 |input() |parses. |
|00000970| 2a 20 69 74 73 20 69 6e | 70 75 74 2e 20 20 49 74 |* its in|put. It|
|00000980| 20 69 73 20 6e 6f 74 20 | 61 20 70 72 6f 62 6c 65 | is not |a proble|
|00000990| 6d 20 70 65 72 20 73 65 | 2c 20 65 78 63 65 70 74 |m per se|, except|
|000009a0| 20 74 68 61 74 20 74 68 | 65 20 6e 6f 64 65 0a 20 | that th|e node. |
|000009b0| 2a 20 63 6f 6e 74 61 69 | 6e 69 6e 67 20 61 20 62 |* contai|ning a b|
|000009c0| 6c 61 6e 6b 20 6e 61 6d | 65 20 73 68 6f 75 6c 64 |lank nam|e should|
|000009d0| 20 6e 6f 74 20 62 65 20 | 70 72 69 6e 74 65 64 20 | not be |printed |
|000009e0| 69 6e 20 74 68 69 73 20 | 63 61 73 65 2e 0a 20 2a |in this |case.. *|
|000009f0| 20 53 6f 2c 20 74 68 65 | 20 73 6f 6c 75 74 69 6f | So, the| solutio|
|00000a00| 6e 20 69 73 20 74 6f 20 | 61 64 64 20 61 6e 20 65 |n is to |add an e|
|00000a10| 78 74 72 61 20 63 68 65 | 63 6b 20 61 6e 64 20 61 |xtra che|ck and a|
|00000a20| 76 6f 69 64 20 74 68 65 | 20 70 72 69 6e 74 0a 20 |void the| print. |
|00000a30| 2a 20 77 68 65 6e 20 74 | 68 65 20 6e 61 6d 65 20 |* when t|he name |
|00000a40| 69 73 20 22 22 2e 20 20 | 42 79 20 74 68 65 20 77 |is "". |By the w|
|00000a50| 61 79 20 74 68 65 20 72 | 6f 6f 74 20 66 6f 72 20 |ay the r|oot for |
|00000a60| 22 22 20 6f 6e 6c 79 20 | 6f 63 63 75 72 73 0a 20 |"" only |occurs. |
|00000a70| 2a 20 62 65 63 61 75 73 | 65 20 74 68 65 20 70 61 |* becaus|e the pa|
|00000a80| 74 68 6e 61 6d 65 73 20 | 61 72 65 20 61 62 73 6f |thnames |are abso|
|00000a90| 6c 75 74 65 20 28 62 65 | 67 69 6e 20 77 69 74 68 |lute (be|gin with|
|00000aa0| 20 61 20 2f 29 2e 0a 20 | 2a 0a 20 2a 20 4e 4f 54 | a /).. |*. * NOT|
|00000ab0| 45 3a 20 61 6c 74 68 6f | 75 67 68 20 6f 75 74 70 |E: altho|ugh outp|
|00000ac0| 75 74 20 6f 66 20 64 69 | 72 65 63 74 6f 72 79 20 |ut of di|rectory |
|00000ad0| 6e 61 6d 65 73 20 61 72 | 65 20 73 6f 72 74 65 64 |names ar|e sorted|
|00000ae0| 20 74 68 65 72 65 20 69 | 73 0a 20 2a 20 6f 6e 65 | there i|s. * one|
|00000af0| 20 6d 69 6e 6f 72 20 61 | 6e 6f 6d 6f 6c 79 20 74 | minor a|nomoly t|
|00000b00| 68 61 74 20 6f 63 63 75 | 72 73 20 77 68 65 6e 20 |hat occu|rs when |
|00000b10| 79 6f 75 20 68 61 76 65 | 20 69 6e 70 75 74 20 61 |you have| input a|
|00000b20| 73 20 66 6f 6c 6c 6f 77 | 73 0a 20 2a 20 28 73 69 |s follow|s. * (si|
|00000b30| 7a 65 73 20 6f 6d 6d 69 | 74 65 64 2c 20 73 69 6e |zes ommi|ted, sin|
|00000b40| 63 65 20 69 72 72 65 6c | 65 76 61 6e 74 29 3a 0a |ce irrel|evant):.|
|00000b50| 20 2a 20 2e 2e 2f 64 69 | 72 0a 20 2a 20 2e 2e 2e | * ../di|r. * ...|
|00000b60| 64 69 72 2f 52 43 53 0a | 20 2a 20 2e 2e 2e 64 69 |dir/RCS.| * ...di|
|00000b70| 72 2e 65 78 74 0a 20 2a | 20 54 68 65 20 69 6d 70 |r.ext. *| The imp|
|00000b80| 6f 72 74 61 6e 74 20 70 | 6f 69 6e 74 20 69 73 20 |ortant p|oint is |
|00000b90| 74 68 61 74 20 77 65 20 | 68 61 76 65 20 62 6f 74 |that we |have bot|
|00000ba0| 68 20 61 20 22 2f 22 20 | 61 6e 64 20 61 20 22 2e |h a "/" |and a ".|
|00000bb0| 22 20 61 66 74 65 72 20 | 74 68 65 0a 20 2a 20 73 |" after |the. * s|
|00000bc0| 61 6d 65 20 6e 61 6d 65 | 20 22 64 69 72 22 2e 0a |ame name| "dir"..|
|00000bd0| 20 2a 20 41 20 73 6f 72 | 74 20 77 6f 75 6c 64 20 | * A sor|t would |
|00000be0| 70 6c 61 63 65 20 74 68 | 65 20 22 2e 22 20 62 65 |place th|e "." be|
|00000bf0| 66 6f 72 65 20 74 68 65 | 20 22 2f 22 20 28 69 65 |fore the| "/" (ie|
|00000c00| 20 6c 69 6e 65 20 33 20 | 62 65 66 6f 72 65 20 6c | line 3 |before l|
|00000c10| 69 6e 65 20 32 29 2c 0a | 20 2a 20 62 75 74 20 74 |ine 2),.| * but t|
|00000c20| 68 65 20 73 6f 72 74 20 | 70 65 72 66 6f 72 6d 65 |he sort |performe|
|00000c30| 64 20 62 79 20 64 75 20 | 69 73 20 6f 6e 6c 79 20 |d by du |is only |
|00000c40| 77 69 74 68 69 6e 20 65 | 61 63 68 20 64 69 72 65 |within e|ach dire|
|00000c50| 63 74 6f 72 79 20 6c 65 | 76 65 6c 2c 20 73 6f 0a |ctory le|vel, so.|
|00000c60| 20 2a 20 74 68 61 74 20 | 64 75 6f 6e 6c 79 20 77 | * that |duonly w|
|00000c70| 6f 75 6c 64 20 6f 75 74 | 70 75 74 20 6c 69 6e 65 |ould out|put line|
|00000c80| 20 32 20 62 65 66 6f 72 | 65 20 6c 69 6e 65 20 33 | 2 befor|e line 3|
|00000c90| 20 28 73 69 6e 63 65 20 | 2e 2e 2f 64 69 72 20 61 | (since |../dir a|
|00000ca0| 6e 64 0a 20 2a 20 2e 2e | 2f 64 69 72 2e 65 78 74 |nd. * ..|/dir.ext|
|00000cb0| 20 61 72 65 20 73 6f 72 | 74 65 64 20 62 72 6f 74 | are sor|ted brot|
|00000cc0| 68 65 72 73 2c 20 61 6e | 64 20 2e 2e 2f 64 69 72 |hers, an|d ../dir|
|00000cd0| 2f 52 43 53 20 69 73 20 | 61 20 73 6f 72 74 65 64 |/RCS is |a sorted|
|00000ce0| 20 73 6f 6e 20 6f 66 0a | 20 2a 20 2e 2e 2f 64 69 | son of.| * ../di|
|00000cf0| 72 29 20 21 21 0a 20 2a | 0a 20 2a 2f 0a 23 69 66 |r) !!. *|. */.#if|
|00000d00| 20 30 0a 50 61 74 68 3a | 20 72 6c 67 76 61 78 21 | 0.Path:| rlgvax!|
|00000d10| 73 75 6e 64 63 21 73 65 | 69 73 6d 6f 21 75 75 6e |sundc!se|ismo!uun|
|00000d20| 65 74 21 68 75 73 63 36 | 21 74 68 69 6e 6b 21 61 |et!husc6|!think!a|
|00000d30| 6d 65 73 21 6e 65 63 6e | 74 63 21 6e 63 6f 61 73 |mes!necn|tc!ncoas|
|00000d40| 74 21 61 6c 6c 62 65 72 | 79 0a 46 72 6f 6d 3a 20 |t!allber|y.From: |
|00000d50| 64 72 77 40 63 75 6c 64 | 65 76 31 2e 55 55 43 50 |drw@culd|ev1.UUCP|
|00000d60| 20 28 44 61 6c 65 20 57 | 6f 72 6c 65 79 29 0a 4e | (Dale W|orley).N|
|00000d70| 65 77 73 67 72 6f 75 70 | 73 3a 20 63 6f 6d 70 2e |ewsgroup|s: comp.|
|00000d80| 73 6f 75 72 63 65 73 2e | 6d 69 73 63 0a 53 75 62 |sources.|misc.Sub|
|00000d90| 6a 65 63 74 3a 20 50 72 | 65 74 74 79 70 72 69 6e |ject: Pr|ettyprin|
|00000da0| 74 20 61 20 64 75 20 6c | 69 73 74 69 6e 67 0a 4d |t a du l|isting.M|
|00000db0| 65 73 73 61 67 65 2d 49 | 44 3a 20 3c 36 38 30 33 |essage-I|D: <6803|
|00000dc0| 40 6e 63 6f 61 73 74 2e | 55 55 43 50 3e 0a 44 61 |@ncoast.|UUCP>.Da|
|00000dd0| 74 65 3a 20 31 37 20 44 | 65 63 20 38 37 20 30 32 |te: 17 D|ec 87 02|
|00000de0| 3a 33 33 3a 35 34 20 47 | 4d 54 0a 53 65 6e 64 65 |:33:54 G|MT.Sende|
|00000df0| 72 3a 20 61 6c 6c 62 65 | 72 79 40 6e 63 6f 61 73 |r: allbe|ry@ncoas|
|00000e00| 74 2e 55 55 43 50 0a 4f | 72 67 61 6e 69 7a 61 74 |t.UUCP.O|rganizat|
|00000e10| 69 6f 6e 3a 20 43 75 6c | 6c 69 6e 65 74 20 53 6f |ion: Cul|linet So|
|00000e20| 66 74 77 61 72 65 2c 20 | 57 65 73 74 77 6f 6f 64 |ftware, |Westwood|
|00000e30| 2c 20 4d 41 2c 20 55 53 | 41 0a 4c 69 6e 65 73 3a |, MA, US|A.Lines:|
|00000e40| 20 34 34 37 0a 41 70 70 | 72 6f 76 65 64 3a 20 61 | 447.App|roved: a|
|00000e50| 6c 6c 62 65 72 79 40 6e | 63 6f 61 73 74 2e 55 55 |llbery@n|coast.UU|
|00000e60| 43 50 0a 58 2d 41 72 63 | 68 69 76 65 3a 20 63 6f |CP.X-Arc|hive: co|
|00000e70| 6d 70 2e 73 6f 75 72 63 | 65 73 2e 6d 69 73 63 2f |mp.sourc|es.misc/|
|00000e80| 38 37 31 32 2f 38 0a 0a | 49 27 76 65 20 61 6c 77 |8712/8..|I've alw|
|00000e90| 61 79 73 20 77 61 6e 74 | 65 64 20 74 6f 20 67 65 |ays want|ed to ge|
|00000ea0| 74 20 61 20 64 75 20 6c | 69 73 74 69 6e 67 20 74 |t a du l|isting t|
|00000eb0| 68 61 74 20 73 68 6f 77 | 73 20 68 6f 77 20 74 68 |hat show|s how th|
|00000ec0| 65 20 73 70 61 63 65 20 | 69 73 0a 62 65 69 6e 67 |e space |is.being|
|00000ed0| 20 75 73 65 64 20 67 72 | 61 70 68 69 63 61 6c 6c | used gr|aphicall|
|00000ee0| 79 2e 20 20 49 20 66 69 | 6e 61 6c 6c 79 20 77 72 |y. I fi|nally wr|
|00000ef0| 6f 74 65 20 61 20 70 72 | 6f 67 72 61 6d 20 74 6f |ote a pr|ogram to|
|00000f00| 20 64 69 67 65 73 74 20 | 61 20 64 75 0a 6c 69 73 | digest |a du.lis|
|00000f10| 74 69 6e 67 20 61 6e 64 | 20 70 72 69 6e 74 20 6f |ting and| print o|
|00000f20| 75 74 20 61 20 74 72 65 | 65 2c 20 77 68 65 72 65 |ut a tre|e, where|
|00000f30| 20 65 61 63 68 20 64 69 | 72 65 63 74 6f 72 79 20 | each di|rectory |
|00000f40| 6f 63 63 75 70 69 65 73 | 20 6c 69 6e 65 73 0a 70 |occupies| lines.p|
|00000f50| 72 6f 70 6f 72 74 69 6f | 6e 61 6c 6c 79 20 74 6f |roportio|nally to|
|00000f60| 20 68 6f 77 20 6d 75 63 | 68 20 73 70 61 63 65 20 | how muc|h space |
|00000f70| 74 68 65 20 66 69 6c 65 | 73 20 69 6e 20 69 74 20 |the file|s in it |
|00000f80| 63 6f 6e 73 75 6d 65 2e | 0a 0a 54 6f 20 72 75 6e |consume.|..To run|
|00000f90| 20 69 74 2c 20 74 79 70 | 65 20 22 64 75 20 7c 20 | it, typ|e "du | |
|00000fa0| 64 75 67 72 61 70 68 22 | 20 6f 72 20 73 6f 6d 65 |dugraph"| or some|
|00000fb0| 20 73 75 63 68 2e 20 20 | 54 68 65 20 6c 69 73 74 | such. |The list|
|00000fc0| 69 6e 67 20 66 6f 72 20 | 65 61 63 68 0a 64 69 72 |ing for |each.dir|
|00000fd0| 65 63 74 6f 72 79 20 73 | 74 61 72 74 73 20 77 69 |ectory s|tarts wi|
|00000fe0| 74 68 20 61 20 62 6c 61 | 6e 6b 20 73 70 61 63 65 |th a bla|nk space|
|00000ff0| 20 73 68 6f 77 69 6e 67 | 20 73 70 61 63 65 20 6f | showing| space o|
|00001000| 63 63 75 70 69 65 64 20 | 62 79 20 66 69 6c 65 73 |ccupied |by files|
|00001010| 0a 64 69 72 65 63 74 6c | 79 20 69 6e 20 74 68 61 |.directl|y in tha|
|00001020| 74 20 64 69 72 65 63 74 | 6f 72 79 2c 20 74 68 65 |t direct|ory, the|
|00001030| 6e 20 74 68 65 20 73 75 | 62 74 72 65 65 73 20 66 |n the su|btrees f|
|00001040| 6f 72 20 65 61 63 68 20 | 73 75 62 64 69 72 65 63 |or each |subdirec|
|00001050| 74 6f 72 79 0a 28 69 6e | 20 64 65 73 63 65 6e 64 |tory.(in| descend|
|00001060| 69 6e 67 20 6f 72 64 65 | 72 20 6f 66 20 73 69 7a |ing orde|r of siz|
|00001070| 65 29 2e 20 20 49 66 20 | 74 68 65 20 73 75 62 64 |e). If |the subd|
|00001080| 69 72 65 63 74 6f 72 69 | 65 73 20 61 74 20 74 68 |irectori|es at th|
|00001090| 65 20 62 6f 74 74 6f 6d | 0a 67 65 74 20 73 6f 20 |e bottom|.get so |
|000010a0| 73 6d 61 6c 6c 20 74 68 | 61 74 20 74 68 65 79 20 |small th|at they |
|000010b0| 6f 63 63 75 70 79 20 6c | 65 73 73 20 74 68 61 6e |occupy l|ess than|
|000010c0| 20 31 20 6c 69 6e 65 20 | 65 61 63 68 2c 20 74 68 | 1 line |each, th|
|000010d0| 65 79 20 61 72 65 20 61 | 6c 6c 0a 6d 65 72 67 65 |ey are a|ll.merge|
|000010e0| 64 20 69 6e 74 6f 20 61 | 6e 20 65 6e 74 72 79 20 |d into a|n entry |
|000010f0| 22 28 65 74 63 2e 29 22 | 2e 0a 0a 54 68 65 20 65 |"(etc.)"|...The e|
|00001100| 6e 74 69 72 65 20 6c 69 | 73 74 69 6e 67 20 61 6c |ntire li|sting al|
|00001110| 77 61 79 73 20 6f 63 63 | 75 70 69 65 73 20 36 30 |ways occ|upies 60|
|00001120| 20 6c 69 6e 65 73 20 28 | 74 68 65 20 76 61 6c 75 | lines (|the valu|
|00001130| 65 20 6f 66 20 27 6c 65 | 6e 67 74 68 27 29 2e 0a |e of 'le|ngth')..|
|00001140| 54 68 69 73 20 70 72 6f | 67 72 61 6d 20 68 61 73 |This pro|gram has|
|00001150| 20 74 61 62 2d 77 69 64 | 74 68 20 3d 20 35 2e 0a | tab-wid|th = 5..|
|00001160| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00001170| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 64 75 67 72 61 70 |--------|--dugrap|
|00001180| 68 2e 63 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |h.c-----|--------|
|00001190| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000011a0| 2d 2d 2d 2d 0a 23 65 6e | 64 69 66 0a 2f 2a 20 70 |----.#en|dif./* p|
|000011b0| 72 6f 67 72 61 6d 20 74 | 6f 20 6d 61 6b 65 20 61 |rogram t|o make a|
|000011c0| 20 70 72 65 74 74 79 20 | 67 72 61 70 68 20 6f 75 | pretty |graph ou|
|000011d0| 74 20 6f 66 20 61 20 64 | 75 20 72 65 70 6f 72 74 |t of a d|u report|
|000011e0| 20 2a 2f 0a 0a 23 69 6e | 63 6c 75 64 65 20 3c 73 | */..#in|clude <s|
|000011f0| 74 64 69 6f 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |tdio.h>.|#include|
|00001200| 20 3c 73 74 72 69 6e 67 | 2e 68 3e 0a 0a 2f 2a 20 | <string|.h>../* |
|00001210| 6e 75 6d 62 65 72 20 6f | 66 20 6c 69 6e 65 73 20 |number o|f lines |
|00001220| 74 68 65 20 6c 69 73 74 | 69 6e 67 20 73 68 6f 75 |the list|ing shou|
|00001230| 6c 64 20 6f 63 63 75 70 | 79 20 2a 2f 0a 69 6e 74 |ld occup|y */.int|
|00001240| 09 6c 65 6e 67 74 68 20 | 3d 20 36 30 3b 0a 2f 2a |.length |= 60;./*|
|00001250| 20 6d 65 73 73 61 67 65 | 20 66 6f 72 20 73 75 70 | message| for sup|
|00001260| 70 72 65 73 73 65 64 20 | 64 69 72 65 63 74 6f 72 |pressed |director|
|00001270| 69 65 73 20 2a 2f 0a 23 | 64 65 66 69 6e 65 09 53 |ies */.#|define.S|
|00001280| 55 50 50 52 45 53 53 45 | 44 09 22 28 65 74 63 2e |UPPRESSE|D."(etc.|
|00001290| 29 22 0a 0a 2f 2a 20 66 | 6f 72 6d 61 74 20 6f 66 |)"../* f|ormat of|
|000012a0| 20 61 20 74 72 65 65 20 | 6e 6f 64 65 20 2a 2f 0a | a tree |node */.|
|000012b0| 73 74 72 75 63 74 20 6e | 6f 64 65 20 7b 0a 09 09 |struct n|ode {...|
|000012c0| 09 73 74 72 75 63 74 20 | 6e 6f 64 65 09 2a 6c 73 |.struct |node.*ls|
|000012d0| 6f 6e 3b 09 2f 2a 20 6c | 65 66 74 20 73 6f 6e 20 |on;./* l|eft son |
|000012e0| 2a 2f 0a 09 09 09 73 74 | 72 75 63 74 20 6e 6f 64 |*/....st|ruct nod|
|000012f0| 65 09 2a 72 62 72 6f 74 | 68 65 72 3b 2f 2a 20 72 |e.*rbrot|her;/* r|
|00001300| 69 67 68 74 20 62 72 6f | 74 68 65 72 20 2a 2f 0a |ight bro|ther */.|
|00001310| 09 09 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |...struc|t node.*|
|00001320| 66 61 74 68 65 72 3b 20 | 2f 2a 20 70 61 72 65 6e |father; |/* paren|
|00001330| 74 20 6e 6f 64 65 2c 20 | 75 70 20 70 74 72 20 2a |t node, |up ptr *|
|00001340| 2f 0a 09 09 09 75 6e 73 | 69 67 6e 65 64 20 6c 6f |/....uns|igned lo|
|00001350| 6e 67 09 73 69 7a 65 3b | 09 2f 2a 20 73 69 7a 65 |ng.size;|./* size|
|00001360| 20 6f 66 20 64 69 72 65 | 63 74 6f 72 79 20 69 6e | of dire|ctory in|
|00001370| 20 6b 62 79 74 65 73 20 | 2a 2f 0a 09 09 09 75 6e | kbytes |*/....un|
|00001380| 73 69 67 6e 65 64 20 6c | 6f 6e 67 09 6d 65 5f 73 |signed l|ong.me_s|
|00001390| 69 7a 65 3b 09 2f 2a 20 | 73 69 7a 65 20 6f 66 20 |ize;./* |size of |
|000013a0| 64 69 72 65 63 74 6f 72 | 79 20 6f 6e 6c 79 20 2a |director|y only *|
|000013b0| 2f 0a 09 09 09 69 6e 74 | 09 09 09 6c 6f 63 3b 09 |/....int|...loc;.|
|000013c0| 09 2f 2a 20 6c 6f 63 61 | 74 69 6f 6e 20 77 65 20 |./* loca|tion we |
|000013d0| 77 69 6c 6c 20 70 72 69 | 6e 74 20 69 74 20 61 74 |will pri|nt it at|
|000013e0| 20 2a 2f 0a 09 09 09 69 | 6e 74 09 09 09 70 72 69 | */....i|nt...pri|
|000013f0| 6e 74 5f 63 6f 6c 3b 2f | 2a 20 63 6f 6c 75 6d 6e |nt_col;/|* column|
|00001400| 20 74 6f 20 70 72 69 6e | 74 20 6e 61 6d 65 20 69 | to prin|t name i|
|00001410| 6e 20 2a 2f 0a 09 09 09 | 69 6e 74 09 09 09 70 72 |n */....|int...pr|
|00001420| 69 6e 74 5f 6c 69 6d 69 | 74 3b 0a 09 09 09 09 09 |int_limi|t;......|
|00001430| 09 09 09 2f 2a 20 6c 6f | 63 61 74 69 6f 6e 20 77 |.../* lo|cation w|
|00001440| 65 20 63 61 6e 27 74 20 | 70 72 69 6e 74 20 6f 6e |e can't |print on|
|00001450| 20 6f 72 0a 09 09 09 09 | 09 09 09 09 20 2a 20 61 | or.....|.... * a|
|00001460| 66 74 65 72 20 2a 2f 0a | 09 09 09 69 6e 74 09 09 |fter */.|...int..|
|00001470| 09 6c 61 73 74 3b 09 2f | 2a 20 61 72 65 20 77 65 |.last;./|* are we|
|00001480| 20 6c 61 73 74 20 73 6f | 6e 20 6f 66 20 6f 75 72 | last so|n of our|
|00001490| 20 66 61 74 68 65 72 3f | 20 2a 2f 0a 09 09 09 63 | father?| */....c|
|000014a0| 68 61 72 09 09 09 6e 61 | 6d 65 5b 31 5d 3b 09 2f |har...na|me[1];./|
|000014b0| 2a 20 6e 61 6d 65 20 2a | 2f 0a 09 09 20 20 7d 3b |* name *|/... };|
|000014c0| 0a 0a 2f 2a 20 72 6f 6f | 74 20 6f 66 20 74 68 65 |../* roo|t of the|
|000014d0| 20 74 72 65 65 20 2a 2f | 0a 73 74 72 75 63 74 20 | tree */|.struct |
|000014e0| 6e 6f 64 65 09 2a 72 6f | 6f 74 20 3d 20 4e 55 4c |node.*ro|ot = NUL|
|000014f0| 4c 3b 0a 2f 2a 20 74 6f | 74 61 6c 20 73 69 7a 65 |L;./* to|tal size|
|00001500| 20 6f 66 20 74 68 69 6e | 67 73 20 6c 69 73 74 65 | of thin|gs liste|
|00001510| 64 20 2a 2f 0a 75 6e 73 | 69 67 6e 65 64 20 6c 6f |d */.uns|igned lo|
|00001520| 6e 67 09 74 6f 74 61 6c | 5f 73 69 7a 65 3b 0a 2f |ng.total|_size;./|
|00001530| 2a 20 63 75 72 72 65 6e | 74 20 6c 69 6e 65 20 6e |* curren|t line n|
|00001540| 75 6d 62 65 72 20 77 65 | 20 61 72 65 20 6f 6e 20 |umber we| are on |
|00001550| 28 30 2d 6f 72 69 67 69 | 6e 29 20 2a 2f 0a 69 6e |(0-origi|n) */.in|
|00001560| 74 09 09 09 63 75 72 72 | 65 6e 74 5f 6c 69 6e 65 |t...curr|ent_line|
|00001570| 20 3d 20 30 3b 0a 2f 2a | 20 6c 69 73 74 20 6f 66 | = 0;./*| list of|
|00001580| 20 77 68 65 72 65 20 74 | 6f 20 70 75 74 20 62 61 | where t|o put ba|
|00001590| 72 73 20 2a 2f 0a 69 6e | 74 09 09 09 62 61 72 5f |rs */.in|t...bar_|
|000015a0| 6c 69 73 74 5b 35 30 5d | 3b 0a 2f 2a 20 6e 75 6d |list[50]|;./* num|
|000015b0| 62 65 72 20 6f 66 20 62 | 61 72 73 20 69 6e 20 74 |ber of b|ars in t|
|000015c0| 68 65 20 6c 69 73 74 20 | 2a 2f 0a 69 6e 74 09 09 |he list |*/.int..|
|000015d0| 09 62 61 72 5f 63 6f 75 | 6e 74 20 3d 20 30 3b 0a |.bar_cou|nt = 0;.|
|000015e0| 0a 2f 2a 20 64 65 63 6c | 61 72 65 20 66 75 6e 63 |./* decl|are func|
|000015f0| 74 69 6f 6e 73 20 2a 2f | 0a 76 6f 69 64 09 09 09 |tions */|.void...|
|00001600| 72 65 61 64 5f 69 6e 70 | 75 74 28 29 3b 0a 73 74 |read_inp|ut();.st|
|00001610| 72 75 63 74 20 6e 6f 64 | 65 09 2a 69 6e 73 65 72 |ruct nod|e.*inser|
|00001620| 74 5f 69 6e 5f 74 72 65 | 65 28 29 3b 0a 76 6f 69 |t_in_tre|e();.voi|
|00001630| 64 09 09 09 64 66 73 28 | 29 3b 0a 76 6f 69 64 09 |d...dfs(|);.void.|
|00001640| 09 09 64 66 73 31 28 29 | 3b 0a 76 6f 69 64 09 09 |..dfs1()|;.void..|
|00001650| 09 6d 69 73 73 69 6e 67 | 5f 73 69 7a 65 73 28 29 |.missing|_sizes()|
|00001660| 3b 0a 76 6f 69 64 09 09 | 09 73 6f 72 74 5f 73 69 |;.void..|.sort_si|
|00001670| 7a 65 28 29 3b 09 2f 2a | 20 73 6f 72 74 20 74 72 |ze();./*| sort tr|
|00001680| 65 65 20 62 79 20 73 69 | 7a 65 20 2a 2f 0a 76 6f |ee by si|ze */.vo|
|00001690| 69 64 09 09 09 73 6f 72 | 74 5f 6e 61 6d 65 28 29 |id...sor|t_name()|
|000016a0| 3b 09 2f 2a 20 73 6f 72 | 74 20 74 72 65 65 20 61 |;./* sor|t tree a|
|000016b0| 6c 70 68 61 62 65 74 69 | 63 61 6c 6c 79 20 2a 2f |lphabeti|cally */|
|000016c0| 0a 76 6f 69 64 09 09 09 | 63 61 6c 63 5f 6c 6f 63 |.void...|calc_loc|
|000016d0| 28 29 3b 0a 76 6f 69 64 | 09 09 09 62 6c 61 6e 6b |();.void|...blank|
|000016e0| 28 29 3b 0a 76 6f 69 64 | 09 09 09 6d 61 72 6b 5f |();.void|...mark_|
|000016f0| 6c 61 73 74 28 29 3b 0a | 76 6f 69 64 09 09 09 63 |last();.|void...c|
|00001700| 61 6c 63 5f 70 63 28 29 | 3b 0a 76 6f 69 64 09 09 |alc_pc()|;.void..|
|00001710| 09 6f 75 74 70 75 74 28 | 29 3b 0a 76 6f 69 64 09 |.output(|);.void.|
|00001720| 09 09 70 6f 73 69 74 69 | 6f 6e 28 29 3b 0a 76 6f |..positi|on();.vo|
|00001730| 69 64 09 09 09 73 68 6f | 77 5f 6e 6f 64 65 28 29 |id...sho|w_node()|
|00001740| 3b 0a 76 6f 69 64 09 09 | 09 6d 79 5f 73 70 61 63 |;.void..|.my_spac|
|00001750| 65 28 29 3b 0a 0a 6d 61 | 69 6e 28 29 0a 09 7b 0a |e();..ma|in()..{.|
|00001760| 09 73 74 72 75 63 74 20 | 6e 6f 64 65 09 2a 74 3b |.struct |node.*t;|
|00001770| 09 2f 2a 20 73 63 72 61 | 74 63 68 20 2a 2f 0a 0a |./* scra|tch */..|
|00001780| 09 2f 2a 20 72 65 61 64 | 20 74 68 65 20 69 6e 70 |./* read| the inp|
|00001790| 75 74 20 61 6e 64 20 66 | 6f 72 6d 20 61 20 74 72 |ut and f|orm a tr|
|000017a0| 65 65 20 2a 2f 0a 09 72 | 65 61 64 5f 69 6e 70 75 |ee */..r|ead_inpu|
|000017b0| 74 28 29 3b 0a 09 72 6f | 6f 74 2d 3e 73 69 7a 65 |t();..ro|ot->size|
|000017c0| 20 3d 20 30 3b 0a 09 2f | 2a 20 70 75 74 20 73 69 | = 0;../|* put si|
|000017d0| 7a 65 73 20 6f 6e 20 65 | 6e 74 72 69 65 73 20 74 |zes on e|ntries t|
|000017e0| 68 61 74 20 68 61 76 65 | 20 6e 6f 6e 65 20 2a 2f |hat have| none */|
|000017f0| 0a 09 64 66 73 28 4e 55 | 4c 4c 2c 20 6d 69 73 73 |..dfs(NU|LL, miss|
|00001800| 69 6e 67 5f 73 69 7a 65 | 73 29 3b 0a 09 2f 2a 20 |ing_size|s);../* |
|00001810| 73 6f 72 74 20 65 61 63 | 68 20 64 69 72 65 63 74 |sort eac|h direct|
|00001820| 6f 72 79 20 2a 2f 0a 09 | 64 66 73 28 73 6f 72 74 |ory */..|dfs(sort|
|00001830| 5f 6e 61 6d 65 2c 20 4e | 55 4c 4c 29 3b 0a 0a 09 |_name, N|ULL);...|
|00001840| 2f 2a 20 66 6f 72 20 65 | 61 63 68 20 64 69 72 65 |/* for e|ach dire|
|00001850| 63 74 6f 72 79 2c 20 73 | 75 62 74 72 61 63 74 20 |ctory, s|ubtract |
|00001860| 74 68 65 20 73 70 61 63 | 65 20 75 73 65 64 20 75 |the spac|e used u|
|00001870| 70 20 62 79 0a 09 20 2a | 20 61 6c 6c 20 63 68 69 |p by.. *| all chi|
|00001880| 6c 64 72 65 6e 20 6f 6e | 65 20 6c 65 76 65 6c 20 |ldren on|e level |
|00001890| 62 65 6c 6f 77 20 6d 65 | 2c 20 73 6f 20 74 68 61 |below me|, so tha|
|000018a0| 74 20 77 65 0a 09 20 2a | 20 63 61 6e 20 74 65 6c |t we.. *| can tel|
|000018b0| 6c 20 68 6f 77 20 6d 75 | 63 68 20 73 70 61 63 65 |l how mu|ch space|
|000018c0| 20 69 73 20 6f 63 63 75 | 70 69 65 64 20 62 79 20 | is occu|pied by |
|000018d0| 74 68 69 73 0a 09 20 2a | 20 64 69 72 65 63 74 6f |this.. *| directo|
|000018e0| 72 79 20 6f 6e 6c 79 2e | 0a 09 20 2a 20 49 4d 50 |ry only.|.. * IMP|
|000018f0| 4f 52 54 41 4e 54 3a 20 | 57 65 20 6e 65 65 64 20 |ORTANT: |We need |
|00001900| 74 6f 20 63 6f 6d 70 75 | 74 65 20 69 6e 20 70 72 |to compu|te in pr|
|00001910| 65 2d 6f 72 64 65 72 2c | 20 6f 72 20 77 65 0a 09 |e-order,| or we..|
|00001920| 20 2a 20 77 6f 6e 27 74 | 20 67 65 74 20 74 68 65 | * won't| get the|
|00001930| 20 72 69 67 68 74 20 72 | 65 73 75 6c 74 73 2e 0a | right r|esults..|
|00001940| 09 20 2a 2f 0a 09 64 66 | 73 28 6d 79 5f 73 70 61 |. */..df|s(my_spa|
|00001950| 63 65 2c 20 4e 55 4c 4c | 29 3b 0a 0a 09 2f 2a 20 |ce, NULL|);.../* |
|00001960| 70 72 69 6e 74 20 74 68 | 65 20 74 72 65 65 20 2a |print th|e tree *|
|00001970| 2f 0a 09 64 66 73 28 73 | 68 6f 77 5f 6e 6f 64 65 |/..dfs(s|how_node|
|00001980| 2c 20 4e 55 4c 4c 29 3b | 0a 09 65 78 69 74 28 30 |, NULL);|..exit(0|
|00001990| 29 3b 0a 0a 09 2f 2a 20 | 75 6e 75 73 65 64 20 6c |);.../* |unused l|
|000019a0| 65 66 74 2d 6f 76 65 72 | 20 63 6f 64 65 20 49 20 |eft-over| code I |
|000019b0| 6d 69 67 68 74 20 6e 65 | 65 64 20 6c 61 74 65 72 |might ne|ed later|
|000019c0| 2e 20 2a 2f 0a 0a 09 2f | 2a 20 63 61 6c 63 75 6c |. */.../|* calcul|
|000019d0| 61 74 65 20 74 68 65 20 | 74 6f 74 61 6c 20 73 69 |ate the |total si|
|000019e0| 7a 65 20 2a 2f 0a 09 74 | 6f 74 61 6c 5f 73 69 7a |ze */..t|otal_siz|
|000019f0| 65 20 3d 20 30 3b 0a 09 | 66 6f 72 20 28 74 20 3d |e = 0;..|for (t =|
|00001a00| 20 72 6f 6f 74 2d 3e 6c | 73 6f 6e 3b 20 74 20 21 | root->l|son; t !|
|00001a10| 3d 20 4e 55 4c 4c 3b 20 | 74 20 3d 20 74 2d 3e 72 |= NULL; |t = t->r|
|00001a20| 62 72 6f 74 68 65 72 29 | 0a 09 09 74 6f 74 61 6c |brother)|...total|
|00001a30| 5f 73 69 7a 65 20 2b 3d | 20 74 2d 3e 73 69 7a 65 |_size +=| t->size|
|00001a40| 3b 0a 09 2f 2a 20 63 61 | 6c 63 75 6c 61 74 65 20 |;../* ca|lculate |
|00001a50| 74 68 65 20 6c 6f 63 61 | 74 69 6f 6e 20 6f 66 20 |the loca|tion of |
|00001a60| 65 61 63 68 20 64 69 72 | 65 63 74 6f 72 79 20 2a |each dir|ectory *|
|00001a70| 2f 0a 09 2f 2a 20 62 6c | 61 6e 6b 20 6f 75 74 20 |/../* bl|ank out |
|00001a80| 73 75 62 64 69 72 65 63 | 74 6f 72 69 65 73 20 74 |subdirec|tories t|
|00001a90| 68 61 74 20 67 65 74 20 | 73 63 72 75 6e 63 68 65 |hat get |scrunche|
|00001aa0| 64 20 74 6f 67 65 74 68 | 65 72 20 61 74 20 74 68 |d togeth|er at th|
|00001ab0| 65 20 62 6f 74 74 6f 6d | 20 2a 2f 0a 09 72 6f 6f |e bottom| */..roo|
|00001ac0| 74 2d 3e 70 72 69 6e 74 | 5f 6c 69 6d 69 74 20 3d |t->print|_limit =|
|00001ad0| 20 6c 65 6e 67 74 68 3b | 0a 09 64 66 73 28 63 61 | length;|..dfs(ca|
|00001ae0| 6c 63 5f 6c 6f 63 2c 20 | 62 6c 61 6e 6b 29 3b 0a |lc_loc, |blank);.|
|00001af0| 09 2f 2a 20 70 72 69 6e | 74 20 6f 75 74 20 74 68 |./* prin|t out th|
|00001b00| 65 20 74 72 65 65 20 2a | 2f 0a 09 66 6f 72 20 28 |e tree *|/..for (|
|00001b10| 74 20 3d 20 72 6f 6f 74 | 2d 3e 6c 73 6f 6e 3b 20 |t = root|->lson; |
|00001b20| 74 20 21 3d 20 4e 55 4c | 4c 3b 20 74 20 3d 20 74 |t != NUL|L; t = t|
|00001b30| 2d 3e 72 62 72 6f 74 68 | 65 72 29 0a 09 09 7b 0a |->rbroth|er)...{.|
|00001b40| 09 09 2f 2a 20 6d 61 72 | 6b 20 74 68 65 20 6c 61 |../* mar|k the la|
|00001b50| 73 74 20 73 6f 6e 20 6f | 66 20 65 61 63 68 20 64 |st son o|f each d|
|00001b60| 69 72 65 63 74 6f 72 79 | 20 2a 2f 0a 09 09 2f 2a |irectory| */.../*|
|00001b70| 20 66 69 67 75 72 65 20 | 6f 75 74 20 74 68 65 20 | figure |out the |
|00001b80| 70 72 69 6e 74 20 63 6f | 6c 75 6d 6e 73 20 2a 2f |print co|lumns */|
|00001b90| 0a 09 09 74 2d 3e 70 72 | 69 6e 74 5f 63 6f 6c 20 |...t->pr|int_col |
|00001ba0| 3d 20 30 3b 0a 09 09 64 | 66 73 31 28 63 61 6c 63 |= 0;...d|fs1(calc|
|00001bb0| 5f 70 63 2c 20 6d 61 72 | 6b 5f 6c 61 73 74 2c 20 |_pc, mar|k_last, |
|00001bc0| 74 29 3b 0a 09 09 64 66 | 73 31 28 6f 75 74 70 75 |t);...df|s1(outpu|
|00001bd0| 74 2c 20 4e 55 4c 4c 2c | 20 74 29 3b 0a 09 09 7d |t, NULL,| t);...}|
|00001be0| 0a 09 2f 2a 20 70 75 74 | 20 62 6c 61 6e 6b 20 73 |../* put| blank s|
|00001bf0| 70 61 63 65 20 61 74 20 | 65 6e 64 20 2a 2f 0a 09 |pace at |end */..|
|00001c00| 70 6f 73 69 74 69 6f 6e | 28 6c 65 6e 67 74 68 29 |position|(length)|
|00001c10| 3b 0a 09 7d 0a 0a 2f 2a | 20 72 65 61 64 20 69 6e |;..}../*| read in|
|00001c20| 70 75 74 20 61 6e 64 20 | 66 6f 72 6d 20 61 20 74 |put and |form a t|
|00001c30| 72 65 65 20 2a 2f 0a 76 | 6f 69 64 20 72 65 61 64 |ree */.v|oid read|
|00001c40| 5f 69 6e 70 75 74 28 29 | 0a 09 7b 0a 09 75 6e 73 |_input()|..{..uns|
|00001c50| 69 67 6e 65 64 20 6c 6f | 6e 67 09 73 69 7a 65 3b |igned lo|ng.size;|
|00001c60| 09 09 2f 2a 20 73 69 7a | 65 20 72 65 61 64 20 66 |../* siz|e read f|
|00001c70| 72 6f 6d 20 69 6e 70 75 | 74 20 2a 2f 0a 09 63 68 |rom inpu|t */..ch|
|00001c80| 61 72 09 09 09 6e 61 6d | 65 5b 31 30 30 5d 3b 09 |ar...nam|e[100];.|
|00001c90| 2f 2a 20 64 69 72 65 63 | 74 6f 72 79 20 6e 61 6d |/* direc|tory nam|
|00001ca0| 65 20 72 65 61 64 20 66 | 72 6f 6d 20 69 6e 70 75 |e read f|rom inpu|
|00001cb0| 74 20 2a 2f 0a 0a 09 2f | 2a 20 6d 61 6b 65 20 74 |t */.../|* make t|
|00001cc0| 68 65 20 64 75 6d 6d 79 | 20 6e 6f 64 65 20 61 74 |he dummy| node at|
|00001cd0| 20 74 68 65 20 74 6f 70 | 20 6f 66 20 74 68 65 20 | the top| of the |
|00001ce0| 74 72 65 65 20 2a 2f 0a | 09 72 6f 6f 74 20 3d 20 |tree */.|.root = |
|00001cf0| 28 73 74 72 75 63 74 20 | 6e 6f 64 65 20 2a 29 6d |(struct |node *)m|
|00001d00| 61 6c 6c 6f 63 28 73 69 | 7a 65 6f 66 20 28 73 74 |alloc(si|zeof (st|
|00001d10| 72 75 63 74 20 6e 6f 64 | 65 29 29 3b 0a 09 72 6f |ruct nod|e));..ro|
|00001d20| 6f 74 2d 3e 6e 61 6d 65 | 5b 30 5d 20 3d 20 27 5c |ot->name|[0] = '\|
|00001d30| 30 27 3b 0a 09 72 6f 6f | 74 2d 3e 6c 73 6f 6e 20 |0';..roo|t->lson |
|00001d40| 3d 20 4e 55 4c 4c 3b 0a | 09 72 6f 6f 74 2d 3e 66 |= NULL;.|.root->f|
|00001d50| 61 74 68 65 72 20 3d 20 | 4e 55 4c 4c 3b 09 2f 2a |ather = |NULL;./*|
|00001d60| 20 69 66 20 77 61 6c 6b | 69 6e 67 20 75 70 20 74 | if walk|ing up t|
|00001d70| 68 65 20 6c 61 64 64 65 | 72 2c 20 64 6f 6e 27 74 |he ladde|r, don't|
|00001d80| 20 66 61 6c 6c 20 6f 66 | 66 20 21 20 2a 2f 0a 09 | fall of|f ! */..|
|00001d90| 2f 2a 20 72 65 61 64 20 | 74 68 65 20 6e 65 78 74 |/* read |the next|
|00001da0| 20 6c 69 6e 65 20 6f 66 | 20 69 6e 70 75 74 20 2a | line of| input *|
|00001db0| 2f 0a 09 77 68 69 6c 65 | 20 28 66 73 63 61 6e 66 |/..while| (fscanf|
|00001dc0| 28 73 74 64 69 6e 2c 20 | 22 25 6c 75 20 25 73 5c |(stdin, |"%lu %s\|
|00001dd0| 6e 22 2c 20 26 73 69 7a | 65 2c 20 6e 61 6d 65 29 |n", &siz|e, name)|
|00001de0| 20 21 3d 20 45 4f 46 29 | 0a 09 09 7b 0a 09 09 2f | != EOF)|...{.../|
|00001df0| 2a 20 69 6e 73 65 72 74 | 20 28 6f 72 20 66 69 6e |* insert| (or fin|
|00001e00| 64 29 20 74 68 65 20 64 | 69 72 65 63 74 6f 72 79 |d) the d|irectory|
|00001e10| 20 69 6e 20 74 68 65 20 | 74 72 65 65 20 61 6e 64 | in the |tree and|
|00001e20| 20 73 61 76 65 20 69 74 | 73 20 73 69 7a 65 20 2a | save it|s size *|
|00001e30| 2f 0a 09 09 69 6e 73 65 | 72 74 5f 69 6e 5f 74 72 |/...inse|rt_in_tr|
|00001e40| 65 65 28 6e 61 6d 65 29 | 2d 3e 73 69 7a 65 20 3d |ee(name)|->size =|
|00001e50| 20 73 69 7a 65 3b 0a 09 | 09 7d 0a 09 7d 0a 0a 2f | size;..|.}..}../|
|00001e60| 2a 20 69 6e 73 65 72 74 | 20 28 6f 72 20 66 69 6e |* insert| (or fin|
|00001e70| 64 29 20 61 20 64 69 72 | 65 63 74 6f 72 79 20 69 |d) a dir|ectory i|
|00001e80| 6e 20 74 68 65 20 74 72 | 65 65 20 2a 2f 0a 73 74 |n the tr|ee */.st|
|00001e90| 72 75 63 74 20 6e 6f 64 | 65 20 2a 69 6e 73 65 72 |ruct nod|e *inser|
|00001ea0| 74 5f 69 6e 5f 74 72 65 | 65 28 6e 61 6d 65 29 0a |t_in_tre|e(name).|
|00001eb0| 09 63 68 61 72 09 2a 6e | 61 6d 65 3b 09 09 2f 2a |.char.*n|ame;../*|
|00001ec0| 20 6e 61 6d 65 20 6f 66 | 20 74 68 65 20 64 69 72 | name of| the dir|
|00001ed0| 65 63 74 6f 72 79 20 2a | 2f 0a 09 7b 0a 09 73 74 |ectory *|/..{..st|
|00001ee0| 72 75 63 74 20 6e 6f 64 | 65 09 2a 74 3b 09 2f 2a |ruct nod|e.*t;./*|
|00001ef0| 20 70 6f 69 6e 74 65 72 | 20 66 6f 72 20 73 65 61 | pointer| for sea|
|00001f00| 72 63 68 69 6e 67 20 64 | 6f 77 6e 20 74 68 72 6f |rching d|own thro|
|00001f10| 75 67 68 20 74 72 65 65 | 20 2a 2f 0a 09 63 68 61 |ugh tree| */..cha|
|00001f20| 72 09 09 09 2a 6e 70 3b | 09 2f 2a 20 70 6f 69 6e |r...*np;|./* poin|
|00001f30| 74 73 20 74 6f 20 6e 65 | 78 74 20 70 61 72 74 20 |ts to ne|xt part |
|00001f40| 6f 66 20 64 69 72 65 63 | 74 6f 72 79 20 6e 61 6d |of direc|tory nam|
|00001f50| 65 20 74 6f 20 62 65 0a | 09 09 09 09 09 20 2a 20 |e to be.|..... * |
|00001f60| 65 78 61 6d 69 6e 65 64 | 20 2a 2f 0a 09 73 74 72 |examined| */..str|
|00001f70| 75 63 74 20 6e 6f 64 65 | 09 2a 74 31 3b 09 2f 2a |uct node|.*t1;./*|
|00001f80| 20 73 63 72 61 74 63 68 | 20 70 6f 69 6e 74 65 72 | scratch| pointer|
|00001f90| 20 2a 2f 0a 09 63 68 61 | 72 09 09 09 2a 6e 70 31 | */..cha|r...*np1|
|00001fa0| 3b 2f 2a 20 73 63 72 61 | 74 63 68 20 70 6f 69 6e |;/* scra|tch poin|
|00001fb0| 74 65 72 20 2a 2f 0a 0a | 09 2f 2a 20 72 65 61 64 |ter */..|./* read|
|00001fc0| 20 74 68 72 6f 75 67 68 | 20 74 68 65 20 6e 61 6d | through| the nam|
|00001fd0| 65 2c 20 6f 6e 65 20 64 | 69 72 65 63 74 6f 72 79 |e, one d|irectory|
|00001fe0| 2d 70 61 72 74 20 61 74 | 20 61 20 74 69 6d 65 2c |-part at| a time,|
|00001ff0| 20 61 6e 64 20 68 75 6e | 74 0a 09 20 2a 20 64 6f | and hun|t.. * do|
|00002000| 77 6e 20 74 68 65 20 74 | 72 65 65 2c 20 63 6f 6e |wn the t|ree, con|
|00002010| 73 74 72 75 63 74 69 6e | 67 20 6e 6f 64 65 73 20 |structin|g nodes |
|00002020| 61 73 20 6e 65 65 64 65 | 64 20 2a 2f 0a 09 66 6f |as neede|d */..fo|
|00002030| 72 20 28 74 20 3d 20 72 | 6f 6f 74 2c 20 6e 70 20 |r (t = r|oot, np |
|00002040| 3d 20 6e 61 6d 65 3b 20 | 6e 70 20 21 3d 20 4e 55 |= name; |np != NU|
|00002050| 4c 4c 3b 20 6e 70 20 3d | 20 6e 70 31 29 0a 09 09 |LL; np =| np1)...|
|00002060| 7b 0a 09 09 2f 2a 20 65 | 78 74 72 61 63 74 20 74 |{.../* e|xtract t|
|00002070| 68 65 20 6e 65 78 74 20 | 64 69 72 65 63 74 6f 72 |he next |director|
|00002080| 79 2d 70 61 72 74 20 2a | 2f 0a 09 09 69 66 20 28 |y-part *|/...if (|
|00002090| 28 6e 70 31 20 3d 20 73 | 74 72 63 68 72 28 6e 70 |(np1 = s|trchr(np|
|000020a0| 2c 20 27 2f 27 29 29 20 | 21 3d 20 4e 55 4c 4c 29 |, '/')) |!= NULL)|
|000020b0| 0a 09 09 09 7b 0a 09 09 | 09 2f 2a 20 77 65 20 66 |....{...|./* we f|
|000020c0| 6f 75 6e 64 20 61 20 73 | 6c 61 73 68 2c 20 72 65 |ound a s|lash, re|
|000020d0| 70 6c 61 63 65 20 69 74 | 20 77 69 74 68 20 61 20 |place it| with a |
|000020e0| 6e 75 6c 6c 2c 20 61 6e | 64 20 70 6f 73 69 74 69 |null, an|d positi|
|000020f0| 6f 6e 0a 09 09 09 20 2a | 20 6e 70 31 20 74 6f 20 |on.... *| np1 to |
|00002100| 70 6f 69 6e 74 20 74 6f | 20 74 68 65 20 72 65 6d |point to| the rem|
|00002110| 61 69 6e 64 65 72 20 6f | 66 20 74 68 65 20 6e 61 |ainder o|f the na|
|00002120| 6d 65 20 2a 2f 0a 09 09 | 09 2f 2a 20 63 61 6e 20 |me */...|./* can |
|00002130| 73 74 6f 72 65 20 6e 6f | 64 65 2e 6e 61 6d 65 3d |store no|de.name=|
|00002140| 3d 22 22 20 77 68 65 6e | 20 6e 61 6d 65 20 62 65 |="" when| name be|
|00002150| 67 69 6e 73 20 77 69 74 | 68 20 2f 20 2a 2f 0a 09 |gins wit|h / */..|
|00002160| 09 09 2a 6e 70 31 2b 2b | 20 3d 20 27 5c 30 27 3b |..*np1++| = '\0';|
|00002170| 0a 09 09 09 7d 0a 09 09 | 2f 2a 20 65 6c 73 65 20 |....}...|/* else |
|00002180| 2a 2f 0a 09 09 09 2f 2a | 20 77 65 20 66 6f 75 6e |*/..../*| we foun|
|00002190| 64 20 6e 6f 20 73 68 61 | 73 68 2c 20 73 6f 20 77 |d no sha|sh, so w|
|000021a0| 65 20 61 72 65 20 61 74 | 20 74 68 65 20 65 6e 64 |e are at| the end|
|000021b0| 20 6f 66 20 74 68 65 20 | 6e 61 6d 65 0a 09 09 09 | of the |name....|
|000021c0| 20 2a 20 6e 70 31 20 68 | 61 73 20 62 65 65 6e 20 | * np1 h|as been |
|000021d0| 73 65 74 20 74 6f 20 4e | 55 4c 4c 20 66 6f 72 20 |set to N|ULL for |
|000021e0| 75 73 20 62 79 20 73 74 | 72 63 68 72 20 2a 2f 0a |us by st|rchr */.|
|000021f0| 09 09 2f 2a 20 73 65 61 | 72 63 68 20 74 68 65 20 |../* sea|rch the |
|00002200| 73 6f 6e 73 20 6f 66 20 | 74 68 69 73 20 6e 6f 64 |sons of |this nod|
|00002210| 65 20 66 6f 72 20 61 20 | 6e 6f 64 65 20 77 69 74 |e for a |node wit|
|00002220| 68 20 74 68 65 20 70 72 | 6f 70 65 72 20 6e 61 6d |h the pr|oper nam|
|00002230| 65 20 2a 2f 0a 09 09 66 | 6f 72 20 28 74 31 20 3d |e */...f|or (t1 =|
|00002240| 20 74 2d 3e 6c 73 6f 6e | 3b 20 74 31 20 21 3d 20 | t->lson|; t1 != |
|00002250| 4e 55 4c 4c 20 26 26 20 | 73 74 72 63 6d 70 28 74 |NULL && |strcmp(t|
|00002260| 31 2d 3e 6e 61 6d 65 2c | 20 6e 70 29 20 21 3d 20 |1->name,| np) != |
|00002270| 30 3b 0a 09 09 09 09 74 | 31 20 3d 20 74 31 2d 3e |0;.....t|1 = t1->|
|00002280| 72 62 72 6f 74 68 65 72 | 29 0a 09 09 09 3b 0a 09 |rbrother|)....;..|
|00002290| 09 2f 2a 20 64 69 64 20 | 77 65 20 66 69 6e 64 20 |./* did |we find |
|000022a0| 6f 6e 65 3f 20 2a 2f 0a | 09 09 69 66 20 28 74 31 |one? */.|..if (t1|
|000022b0| 20 21 3d 20 4e 55 4c 4c | 29 0a 09 09 09 2f 2a 20 | != NULL|)..../* |
|000022c0| 79 65 73 2c 20 67 6f 20 | 74 6f 20 69 74 20 2a 2f |yes, go |to it */|
|000022d0| 0a 09 09 09 74 20 3d 20 | 74 31 3b 0a 09 09 65 6c |....t = |t1;...el|
|000022e0| 73 65 0a 09 09 09 7b 0a | 09 09 09 2f 2a 20 6e 6f |se....{.|.../* no|
|000022f0| 2c 20 6d 61 6b 65 20 6f | 6e 65 20 2a 2f 0a 09 09 |, make o|ne */...|
|00002300| 09 74 31 20 3d 20 28 73 | 74 72 75 63 74 20 6e 6f |.t1 = (s|truct no|
|00002310| 64 65 20 2a 29 6d 61 6c | 6c 6f 63 28 73 69 7a 65 |de *)mal|loc(size|
|00002320| 6f 66 28 73 74 72 75 63 | 74 20 6e 6f 64 65 29 20 |of(struc|t node) |
|00002330| 2b 20 73 74 72 6c 65 6e | 28 6e 70 29 29 3b 0a 09 |+ strlen|(np));..|
|00002340| 09 09 73 74 72 63 70 79 | 28 74 31 2d 3e 6e 61 6d |..strcpy|(t1->nam|
|00002350| 65 2c 20 6e 70 29 3b 0a | 09 09 09 74 31 2d 3e 6c |e, np);.|...t1->l|
|00002360| 73 6f 6e 20 3d 20 4e 55 | 4c 4c 3b 0a 09 09 09 74 |son = NU|LL;....t|
|00002370| 31 2d 3e 72 62 72 6f 74 | 68 65 72 20 3d 20 4e 55 |1->rbrot|her = NU|
|00002380| 4c 4c 3b 0a 09 09 09 74 | 31 2d 3e 66 61 74 68 65 |LL;....t|1->fathe|
|00002390| 72 20 3d 20 74 3b 0a 09 | 09 09 74 31 2d 3e 73 69 |r = t;..|..t1->si|
|000023a0| 7a 65 20 3d 20 30 3b 0a | 09 09 09 2f 2a 20 69 6e |ze = 0;.|.../* in|
|000023b0| 73 65 72 74 20 69 74 20 | 69 6e 20 74 72 65 65 20 |sert it |in tree |
|000023c0| 2a 2f 0a 09 09 09 74 31 | 2d 3e 72 62 72 6f 74 68 |*/....t1|->rbroth|
|000023d0| 65 72 20 3d 20 74 2d 3e | 6c 73 6f 6e 3b 0a 09 09 |er = t->|lson;...|
|000023e0| 09 74 2d 3e 6c 73 6f 6e | 20 3d 20 74 31 3b 0a 09 |.t->lson| = t1;..|
|000023f0| 09 09 74 20 3d 20 74 31 | 3b 0a 09 09 09 7d 0a 09 |..t = t1|;....}..|
|00002400| 09 7d 0a 09 72 65 74 75 | 72 6e 20 74 3b 0a 09 7d |.}..retu|rn t;..}|
|00002410| 0a 0a 2f 2a 20 64 65 70 | 74 68 2d 66 69 72 73 74 |../* dep|th-first|
|00002420| 2d 73 65 61 72 63 68 20 | 72 6f 75 74 69 6e 65 20 |-search |routine |
|00002430| 2a 2f 0a 76 6f 69 64 20 | 64 66 73 28 70 72 65 5f |*/.void |dfs(pre_|
|00002440| 72 6f 75 74 69 6e 65 2c | 20 70 6f 73 74 5f 72 6f |routine,| post_ro|
|00002450| 75 74 69 6e 65 29 0a 09 | 76 6f 69 64 09 28 2a 70 |utine)..|void.(*p|
|00002460| 72 65 5f 72 6f 75 74 69 | 6e 65 29 28 29 3b 09 2f |re_routi|ne)();./|
|00002470| 2a 20 72 6f 75 74 69 6e | 65 20 74 6f 20 65 78 65 |* routin|e to exe|
|00002480| 63 75 74 65 20 62 65 66 | 6f 72 65 20 73 63 61 6e |cute bef|ore scan|
|00002490| 6e 69 6e 67 0a 09 09 09 | 09 09 09 20 2a 20 64 65 |ning....|... * de|
|000024a0| 73 63 65 6e 64 61 6e 74 | 73 20 2a 2f 0a 09 76 6f |scendant|s */..vo|
|000024b0| 69 64 09 28 2a 70 6f 73 | 74 5f 72 6f 75 74 69 6e |id.(*pos|t_routin|
|000024c0| 65 29 28 29 3b 09 2f 2a | 20 72 6f 75 74 69 6e 65 |e)();./*| routine|
|000024d0| 20 74 6f 20 65 78 65 63 | 75 74 65 20 61 66 74 65 | to exec|ute afte|
|000024e0| 72 20 73 63 61 6e 6e 69 | 6e 67 0a 09 09 09 09 09 |r scanni|ng......|
|000024f0| 09 20 2a 20 64 65 73 63 | 65 6e 64 61 6e 74 73 20 |. * desc|endants |
|00002500| 2a 2f 0a 09 7b 0a 09 64 | 66 73 31 28 70 72 65 5f |*/..{..d|fs1(pre_|
|00002510| 72 6f 75 74 69 6e 65 2c | 20 70 6f 73 74 5f 72 6f |routine,| post_ro|
|00002520| 75 74 69 6e 65 2c 20 72 | 6f 6f 74 29 3b 0a 09 7d |utine, r|oot);..}|
|00002530| 0a 0a 2f 2a 20 64 65 70 | 74 68 2d 66 69 72 73 74 |../* dep|th-first|
|00002540| 2d 73 65 61 72 63 68 20 | 73 65 72 76 69 63 65 20 |-search |service |
|00002550| 72 6f 75 74 69 6e 65 20 | 2a 2f 0a 76 6f 69 64 20 |routine |*/.void |
|00002560| 64 66 73 31 28 70 72 65 | 5f 72 6f 75 74 69 6e 65 |dfs1(pre|_routine|
|00002570| 2c 20 70 6f 73 74 5f 72 | 6f 75 74 69 6e 65 2c 20 |, post_r|outine, |
|00002580| 74 29 0a 09 76 6f 69 64 | 09 28 2a 70 72 65 5f 72 |t)..void|.(*pre_r|
|00002590| 6f 75 74 69 6e 65 29 28 | 29 3b 09 2f 2a 20 72 6f |outine)(|);./* ro|
|000025a0| 75 74 69 6e 65 20 74 6f | 20 65 78 65 63 75 74 65 |utine to| execute|
|000025b0| 20 62 65 66 6f 72 65 20 | 73 63 61 6e 6e 69 6e 67 | before |scanning|
|000025c0| 0a 09 09 09 09 09 09 20 | 2a 20 64 65 73 63 65 6e |....... |* descen|
|000025d0| 64 61 6e 74 73 20 2a 2f | 0a 09 76 6f 69 64 09 28 |dants */|..void.(|
|000025e0| 2a 70 6f 73 74 5f 72 6f | 75 74 69 6e 65 29 28 29 |*post_ro|utine)()|
|000025f0| 3b 09 2f 2a 20 72 6f 75 | 74 69 6e 65 20 74 6f 20 |;./* rou|tine to |
|00002600| 65 78 65 63 75 74 65 20 | 61 66 74 65 72 20 73 63 |execute |after sc|
|00002610| 61 6e 6e 69 6e 67 0a 09 | 09 09 09 09 09 20 2a 20 |anning..|..... * |
|00002620| 64 65 73 63 65 6e 64 61 | 6e 74 73 20 2a 2f 0a 09 |descenda|nts */..|
|00002630| 73 74 72 75 63 74 20 6e | 6f 64 65 20 2a 74 3b 09 |struct n|ode *t;.|
|00002640| 09 2f 2a 20 6e 6f 64 65 | 20 74 6f 20 6f 70 65 72 |./* node| to oper|
|00002650| 61 74 65 20 6f 6e 20 2a | 2f 0a 09 7b 0a 09 73 74 |ate on *|/..{..st|
|00002660| 72 75 63 74 20 6e 6f 64 | 65 20 2a 74 31 3b 09 09 |ruct nod|e *t1;..|
|00002670| 2f 2a 20 73 63 72 61 74 | 63 68 20 70 6f 69 6e 74 |/* scrat|ch point|
|00002680| 65 72 20 2a 2f 0a 0a 09 | 2f 2a 20 69 66 20 69 74 |er */...|/* if it|
|00002690| 20 65 78 69 73 74 73 2c | 20 65 78 65 63 75 74 65 | exists,| execute|
|000026a0| 20 74 68 65 20 70 72 65 | 2d 72 6f 75 74 69 6e 65 | the pre|-routine|
|000026b0| 20 2a 2f 0a 09 69 66 20 | 28 70 72 65 5f 72 6f 75 | */..if |(pre_rou|
|000026c0| 74 69 6e 65 20 21 3d 20 | 4e 55 4c 4c 29 0a 09 09 |tine != |NULL)...|
|000026d0| 70 72 65 5f 72 6f 75 74 | 69 6e 65 28 74 29 3b 0a |pre_rout|ine(t);.|
|000026e0| 09 2f 2a 20 63 61 6c 6c | 20 73 65 6c 66 20 6f 6e |./* call| self on|
|000026f0| 20 73 6f 6e 73 20 6f 66 | 20 74 68 69 73 20 6e 6f | sons of| this no|
|00002700| 64 65 20 2a 2f 0a 09 66 | 6f 72 20 28 74 31 20 3d |de */..f|or (t1 =|
|00002710| 20 74 2d 3e 6c 73 6f 6e | 3b 20 74 31 20 21 3d 20 | t->lson|; t1 != |
|00002720| 4e 55 4c 4c 3b 20 74 31 | 20 3d 20 74 31 2d 3e 72 |NULL; t1| = t1->r|
|00002730| 62 72 6f 74 68 65 72 29 | 0a 09 09 64 66 73 31 28 |brother)|...dfs1(|
|00002740| 70 72 65 5f 72 6f 75 74 | 69 6e 65 2c 20 70 6f 73 |pre_rout|ine, pos|
|00002750| 74 5f 72 6f 75 74 69 6e | 65 2c 20 74 31 29 3b 0a |t_routin|e, t1);.|
|00002760| 09 2f 2a 20 69 66 20 69 | 74 20 65 78 69 73 74 73 |./* if i|t exists|
|00002770| 2c 20 65 78 65 63 75 74 | 65 20 74 68 65 20 70 6f |, execut|e the po|
|00002780| 73 74 2d 72 6f 75 74 69 | 6e 65 20 2a 2f 0a 09 69 |st-routi|ne */..i|
|00002790| 66 20 28 70 6f 73 74 5f | 72 6f 75 74 69 6e 65 20 |f (post_|routine |
|000027a0| 21 3d 20 4e 55 4c 4c 29 | 0a 09 09 70 6f 73 74 5f |!= NULL)|...post_|
|000027b0| 72 6f 75 74 69 6e 65 28 | 74 29 3b 0a 09 7d 0a 0a |routine(|t);..}..|
|000027c0| 2f 2a 20 61 64 64 20 6d | 69 73 73 69 6e 67 20 73 |/* add m|issing s|
|000027d0| 69 7a 65 73 20 2a 2f 0a | 76 6f 69 64 20 6d 69 73 |izes */.|void mis|
|000027e0| 73 69 6e 67 5f 73 69 7a | 65 73 28 74 29 0a 09 73 |sing_siz|es(t)..s|
|000027f0| 74 72 75 63 74 20 6e 6f | 64 65 09 2a 74 3b 0a 09 |truct no|de.*t;..|
|00002800| 7b 0a 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |{..struc|t node.*|
|00002810| 74 31 3b 09 09 2f 2a 20 | 73 63 72 61 74 63 68 20 |t1;../* |scratch |
|00002820| 70 6f 69 6e 74 65 72 20 | 2a 2f 0a 09 75 6e 73 69 |pointer |*/..unsi|
|00002830| 67 6e 65 64 20 6c 6f 6e | 67 09 73 3b 09 09 2f 2a |gned lon|g.s;../*|
|00002840| 20 73 63 72 61 74 63 68 | 20 2a 2f 0a 0a 09 69 66 | scratch| */...if|
|00002850| 20 28 74 2d 3e 73 69 7a | 65 20 3d 3d 20 30 29 0a | (t->siz|e == 0).|
|00002860| 09 09 7b 0a 09 09 2f 2a | 20 73 69 7a 65 20 69 73 |..{.../*| size is|
|00002870| 20 6d 69 73 73 69 6e 67 | 2c 20 77 65 20 68 61 76 | missing|, we hav|
|00002880| 65 20 74 6f 20 63 61 6c | 63 75 61 74 65 20 69 74 |e to cal|cuate it|
|00002890| 20 2a 2f 0a 09 09 73 20 | 3d 20 30 3b 0a 09 09 66 | */...s |= 0;...f|
|000028a0| 6f 72 20 28 74 31 20 3d | 20 74 2d 3e 6c 73 6f 6e |or (t1 =| t->lson|
|000028b0| 3b 20 74 31 20 21 3d 20 | 4e 55 4c 4c 3b 20 74 31 |; t1 != |NULL; t1|
|000028c0| 20 3d 20 74 31 2d 3e 72 | 62 72 6f 74 68 65 72 29 | = t1->r|brother)|
|000028d0| 0a 09 09 09 73 20 2b 3d | 20 74 31 2d 3e 73 69 7a |....s +=| t1->siz|
|000028e0| 65 3b 0a 09 09 74 2d 3e | 73 69 7a 65 20 3d 20 73 |e;...t->|size = s|
|000028f0| 3b 0a 09 09 7d 0a 09 7d | 0a 0a 2f 2a 20 73 6f 72 |;...}..}|../* sor|
|00002900| 74 20 74 68 65 20 64 69 | 72 65 63 74 6f 72 69 65 |t the di|rectorie|
|00002910| 73 20 75 6e 64 65 72 20 | 61 20 64 69 72 65 63 74 |s under |a direct|
|00002920| 6f 72 79 20 62 79 20 73 | 69 7a 65 20 2a 2f 0a 76 |ory by s|ize */.v|
|00002930| 6f 69 64 20 73 6f 72 74 | 5f 73 69 7a 65 28 74 29 |oid sort|_size(t)|
|00002940| 0a 09 73 74 72 75 63 74 | 20 6e 6f 64 65 09 2a 74 |..struct| node.*t|
|00002950| 3b 0a 09 7b 0a 09 73 74 | 72 75 63 74 20 6e 6f 64 |;..{..st|ruct nod|
|00002960| 65 09 2a 70 31 2c 20 2a | 70 32 2c 20 2a 70 33 2c |e.*p1, *|p2, *p3,|
|00002970| 20 2a 70 70 3b 09 09 2f | 2a 20 73 63 72 61 74 63 | *pp;../|* scratc|
|00002980| 68 20 70 6f 69 6e 74 65 | 72 73 20 2a 2f 0a 09 69 |h pointe|rs */..i|
|00002990| 6e 74 09 09 09 6e 6f 64 | 65 73 2c 20 6e 3b 09 09 |nt...nod|es, n;..|
|000029a0| 09 09 2f 2a 20 73 63 72 | 61 74 63 68 20 2a 2f 0a |../* scr|atch */.|
|000029b0| 0a 09 2f 2a 20 63 6f 75 | 6e 74 20 74 68 65 20 6e |../* cou|nt the n|
|000029c0| 75 6d 62 65 72 20 6f 66 | 20 6e 6f 64 65 73 20 2a |umber of| nodes *|
|000029d0| 2f 0a 09 6e 6f 64 65 73 | 20 3d 20 30 3b 0a 09 66 |/..nodes| = 0;..f|
|000029e0| 6f 72 20 28 70 31 20 3d | 20 74 2d 3e 6c 73 6f 6e |or (p1 =| t->lson|
|000029f0| 3b 20 70 31 20 21 3d 20 | 4e 55 4c 4c 3b 20 70 31 |; p1 != |NULL; p1|
|00002a00| 20 3d 20 70 31 2d 3e 72 | 62 72 6f 74 68 65 72 29 | = p1->r|brother)|
|00002a10| 0a 09 09 6e 6f 64 65 73 | 2b 2b 3b 0a 09 2f 2a 20 |...nodes|++;../* |
|00002a20| 6a 75 73 74 20 61 20 73 | 69 6d 70 6c 65 20 61 6e |just a s|imple an|
|00002a30| 64 20 69 6e 65 66 66 69 | 63 69 65 6e 74 20 62 75 |d ineffi|cient bu|
|00002a40| 62 62 6c 65 20 73 6f 72 | 74 20 2a 2f 0a 09 66 6f |bble sor|t */..fo|
|00002a50| 72 20 28 6e 20 3d 20 31 | 3b 20 6e 20 3c 20 6e 6f |r (n = 1|; n < no|
|00002a60| 64 65 73 3b 20 6e 2b 2b | 29 0a 09 09 66 6f 72 20 |des; n++|)...for |
|00002a70| 28 70 31 20 3d 20 4e 55 | 4c 4c 2c 20 70 32 20 3d |(p1 = NU|LL, p2 =|
|00002a80| 20 74 2d 3e 6c 73 6f 6e | 2c 20 70 33 20 3d 20 70 | t->lson|, p3 = p|
|00002a90| 32 2d 3e 72 62 72 6f 74 | 68 65 72 3b 20 70 33 20 |2->rbrot|her; p3 |
|00002aa0| 21 3d 20 4e 55 4c 4c 3b | 0a 09 09 09 09 70 31 20 |!= NULL;|.....p1 |
|00002ab0| 3d 20 70 32 2c 20 70 32 | 20 3d 20 70 33 2c 20 70 |= p2, p2| = p3, p|
|00002ac0| 33 20 3d 20 70 33 2d 3e | 72 62 72 6f 74 68 65 72 |3 = p3->|rbrother|
|00002ad0| 29 0a 09 09 09 7b 0a 09 | 09 09 69 66 20 28 70 32 |)....{..|..if (p2|
|00002ae0| 2d 3e 73 69 7a 65 20 3c | 20 70 33 2d 3e 73 69 7a |->size <| p3->siz|
|00002af0| 65 29 0a 09 09 09 09 7b | 0a 09 09 09 09 2f 2a 20 |e).....{|...../* |
|00002b00| 65 78 63 68 61 6e 67 65 | 20 74 68 65 20 6e 6f 64 |exchange| the nod|
|00002b10| 65 73 20 70 32 20 61 6e | 64 20 70 33 20 2a 2f 0a |es p2 an|d p3 */.|
|00002b20| 09 09 09 09 70 70 20 3d | 20 70 33 2d 3e 72 62 72 |....pp =| p3->rbr|
|00002b30| 6f 74 68 65 72 3b 0a 09 | 09 09 09 70 33 2d 3e 72 |other;..|...p3->r|
|00002b40| 62 72 6f 74 68 65 72 20 | 3d 20 70 32 3b 0a 09 09 |brother |= p2;...|
|00002b50| 09 09 70 32 2d 3e 72 62 | 72 6f 74 68 65 72 20 3d |..p2->rb|rother =|
|00002b60| 20 70 70 3b 0a 09 09 09 | 09 69 66 20 28 70 31 20 | pp;....|.if (p1 |
|00002b70| 21 3d 20 4e 55 4c 4c 29 | 0a 09 09 09 09 09 70 31 |!= NULL)|......p1|
|00002b80| 2d 3e 72 62 72 6f 74 68 | 65 72 20 3d 20 70 33 3b |->rbroth|er = p3;|
|00002b90| 0a 09 09 09 09 65 6c 73 | 65 0a 09 09 09 09 09 74 |.....els|e......t|
|00002ba0| 2d 3e 6c 73 6f 6e 20 3d | 20 70 33 3b 0a 09 09 09 |->lson =| p3;....|
|00002bb0| 09 2f 2a 20 65 78 63 68 | 61 6e 67 65 20 74 68 65 |./* exch|ange the|
|00002bc0| 20 76 61 6c 75 65 73 20 | 6f 66 20 70 32 20 61 6e | values |of p2 an|
|00002bd0| 64 20 70 33 20 2a 2f 0a | 09 09 09 09 70 70 20 3d |d p3 */.|....pp =|
|00002be0| 20 70 32 3b 0a 09 09 09 | 09 70 32 20 3d 20 70 33 | p2;....|.p2 = p3|
|00002bf0| 3b 0a 09 09 09 09 70 33 | 20 3d 20 70 70 3b 0a 09 |;.....p3| = pp;..|
|00002c00| 09 09 09 7d 0a 09 09 09 | 7d 0a 09 7d 0a 0a 2f 2a |...}....|}..}../*|
|00002c10| 20 63 61 6c 63 75 6c 61 | 74 65 20 74 68 65 20 70 | calcula|te the p|
|00002c20| 72 69 6e 74 20 6c 6f 63 | 61 74 69 6f 6e 20 2a 2f |rint loc|ation */|
|00002c30| 0a 76 6f 69 64 20 63 61 | 6c 63 5f 6c 6f 63 28 74 |.void ca|lc_loc(t|
|00002c40| 29 0a 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |)..struc|t node.*|
|00002c50| 74 3b 0a 09 7b 0a 09 75 | 6e 73 69 67 6e 65 64 20 |t;..{..u|nsigned |
|00002c60| 6c 6f 6e 67 09 63 73 3b | 09 09 2f 2a 20 73 63 72 |long.cs;|../* scr|
|00002c70| 61 74 63 68 20 2a 2f 0a | 09 73 74 72 75 63 74 20 |atch */.|.struct |
|00002c80| 6e 6f 64 65 09 2a 74 31 | 2c 20 2a 74 32 3b 09 2f |node.*t1|, *t2;./|
|00002c90| 2a 20 73 63 72 61 74 63 | 68 20 70 6f 69 6e 74 65 |* scratc|h pointe|
|00002ca0| 72 73 20 2a 2f 0a 09 69 | 6e 74 09 09 09 70 72 69 |rs */..i|nt...pri|
|00002cb0| 6e 74 5f 6c 69 6d 69 74 | 3b 0a 09 09 09 09 09 09 |nt_limit|;.......|
|00002cc0| 2f 2a 20 6c 6f 63 61 74 | 69 6f 6e 20 6e 65 78 74 |/* locat|ion next|
|00002cd0| 20 64 69 72 65 63 74 6f | 72 79 20 61 66 74 65 72 | directo|ry after|
|00002ce0| 20 74 20 77 69 6c 6c 0a | 09 09 09 09 09 09 20 2a | t will.|...... *|
|00002cf0| 20 62 65 20 70 72 69 6e | 74 65 64 20 2a 2f 0a 0a | be prin|ted */..|
|00002d00| 09 69 66 20 28 74 20 3d | 3d 20 72 6f 6f 74 29 0a |.if (t =|= root).|
|00002d10| 09 09 63 73 20 3d 20 30 | 3b 0a 09 65 6c 73 65 0a |..cs = 0|;..else.|
|00002d20| 09 09 7b 0a 09 09 2f 2a | 20 66 69 67 75 72 65 20 |..{.../*| figure |
|00002d30| 6f 75 74 20 68 6f 77 20 | 6d 75 63 68 20 69 73 20 |out how |much is |
|00002d40| 69 6e 20 74 68 65 20 64 | 69 72 65 63 74 6f 72 79 |in the d|irectory|
|00002d50| 20 69 74 73 65 6c 66 20 | 2a 2f 0a 09 09 66 6f 72 | itself |*/...for|
|00002d60| 20 28 74 31 20 3d 20 74 | 2d 3e 6c 73 6f 6e 2c 20 | (t1 = t|->lson, |
|00002d70| 63 73 20 3d 20 30 3b 20 | 74 31 20 21 3d 20 4e 55 |cs = 0; |t1 != NU|
|00002d80| 4c 4c 3b 20 74 31 20 3d | 20 74 31 2d 3e 72 62 72 |LL; t1 =| t1->rbr|
|00002d90| 6f 74 68 65 72 29 0a 09 | 09 09 7b 0a 09 09 09 63 |other)..|..{....c|
|00002da0| 73 20 2b 3d 20 74 31 2d | 3e 73 69 7a 65 3b 0a 09 |s += t1-|>size;..|
|00002db0| 09 09 7d 0a 09 09 2f 2a | 20 63 73 20 69 73 20 74 |..}.../*| cs is t|
|00002dc0| 68 65 20 73 69 7a 65 20 | 61 63 63 6f 75 6e 74 65 |he size |accounte|
|00002dd0| 64 20 66 6f 72 20 62 79 | 20 73 75 62 64 69 72 65 |d for by| subdire|
|00002de0| 63 74 6f 72 69 65 73 20 | 2a 2f 0a 09 09 63 73 20 |ctories |*/...cs |
|00002df0| 3d 20 74 2d 3e 73 69 7a | 65 20 2d 20 63 73 3b 0a |= t->siz|e - cs;.|
|00002e00| 09 09 7d 0a 09 2f 2a 20 | 63 73 20 69 73 20 74 68 |..}../* |cs is th|
|00002e10| 65 20 73 69 7a 65 20 6f | 66 20 74 68 65 20 66 69 |e size o|f the fi|
|00002e20| 6c 65 73 20 69 6e 20 74 | 68 65 20 64 69 72 65 63 |les in t|he direc|
|00002e30| 74 6f 72 79 20 69 74 73 | 65 6c 66 20 2a 2f 0a 09 |tory its|elf */..|
|00002e40| 2f 2a 20 63 6f 6e 76 65 | 72 74 20 63 73 20 74 6f |/* conve|rt cs to|
|00002e50| 20 6c 69 6e 65 73 20 2a | 2f 0a 09 63 73 20 3d 20 | lines *|/..cs = |
|00002e60| 63 73 2a 6c 65 6e 67 74 | 68 2f 74 6f 74 61 6c 5f |cs*lengt|h/total_|
|00002e70| 73 69 7a 65 20 2b 20 74 | 2d 3e 6c 6f 63 3b 0a 09 |size + t|->loc;..|
|00002e80| 2f 2a 20 63 61 6c 63 75 | 6c 61 74 65 20 77 68 65 |/* calcu|late whe|
|00002e90| 72 65 20 6e 65 78 74 20 | 64 69 72 65 63 74 6f 72 |re next |director|
|00002ea0| 79 20 61 66 74 65 72 20 | 74 20 77 69 6c 6c 20 62 |y after |t will b|
|00002eb0| 65 20 2a 2f 0a 09 70 72 | 69 6e 74 5f 6c 69 6d 69 |e */..pr|int_limi|
|00002ec0| 74 20 3d 20 74 2d 3e 70 | 72 69 6e 74 5f 6c 69 6d |t = t->p|rint_lim|
|00002ed0| 69 74 3b 0a 09 2f 2a 20 | 61 73 73 69 67 6e 20 6c |it;../* |assign l|
|00002ee0| 6f 63 61 74 69 6f 6e 73 | 20 2a 2f 0a 09 66 6f 72 |ocations| */..for|
|00002ef0| 20 28 74 31 20 3d 20 74 | 2d 3e 6c 73 6f 6e 2c 20 | (t1 = t|->lson, |
|00002f00| 74 32 20 3d 20 4e 55 4c | 4c 3b 20 74 31 20 21 3d |t2 = NUL|L; t1 !=|
|00002f10| 20 4e 55 4c 4c 3b 20 74 | 32 20 3d 20 74 31 2c 20 | NULL; t|2 = t1, |
|00002f20| 74 31 20 3d 20 74 31 2d | 3e 72 62 72 6f 74 68 65 |t1 = t1-|>rbrothe|
|00002f30| 72 29 0a 09 09 7b 0a 09 | 09 2f 2a 20 6d 61 6b 65 |r)...{..|./* make|
|00002f40| 20 73 75 72 65 20 77 65 | 20 64 6f 6e 27 74 20 72 | sure we| don't r|
|00002f50| 75 6e 20 69 6e 74 6f 20 | 6e 65 78 74 20 64 69 72 |un into |next dir|
|00002f60| 65 63 74 6f 72 79 20 2a | 2f 0a 09 09 69 66 20 28 |ectory *|/...if (|
|00002f70| 63 73 20 3e 3d 20 70 72 | 69 6e 74 5f 6c 69 6d 69 |cs >= pr|int_limi|
|00002f80| 74 29 0a 09 09 09 7b 0a | 09 09 09 63 73 20 3d 20 |t)....{.|...cs = |
|00002f90| 70 72 69 6e 74 5f 6c 69 | 6d 69 74 2d 31 3b 0a 09 |print_li|mit-1;..|
|00002fa0| 09 09 7d 0a 09 09 74 31 | 2d 3e 6c 6f 63 20 3d 20 |..}...t1|->loc = |
|00002fb0| 63 73 3b 0a 09 09 69 66 | 20 28 74 32 20 21 3d 20 |cs;...if| (t2 != |
|00002fc0| 4e 55 4c 4c 29 0a 09 09 | 09 74 32 2d 3e 70 72 69 |NULL)...|.t2->pri|
|00002fd0| 6e 74 5f 6c 69 6d 69 74 | 20 3d 20 63 73 3b 0a 09 |nt_limit| = cs;..|
|00002fe0| 09 63 73 20 2b 3d 20 74 | 31 2d 3e 73 69 7a 65 2a |.cs += t|1->size*|
|00002ff0| 6c 65 6e 67 74 68 2f 74 | 6f 74 61 6c 5f 73 69 7a |length/t|otal_siz|
|00003000| 65 3b 0a 09 09 7d 0a 09 | 69 66 20 28 74 32 20 21 |e;...}..|if (t2 !|
|00003010| 3d 20 4e 55 4c 4c 29 0a | 09 09 74 32 2d 3e 70 72 |= NULL).|..t2->pr|
|00003020| 69 6e 74 5f 6c 69 6d 69 | 74 20 3d 20 70 72 69 6e |int_limi|t = prin|
|00003030| 74 5f 6c 69 6d 69 74 3b | 0a 09 7d 0a 0a 2f 2a 20 |t_limit;|..}../* |
|00003040| 66 69 67 75 72 65 20 6f | 75 74 20 77 68 69 63 68 |figure o|ut which|
|00003050| 20 64 69 72 65 63 74 6f | 72 69 65 73 20 74 6f 20 | directo|ries to |
|00003060| 62 6c 61 6e 6b 20 6f 75 | 74 20 2a 2f 0a 76 6f 69 |blank ou|t */.voi|
|00003070| 64 20 62 6c 61 6e 6b 28 | 74 29 0a 09 73 74 72 75 |d blank(|t)..stru|
|00003080| 63 74 20 6e 6f 64 65 09 | 2a 74 3b 0a 09 7b 0a 09 |ct node.|*t;..{..|
|00003090| 73 74 72 75 63 74 20 6e | 6f 64 65 09 2a 74 31 2c |struct n|ode.*t1,|
|000030a0| 20 2a 74 32 2c 20 2a 74 | 33 3b 09 09 2f 2a 20 6c | *t2, *t|3;../* l|
|000030b0| 6f 6f 70 20 70 6f 69 6e | 74 65 72 73 20 2a 2f 0a |oop poin|ters */.|
|000030c0| 0a 09 2f 2a 20 72 65 74 | 75 72 6e 20 69 66 20 74 |../* ret|urn if t|
|000030d0| 68 65 72 65 20 61 72 65 | 6e 27 74 20 61 74 20 6c |here are|n't at l|
|000030e0| 65 61 73 74 20 74 77 6f | 20 73 6f 6e 73 20 2a 2f |east two| sons */|
|000030f0| 0a 09 69 66 20 28 74 2d | 3e 6c 73 6f 6e 20 3d 3d |..if (t-|>lson ==|
|00003100| 20 4e 55 4c 4c 20 7c 7c | 20 74 2d 3e 6c 73 6f 6e | NULL ||| t->lson|
|00003110| 2d 3e 72 62 72 6f 74 68 | 65 72 20 3d 3d 20 4e 55 |->rbroth|er == NU|
|00003120| 4c 4c 29 0a 09 09 72 65 | 74 75 72 6e 3b 0a 09 66 |LL)...re|turn;..f|
|00003130| 6f 72 20 28 74 31 20 3d | 20 4e 55 4c 4c 2c 20 74 |or (t1 =| NULL, t|
|00003140| 32 20 3d 20 74 2d 3e 6c | 73 6f 6e 2c 20 74 33 20 |2 = t->l|son, t3 |
|00003150| 3d 20 74 32 2d 3e 72 62 | 72 6f 74 68 65 72 3b 20 |= t2->rb|rother; |
|00003160| 74 33 20 21 3d 20 4e 55 | 4c 4c 3b 0a 09 09 09 74 |t3 != NU|LL;....t|
|00003170| 31 20 3d 20 74 32 2c 20 | 74 32 20 3d 20 74 33 2c |1 = t2, |t2 = t3,|
|00003180| 20 74 33 20 3d 20 74 33 | 2d 3e 72 62 72 6f 74 68 | t3 = t3|->rbroth|
|00003190| 65 72 29 0a 09 09 69 66 | 20 28 74 32 2d 3e 6c 6f |er)...if| (t2->lo|
|000031a0| 63 20 3d 3d 20 74 33 2d | 3e 6c 6f 63 29 0a 09 09 |c == t3-|>loc)...|
|000031b0| 09 7b 0a 09 09 09 2f 2a | 20 72 65 70 6c 61 63 65 |.{..../*| replace|
|000031c0| 20 74 31 20 61 6e 64 20 | 73 75 63 63 65 65 64 69 | t1 and |succeedi|
|000031d0| 6e 67 20 6e 6f 64 65 73 | 20 77 69 74 68 20 22 28 |ng nodes| with "(|
|000031e0| 65 74 63 2e 29 22 20 2a | 2f 0a 09 09 09 74 33 20 |etc.)" *|/....t3 |
|000031f0| 3d 20 28 73 74 72 75 63 | 74 20 6e 6f 64 65 20 2a |= (struc|t node *|
|00003200| 29 6d 61 6c 6c 6f 63 28 | 73 69 7a 65 6f 66 20 28 |)malloc(|sizeof (|
|00003210| 73 74 72 75 63 74 20 6e | 6f 64 65 29 20 2b 0a 09 |struct n|ode) +..|
|00003220| 09 09 09 73 69 7a 65 6f | 66 20 28 53 55 50 50 52 |...sizeo|f (SUPPR|
|00003230| 45 53 53 45 44 29 20 2d | 20 31 29 3b 0a 09 09 09 |ESSED) -| 1);....|
|00003240| 73 74 72 63 70 79 28 74 | 33 2d 3e 6e 61 6d 65 2c |strcpy(t|3->name,|
|00003250| 20 53 55 50 50 52 45 53 | 53 45 44 29 3b 0a 09 09 | SUPPRES|SED);...|
|00003260| 09 74 33 2d 3e 6c 73 6f | 6e 20 3d 20 74 33 2d 3e |.t3->lso|n = t3->|
|00003270| 72 62 72 6f 74 68 65 72 | 20 3d 20 4e 55 4c 4c 3b |rbrother| = NULL;|
|00003280| 0a 09 09 09 74 33 2d 3e | 6c 6f 63 20 3d 20 74 32 |....t3->|loc = t2|
|00003290| 2d 3e 6c 6f 63 3b 0a 09 | 09 09 69 66 20 28 74 31 |->loc;..|..if (t1|
|000032a0| 20 3d 3d 20 4e 55 4c 4c | 29 0a 09 09 09 09 74 2d | == NULL|).....t-|
|000032b0| 3e 6c 73 6f 6e 20 3d 20 | 74 33 3b 0a 09 09 09 65 |>lson = |t3;....e|
|000032c0| 6c 73 65 0a 09 09 09 09 | 74 31 2d 3e 72 62 72 6f |lse.....|t1->rbro|
|000032d0| 74 68 65 72 20 3d 20 74 | 33 3b 0a 09 09 09 7d 0a |ther = t|3;....}.|
|000032e0| 09 7d 0a 0a 2f 2a 20 6d | 61 72 6b 20 74 68 65 20 |.}../* m|ark the |
|000032f0| 6c 61 73 74 20 73 6f 6e | 20 6f 66 20 65 61 63 68 |last son| of each|
|00003300| 20 64 69 72 65 63 74 6f | 72 79 20 2a 2f 0a 76 6f | directo|ry */.vo|
|00003310| 69 64 20 6d 61 72 6b 5f | 6c 61 73 74 28 74 29 0a |id mark_|last(t).|
|00003320| 09 73 74 72 75 63 74 20 | 6e 6f 64 65 09 2a 74 3b |.struct |node.*t;|
|00003330| 0a 09 7b 0a 09 73 74 72 | 75 63 74 20 6e 6f 64 65 |..{..str|uct node|
|00003340| 09 2a 74 31 2c 20 2a 74 | 32 3b 09 2f 2a 20 73 63 |.*t1, *t|2;./* sc|
|00003350| 72 61 74 63 68 20 70 6f | 69 6e 74 65 72 73 20 2a |ratch po|inters *|
|00003360| 2f 0a 09 74 2d 3e 6c 61 | 73 74 20 3d 20 30 3b 0a |/..t->la|st = 0;.|
|00003370| 09 66 6f 72 20 28 74 31 | 20 3d 20 74 2d 3e 6c 73 |.for (t1| = t->ls|
|00003380| 6f 6e 2c 20 74 32 20 3d | 20 4e 55 4c 4c 3b 20 74 |on, t2 =| NULL; t|
|00003390| 31 20 21 3d 20 4e 55 4c | 4c 3b 20 74 32 20 3d 20 |1 != NUL|L; t2 = |
|000033a0| 74 31 2c 20 74 31 20 3d | 20 74 31 2d 3e 72 62 72 |t1, t1 =| t1->rbr|
|000033b0| 6f 74 68 65 72 29 0a 09 | 09 3b 0a 09 69 66 20 28 |other)..|.;..if (|
|000033c0| 74 32 20 21 3d 20 4e 55 | 4c 4c 29 0a 09 09 74 32 |t2 != NU|LL)...t2|
|000033d0| 2d 3e 6c 61 73 74 20 3d | 20 31 3b 0a 09 7d 0a 0a |->last =| 1;..}..|
|000033e0| 2f 2a 20 63 61 6c 63 75 | 6c 61 74 65 20 74 68 65 |/* calcu|late the|
|000033f0| 20 70 72 69 6e 74 20 63 | 6f 6c 75 6d 6e 73 20 2a | print c|olumns *|
|00003400| 2f 0a 76 6f 69 64 20 63 | 61 6c 63 5f 70 63 28 74 |/.void c|alc_pc(t|
|00003410| 29 0a 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |)..struc|t node.*|
|00003420| 74 3b 0a 09 7b 0a 09 73 | 74 72 75 63 74 20 6e 6f |t;..{..s|truct no|
|00003430| 64 65 09 2a 74 31 3b 09 | 09 2f 2a 20 73 63 72 61 |de.*t1;.|./* scra|
|00003440| 74 63 68 20 70 6f 69 6e | 74 65 72 20 2a 2f 0a 09 |tch poin|ter */..|
|00003450| 69 6e 74 09 09 09 63 3b | 09 09 2f 2a 20 63 6f 6c |int...c;|../* col|
|00003460| 75 6d 6e 20 73 75 6e 73 | 20 77 69 6c 6c 20 62 65 |umn suns| will be|
|00003470| 20 70 72 69 6e 74 65 64 | 20 69 6e 20 2a 2f 0a 0a | printed| in */..|
|00003480| 09 63 20 3d 20 74 2d 3e | 70 72 69 6e 74 5f 63 6f |.c = t->|print_co|
|00003490| 6c 20 2b 20 73 74 72 6c | 65 6e 28 74 2d 3e 6e 61 |l + strl|en(t->na|
|000034a0| 6d 65 29 20 2b 20 35 3b | 0a 09 66 6f 72 20 28 74 |me) + 5;|..for (t|
|000034b0| 31 20 3d 20 74 2d 3e 6c | 73 6f 6e 3b 20 74 31 20 |1 = t->l|son; t1 |
|000034c0| 21 3d 20 4e 55 4c 4c 3b | 20 74 31 20 3d 20 74 31 |!= NULL;| t1 = t1|
|000034d0| 2d 3e 72 62 72 6f 74 68 | 65 72 29 09 0a 09 09 74 |->rbroth|er)....t|
|000034e0| 31 2d 3e 70 72 69 6e 74 | 5f 63 6f 6c 20 3d 20 63 |1->print|_col = c|
|000034f0| 3b 0a 09 7d 0a 0a 2f 2a | 20 77 72 69 74 65 20 74 |;..}../*| write t|
|00003500| 68 65 20 6f 75 74 70 75 | 74 20 2a 2f 0a 76 6f 69 |he outpu|t */.voi|
|00003510| 64 20 6f 75 74 70 75 74 | 28 74 29 0a 09 73 74 72 |d output|(t)..str|
|00003520| 75 63 74 20 6e 6f 64 65 | 09 2a 74 3b 0a 09 7b 0a |uct node|.*t;..{.|
|00003530| 09 70 6f 73 69 74 69 6f | 6e 28 74 2d 3e 6c 6f 63 |.positio|n(t->loc|
|00003540| 29 3b 0a 09 70 72 69 6e | 74 66 28 22 2d 2d 25 73 |);..prin|tf("--%s|
|00003550| 25 73 22 2c 20 74 2d 3e | 6e 61 6d 65 2c 20 28 74 |%s", t->|name, (t|
|00003560| 2d 3e 6c 73 6f 6e 20 21 | 3d 20 4e 55 4c 4c 20 3f |->lson !|= NULL ?|
|00003570| 20 22 2d 2d 2b 22 20 3a | 20 22 22 29 29 3b 0a 09 | "--+" :| ""));..|
|00003580| 2f 2a 20 72 65 6d 6f 76 | 65 20 74 68 65 20 62 61 |/* remov|e the ba|
|00003590| 72 20 66 6f 72 20 6f 75 | 72 20 66 61 74 68 65 72 |r for ou|r father|
|000035a0| 20 69 66 20 77 65 20 61 | 72 65 20 74 68 65 20 6c | if we a|re the l|
|000035b0| 61 73 74 20 73 6f 6e 20 | 2a 2f 0a 09 69 66 20 28 |ast son |*/..if (|
|000035c0| 74 2d 3e 6c 61 73 74 29 | 0a 09 09 62 61 72 5f 63 |t->last)|...bar_c|
|000035d0| 6f 75 6e 74 2d 2d 3b 0a | 09 2f 2a 20 61 64 64 20 |ount--;.|./* add |
|000035e0| 74 68 65 20 6c 6f 63 61 | 74 69 6f 6e 20 6f 66 20 |the loca|tion of |
|000035f0| 74 68 65 20 62 61 72 20 | 74 6f 20 74 68 65 20 62 |the bar |to the b|
|00003600| 61 72 20 6c 69 73 74 20 | 69 66 20 77 65 20 68 61 |ar list |if we ha|
|00003610| 76 65 20 61 20 73 6f 6e | 20 2a 2f 0a 09 69 66 20 |ve a son| */..if |
|00003620| 28 74 2d 3e 6c 73 6f 6e | 20 21 3d 20 4e 55 4c 4c |(t->lson| != NULL|
|00003630| 29 0a 09 09 7b 0a 09 09 | 62 61 72 5f 6c 69 73 74 |)...{...|bar_list|
|00003640| 5b 62 61 72 5f 63 6f 75 | 6e 74 5d 20 3d 20 74 2d |[bar_cou|nt] = t-|
|00003650| 3e 70 72 69 6e 74 5f 63 | 6f 6c 20 2b 20 73 74 72 |>print_c|ol + str|
|00003660| 6c 65 6e 28 74 2d 3e 6e | 61 6d 65 29 20 2b 20 35 |len(t->n|ame) + 5|
|00003670| 20 2d 20 31 3b 0a 09 09 | 62 61 72 5f 63 6f 75 6e | - 1;...|bar_coun|
|00003680| 74 2b 2b 3b 0a 09 09 7d | 0a 09 7d 0a 0a 2f 2a 20 |t++;...}|..}../* |
|00003690| 70 6f 73 69 74 69 6f 6e | 20 74 6f 20 61 20 73 70 |position| to a sp|
|000036a0| 65 63 69 66 69 63 20 6c | 69 6e 65 20 2a 2f 0a 76 |ecific l|ine */.v|
|000036b0| 6f 69 64 20 70 6f 73 69 | 74 69 6f 6e 28 6c 69 6e |oid posi|tion(lin|
|000036c0| 65 29 0a 09 69 6e 74 09 | 6c 69 6e 65 3b 09 09 2f |e)..int.|line;../|
|000036d0| 2a 20 6c 69 6e 65 20 6e | 75 6d 62 65 72 20 2a 2f |* line n|umber */|
|000036e0| 0a 09 7b 0a 09 69 6e 74 | 09 69 3b 09 09 09 2f 2a |..{..int|.i;.../*|
|000036f0| 20 63 6f 75 6e 74 73 20 | 74 68 72 6f 75 67 68 20 | counts |through |
|00003700| 74 68 65 20 62 61 72 20 | 6c 69 73 74 20 2a 2f 0a |the bar |list */.|
|00003710| 09 69 6e 74 09 6a 3b 09 | 09 09 2f 2a 20 63 75 72 |.int.j;.|../* cur|
|00003720| 72 65 6e 74 20 63 6f 6c | 75 6d 6e 20 6e 75 6d 62 |rent col|umn numb|
|00003730| 65 72 20 2a 2f 0a 0a 09 | 2f 2a 20 66 6f 72 20 65 |er */...|/* for e|
|00003740| 76 65 72 79 20 6c 69 6e | 65 20 77 65 20 6e 65 65 |very lin|e we nee|
|00003750| 64 20 74 6f 20 67 6f 20 | 64 6f 77 6e 20 2a 2f 0a |d to go |down */.|
|00003760| 09 66 6f 72 20 28 3b 20 | 63 75 72 72 65 6e 74 5f |.for (; |current_|
|00003770| 6c 69 6e 65 20 3c 20 6c | 69 6e 65 3b 20 63 75 72 |line < l|ine; cur|
|00003780| 72 65 6e 74 5f 6c 69 6e | 65 2b 2b 29 0a 09 09 7b |rent_lin|e++)...{|
|00003790| 0a 09 09 70 75 74 63 68 | 61 72 28 27 5c 6e 27 29 |...putch|ar('\n')|
|000037a0| 3b 0a 09 09 2f 2a 20 70 | 72 69 6e 74 20 74 68 65 |;.../* p|rint the|
|000037b0| 20 62 61 72 73 20 66 6f | 72 20 74 68 69 73 20 6c | bars fo|r this l|
|000037c0| 69 6e 65 20 2a 2f 0a 09 | 09 6a 20 3d 20 30 3b 0a |ine */..|.j = 0;.|
|000037d0| 09 09 66 6f 72 20 28 69 | 20 3d 20 30 3b 20 69 20 |..for (i| = 0; i |
|000037e0| 3c 20 62 61 72 5f 63 6f | 75 6e 74 3b 20 69 2b 2b |< bar_co|unt; i++|
|000037f0| 29 0a 09 09 09 7b 0a 09 | 09 09 66 6f 72 20 28 3b |)....{..|..for (;|
|00003800| 20 6a 20 3c 20 62 61 72 | 5f 6c 69 73 74 5b 69 5d | j < bar|_list[i]|
|00003810| 3b 20 6a 2b 2b 29 0a 09 | 09 09 09 70 75 74 63 68 |; j++)..|...putch|
|00003820| 61 72 28 27 20 27 29 3b | 0a 09 09 09 69 66 20 28 |ar(' ');|....if (|
|00003830| 63 75 72 72 65 6e 74 5f | 6c 69 6e 65 20 3d 3d 20 |current_|line == |
|00003840| 6c 69 6e 65 2d 31 20 26 | 26 20 69 20 3d 3d 20 62 |line-1 &|& i == b|
|00003850| 61 72 5f 63 6f 75 6e 74 | 2d 31 29 0a 09 09 09 09 |ar_count|-1).....|
|00003860| 70 75 74 63 68 61 72 28 | 27 2b 27 29 3b 0a 09 09 |putchar(|'+');...|
|00003870| 09 65 6c 73 65 0a 09 09 | 09 09 70 75 74 63 68 61 |.else...|..putcha|
|00003880| 72 28 27 7c 27 29 3b 0a | 09 09 09 6a 2b 2b 3b 0a |r('|');.|...j++;.|
|00003890| 09 09 09 7d 0a 09 09 7d | 0a 09 7d 0a 23 69 66 20 |...}...}|..}.#if |
|000038a0| 30 0a 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |0.------|--------|
|000038b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000038c0| 2d 2d 2d 2d 2d 65 78 61 | 6d 70 6c 65 2d 2d 2d 2d |-----exa|mple----|
|000038d0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000038e0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 0a |--------|-------.|
|000038f0| 2d 2d 2e 2d 2d 2b 0a 20 | 20 20 20 20 7c 0a 20 20 |--.--+. | |. |
|00003900| 20 20 20 7c 0a 20 20 20 | 20 20 7c 0a 20 20 20 20 | |. | |. |
|00003910| 20 7c 0a 20 20 20 20 20 | 7c 0a 20 20 20 20 20 7c | |. ||. ||
|00003920| 0a 20 20 20 20 20 7c 0a | 20 20 20 20 20 2b 2d 2d |. |.| +--|
|00003930| 73 63 70 70 2d 2d 2b 2d | 2d 66 74 70 73 2d 2d 2b |scpp--+-|-ftps--+|
|00003940| 0a 20 20 20 20 20 7c 20 | 20 20 20 20 20 20 20 7c |. | | ||
|00003950| 20 20 20 20 20 20 20 20 | 2b 2d 2d 73 63 70 70 2d | |+--scpp-|
|00003960| 2d 2b 2d 2d 74 65 6d 70 | 0a 20 20 20 20 20 7c 20 |-+--temp|. | |
|00003970| 20 20 20 20 20 20 20 2b | 2d 2d 65 72 72 6f 72 0a | +|--error.|
|00003980| 20 20 20 20 20 7c 20 20 | 20 20 20 20 20 20 7c 0a | | | |.|
|00003990| 20 20 20 20 20 7c 20 20 | 20 20 20 20 20 20 2b 2d | | | +-|
|000039a0| 2d 73 68 61 72 2d 2d 2b | 0a 20 20 20 20 20 7c 20 |-shar--+|. | |
|000039b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000039c0| 7c 0a 20 20 20 20 20 7c | 20 20 20 20 20 20 20 20 ||. || |
|000039d0| 20 20 20 20 20 20 20 20 | 20 2b 2d 2d 74 65 6d 70 | | +--temp|
|000039e0| 0a 20 20 20 20 20 2b 2d | 2d 75 65 6d 61 63 73 2d |. +-|-uemacs-|
|000039f0| 2d 2b 2d 2d 75 65 6d 61 | 63 73 33 2e 39 0a 20 20 |-+--uema|cs3.9. |
|00003a00| 20 20 20 7c 0a 20 20 20 | 20 20 7c 0a 20 20 20 20 | |. | |. |
|00003a10| 20 7c 0a 20 20 20 20 20 | 7c 0a 20 20 20 20 20 7c | |. ||. ||
|00003a20| 0a 20 20 20 20 20 7c 0a | 20 20 20 20 20 2b 2d 2d |. |.| +--|
|00003a30| 70 61 74 63 68 2d 2d 2b | 2d 2d 64 69 73 74 0a 20 |patch--+|--dist. |
|00003a40| 20 20 20 20 7c 20 20 20 | 20 20 20 20 20 20 7c 0a | | | |.|
|00003a50| 20 20 20 20 20 7c 20 20 | 20 20 20 20 20 20 20 7c | | | ||
|00003a60| 0a 20 20 20 20 20 7c 20 | 20 20 20 20 20 20 20 20 |. | | |
|00003a70| 2b 2d 2d 62 75 69 6c 64 | 0a 20 20 20 20 20 7c 0a |+--build|. |.|
|00003a80| 20 20 20 20 20 7c 0a 20 | 20 20 20 20 7c 0a 20 20 | |. | |. |
|00003a90| 20 20 20 2b 2d 2d 73 63 | 63 73 2d 2d 2b 2d 2d 61 | +--sc|cs--+--a|
|00003aa0| 6c 6c 0a 20 20 20 20 20 | 7c 20 20 20 20 20 20 20 |ll. || |
|00003ab0| 20 7c 0a 20 20 20 20 20 | 7c 20 20 20 20 20 20 20 | |. || |
|00003ac0| 20 7c 0a 20 20 20 20 20 | 7c 20 20 20 20 20 20 20 | |. || |
|00003ad0| 20 7c 0a 20 20 20 20 20 | 7c 20 20 20 20 20 20 20 | |. || |
|00003ae0| 20 2b 2d 2d 28 65 74 63 | 2e 29 0a 20 20 20 20 20 | +--(etc|.). |
|00003af0| 2b 2d 2d 79 61 63 63 74 | 65 73 74 0a 20 20 20 20 |+--yacct|est. |
|00003b00| 20 7c 0a 20 20 20 20 20 | 7c 0a 20 20 20 20 20 7c | |. ||. ||
|00003b10| 0a 20 20 20 20 20 2b 2d | 2d 79 61 63 63 0a 20 20 |. +-|-yacc. |
|00003b20| 20 20 20 7c 0a 20 20 20 | 20 20 7c 0a 20 20 20 20 | |. | |. |
|00003b30| 20 7c 0a 20 20 20 20 20 | 2b 2d 2d 72 6e 73 65 6e | |. |+--rnsen|
|00003b40| 64 2d 2d 2b 2d 2d 64 69 | 73 74 31 0a 20 20 20 20 |d--+--di|st1. |
|00003b50| 20 7c 20 20 20 20 20 20 | 20 20 20 20 2b 2d 2d 64 | | | +--d|
|00003b60| 69 73 74 33 0a 20 20 20 | 20 20 7c 20 20 20 20 20 |ist3. | | |
|00003b70| 20 20 20 20 20 2b 2d 2d | 64 69 73 74 32 0a 20 20 | +--|dist2. |
|00003b80| 20 20 20 2b 2d 2d 62 69 | 6e 2d 2d 2b 0a 20 20 20 | +--bi|n--+. |
|00003b90| 20 20 7c 20 20 20 20 20 | 20 20 2b 2d 2d 73 6f 75 | | | +--sou|
|00003ba0| 72 63 65 0a 20 20 20 20 | 20 2b 2d 2d 73 6f 75 72 |rce. | +--sour|
|00003bb0| 63 65 73 0a 20 20 20 20 | 20 7c 0a 20 20 20 20 20 |ces. | |. |
|00003bc0| 2b 2d 2d 6b 77 66 72 6f | 62 0a 20 20 20 20 20 2b |+--kwfro|b. +|
|00003bd0| 2d 2d 72 73 74 73 2e 74 | 61 70 65 0a 20 20 20 20 |--rsts.t|ape. |
|00003be0| 20 2b 2d 2d 72 6e 65 77 | 73 0a 20 20 20 20 20 2b | +--rnew|s. +|
|00003bf0| 2d 2d 66 74 70 2d 73 65 | 72 76 65 72 0a 20 20 20 |--ftp-se|rver. |
|00003c00| 20 20 2b 2d 2d 28 65 74 | 63 2e 29 0a 0a 0a 0a 0a | +--(et|c.).....|
|00003c10| 0a 0a 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |..------|--------|
|00003c20| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003c30| 65 6e 64 20 6f 66 20 65 | 78 61 6d 70 6c 65 2d 2d |end of e|xample--|
|00003c40| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003c50| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 0a 2d 2d 20 |--------|----.-- |
|00003c60| 0a 44 61 6c 65 20 57 6f | 72 6c 65 79 20 20 20 20 |.Dale Wo|rley |
|00003c70| 43 75 6c 6c 69 6e 65 74 | 20 53 6f 66 74 77 61 72 |Cullinet| Softwar|
|00003c80| 65 20 20 20 20 20 20 41 | 52 50 41 3a 20 63 75 6c |e A|RPA: cul|
|00003c90| 64 65 76 31 21 64 72 77 | 40 65 64 64 69 65 2e 6d |dev1!drw|@eddie.m|
|00003ca0| 69 74 2e 65 64 75 0a 55 | 55 43 50 3a 20 2e 2e 2e |it.edu.U|UCP: ...|
|00003cb0| 21 73 65 69 73 6d 6f 21 | 68 61 72 76 61 72 64 21 |!seismo!|harvard!|
|00003cc0| 6d 69 74 2d 65 64 64 69 | 65 21 63 75 6c 64 65 76 |mit-eddi|e!culdev|
|00003cd0| 31 21 64 72 77 0a 4e 6f | 74 68 69 6e 67 20 73 68 |1!drw.No|thing sh|
|00003ce0| 6f 63 6b 73 20 6d 65 20 | 2d 2d 20 49 27 6d 20 61 |ocks me |-- I'm a|
|00003cf0| 20 73 63 69 65 6e 74 69 | 73 74 2e 0a 23 65 6e 64 | scienti|st..#end|
|00003d00| 69 66 0a 0a 0a 2f 2a 20 | 62 65 67 69 6e 20 6f 66 |if.../* |begin of|
|00003d10| 20 6e 65 77 20 63 6f 64 | 65 20 61 64 64 65 64 20 | new cod|e added |
|00003d20| 62 79 20 64 65 6e 6e 69 | 73 20 62 65 64 6e 61 72 |by denni|s bednar|
|00003d30| 20 2a 2f 0a 2f 2a 0a 20 | 2a 20 50 72 69 6e 74 20 | */./*. |* Print |
|00003d40| 74 68 65 20 66 75 6c 6c | 20 6e 61 6d 65 20 61 73 |the full| name as|
|00003d50| 73 6f 63 69 61 74 65 64 | 20 77 69 74 68 20 74 68 |sociated| with th|
|00003d60| 65 20 70 61 74 68 20 74 | 6f 20 74 68 69 73 20 63 |e path t|o this c|
|00003d70| 6f 6d 70 6f 6e 65 6e 74 | 2e 0a 20 2a 20 53 69 6e |omponent|.. * Sin|
|00003d80| 63 65 20 65 61 63 68 20 | 6e 6f 64 65 20 63 6f 6e |ce each |node con|
|00003d90| 74 61 69 6e 73 20 6f 6e | 6c 79 20 6f 6e 65 20 63 |tains on|ly one c|
|00003da0| 6f 6d 70 6f 6e 65 6e 74 | 20 6f 66 20 74 68 65 20 |omponent| of the |
|00003db0| 66 75 6c 6c 20 70 61 74 | 68 20 6e 61 6d 65 2c 0a |full pat|h name,.|
|00003dc0| 20 2a 20 69 6e 20 6f 72 | 64 65 72 20 74 6f 20 70 | * in or|der to p|
|00003dd0| 72 69 6e 74 20 6f 75 74 | 20 74 68 65 20 65 6e 74 |rint out| the ent|
|00003de0| 69 72 65 20 6e 61 6d 65 | 2c 20 77 65 20 68 61 76 |ire name|, we hav|
|00003df0| 65 20 74 6f 20 70 72 69 | 6e 74 20 74 68 65 0a 20 |e to pri|nt the. |
|00003e00| 2a 20 22 66 61 74 68 65 | 72 20 70 61 72 74 20 6f |* "fathe|r part o|
|00003e10| 66 20 74 68 65 20 63 6f | 6d 70 6f 6e 65 6e 74 22 |f the co|mponent"|
|00003e20| 2c 20 66 6f 6c 6c 6f 77 | 65 64 20 62 79 20 74 68 |, follow|ed by th|
|00003e30| 65 20 63 6f 6d 70 6f 6e | 65 6e 74 2e 0a 20 2a 20 |e compon|ent.. * |
|00003e40| 54 68 69 73 20 69 73 20 | 77 68 79 20 49 20 69 6e |This is |why I in|
|00003e50| 76 65 6e 74 65 64 20 74 | 68 65 20 22 66 61 74 68 |vented t|he "fath|
|00003e60| 65 72 22 20 75 70 20 70 | 6f 69 6e 74 65 72 2e 0a |er" up p|ointer..|
|00003e70| 20 2a 20 54 68 69 73 20 | 69 73 20 64 6f 6e 65 20 | * This |is done |
|00003e80| 72 65 63 75 72 73 69 76 | 65 6c 79 2c 20 49 20 6d |recursiv|ely, I m|
|00003e90| 69 67 68 74 20 61 64 64 | 2e 0a 20 2a 0a 20 2a 20 |ight add|.. *. * |
|00003ea0| 74 68 65 20 72 6f 6f 74 | 20 69 73 20 61 20 64 75 |the root| is a du|
|00003eb0| 6d 6d 79 20 68 6f 6c 64 | 65 72 2c 20 69 74 20 63 |mmy hold|er, it c|
|00003ec0| 6f 6e 74 61 69 6e 73 20 | 6e 6f 20 72 65 61 6c 20 |ontains |no real |
|00003ed0| 6e 61 6d 65 2e 0a 20 2a | 20 54 68 65 20 74 6f 70 |name.. *| The top|
|00003ee0| 20 6e 6f 64 65 20 77 68 | 69 63 68 20 63 6f 6e 74 | node wh|ich cont|
|00003ef0| 61 69 6e 73 20 74 68 65 | 20 66 69 72 73 74 20 72 |ains the| first r|
|00003f00| 65 61 6c 20 6e 61 6d 65 | 20 77 69 6c 6c 20 68 61 |eal name| will ha|
|00003f10| 76 65 0a 20 2a 20 61 20 | 66 61 74 68 65 72 20 70 |ve. * a |father p|
|00003f20| 6f 69 6e 74 65 72 20 74 | 6f 20 72 6f 6f 74 2e 0a |ointer t|o root..|
|00003f30| 20 2a 20 52 61 74 68 65 | 72 2c 20 72 6f 6f 74 20 | * Rathe|r, root |
|00003f40| 2d 3e 20 6c 73 6f 6e 20 | 63 6f 6e 74 61 69 6e 73 |-> lson |contains|
|00003f50| 20 74 68 65 20 66 69 72 | 73 74 20 72 65 61 6c 20 | the fir|st real |
|00003f60| 72 6f 6f 74 20 6f 66 20 | 74 68 65 20 74 72 65 65 |root of |the tree|
|00003f70| 2e 0a 20 2a 20 54 68 69 | 73 20 69 73 20 77 68 79 |.. * Thi|s is why|
|00003f80| 20 72 6f 6f 74 2d 3e 72 | 62 72 6f 74 68 65 72 20 | root->r|brother |
|00003f90| 69 73 20 4e 55 4c 4c 2e | 0a 20 2a 0a 20 2a 20 53 |is NULL.|. *. * S|
|00003fa0| 6f 20 64 6f 20 4e 4f 54 | 20 70 72 69 6e 74 20 74 |o do NOT| print t|
|00003fb0| 68 65 20 72 6f 6f 74 20 | 6e 6f 64 65 27 73 20 6e |he root |node's n|
|00003fc0| 61 6d 65 2e 0a 20 2a 20 | 41 6c 73 6f 2c 20 77 68 |ame.. * |Also, wh|
|00003fd0| 65 6e 20 70 72 69 6e 74 | 69 6e 67 20 72 6f 6f 74 |en print|ing root|
|00003fe0| 2d 3e 6c 73 6f 6e 27 73 | 20 66 61 74 68 65 72 2c |->lson's| father,|
|00003ff0| 20 69 74 20 77 69 6c 6c | 20 62 65 20 22 22 2e 0a | it will| be ""..|
|00004000| 20 2a 2f 0a 76 6f 69 64 | 0a 73 68 6f 77 5f 6e 6f | */.void|.show_no|
|00004010| 64 65 28 20 70 20 29 0a | 09 73 74 72 75 63 74 09 |de( p ).|.struct.|
|00004020| 6e 6f 64 65 09 2a 70 3b | 0a 7b 0a 09 69 66 20 28 |node.*p;|.{..if (|
|00004030| 70 20 3d 3d 20 72 6f 6f | 74 29 09 2f 2a 20 6a 75 |p == roo|t)./* ju|
|00004040| 73 74 20 61 20 70 6c 61 | 63 65 68 6f 6c 64 65 72 |st a pla|ceholder|
|00004050| 2c 20 69 74 73 20 6c 73 | 6f 6e 20 69 73 20 74 68 |, its ls|on is th|
|00004060| 65 20 72 65 61 6c 20 72 | 6f 6f 74 20 2a 2f 0a 09 |e real r|oot */..|
|00004070| 09 72 65 74 75 72 6e 3b | 09 2f 2a 20 64 6f 6e 27 |.return;|./* don'|
|00004080| 74 20 70 72 69 6e 74 20 | 6a 69 62 62 65 72 69 73 |t print |jibberis|
|00004090| 68 20 2a 2f 0a 0a 09 2f | 2a 20 61 76 6f 69 64 20 |h */.../|* avoid |
|000040a0| 70 72 69 6e 74 69 6e 67 | 20 72 6f 6f 74 27 73 20 |printing| root's |
|000040b0| 6c 73 6f 6e 20 6e 6f 64 | 65 20 77 68 6f 73 65 20 |lson nod|e whose |
|000040c0| 6e 61 6d 65 20 69 73 20 | 22 22 2e 0a 09 20 2a 20 |name is |""... * |
|000040d0| 54 68 69 73 20 6f 63 63 | 75 72 73 20 77 68 65 6e |This occ|urs when|
|000040e0| 20 66 69 72 73 74 20 6c | 69 6e 65 20 6f 66 20 73 | first l|ine of s|
|000040f0| 74 64 69 6e 20 63 6f 6e | 74 61 69 6e 73 20 61 0a |tdin con|tains a.|
|00004100| 09 20 2a 20 64 69 72 65 | 63 74 6f 72 79 20 6e 61 |. * dire|ctory na|
|00004110| 6d 65 20 62 65 67 69 6e | 6e 69 6e 67 20 77 69 74 |me begin|ning wit|
|00004120| 68 20 61 20 6c 65 61 64 | 69 6e 67 20 2f 2e 0a 09 |h a lead|ing /...|
|00004130| 20 2a 20 50 53 2c 20 73 | 69 6e 63 65 20 72 6f 6f | * PS, s|ince roo|
|00004140| 74 20 6e 6f 64 65 27 73 | 20 6e 61 6d 65 20 69 73 |t node's| name is|
|00004150| 20 61 6c 73 6f 20 22 22 | 2c 20 49 20 70 72 6f 62 | also ""|, I prob|
|00004160| 61 62 6c 79 20 63 6f 75 | 6c 64 20 72 65 6d 6f 76 |ably cou|ld remov|
|00004170| 65 0a 09 20 2a 20 74 68 | 65 20 22 69 66 22 20 63 |e.. * th|e "if" c|
|00004180| 68 65 63 6b 20 61 62 6f | 76 65 2c 20 61 6e 64 20 |heck abo|ve, and |
|00004190| 6c 65 74 20 74 68 69 73 | 20 69 66 20 73 74 6d 74 |let this| if stmt|
|000041a0| 20 64 6f 20 74 68 65 20 | 77 6f 72 6b 20 6f 66 0a | do the |work of.|
|000041b0| 09 20 2a 20 62 6f 74 68 | 2c 20 62 75 74 20 49 20 |. * both|, but I |
|000041c0| 64 69 64 6e 27 74 20 66 | 65 65 6c 20 6c 69 6b 65 |didn't f|eel like|
|000041d0| 20 69 74 2e 0a 09 20 2a | 2f 0a 09 69 66 20 28 70 | it... *|/..if (p|
|000041e0| 20 2d 3e 20 6e 61 6d 65 | 5b 30 5d 20 3d 3d 20 27 | -> name|[0] == '|
|000041f0| 5c 30 27 29 0a 09 09 72 | 65 74 75 72 6e 3b 0a 0a |\0')...r|eturn;..|
|00004200| 09 2f 2a 20 61 76 6f 69 | 64 20 70 72 69 6e 74 69 |./* avoi|d printi|
|00004210| 6e 67 20 2f 61 20 61 6e | 64 20 2f 62 20 77 68 6f |ng /a an|d /b who|
|00004220| 73 65 20 73 69 7a 65 20 | 69 73 20 7a 65 72 6f 2c |se size |is zero,|
|00004230| 20 6a 75 73 74 0a 09 20 | 2a 20 62 65 63 61 75 73 | just.. |* becaus|
|00004240| 65 20 77 65 20 64 69 64 | 20 61 20 22 64 75 20 2f |e we did| a "du /|
|00004250| 61 2f 62 2f 63 20 7c 20 | 64 75 6f 6e 6c 79 22 2e |a/b/c | |duonly".|
|00004260| 0a 09 20 2a 2f 0a 09 69 | 66 20 28 70 20 2d 3e 20 |.. */..i|f (p -> |
|00004270| 6d 65 5f 73 69 7a 65 20 | 3d 3d 20 30 4c 29 0a 09 |me_size |== 0L)..|
|00004280| 09 72 65 74 75 72 6e 3b | 0a 0a 2f 2a 09 70 72 69 |.return;|../*.pri|
|00004290| 6e 74 66 28 22 27 25 73 | 27 20 61 6e 64 20 6d 79 |ntf("'%s|' and my|
|000042a0| 20 66 61 74 68 65 72 20 | 69 73 20 3c 25 73 3e 5c | father |is <%s>\|
|000042b0| 6e 22 2c 20 70 20 2d 3e | 20 6e 61 6d 65 2c 20 70 |n", p ->| name, p|
|000042c0| 20 2d 3e 20 66 61 74 68 | 65 72 20 2d 3e 20 6e 61 | -> fath|er -> na|
|000042d0| 6d 65 29 3b 20 2a 2f 0a | 09 70 72 69 6e 74 66 28 |me); */.|.printf(|
|000042e0| 22 25 6c 64 5c 74 22 2c | 20 70 20 2d 3e 20 6d 65 |"%ld\t",| p -> me|
|000042f0| 5f 73 69 7a 65 29 3b 0a | 09 70 61 74 68 5f 70 72 |_size);.|.path_pr|
|00004300| 69 6e 74 28 70 29 3b 0a | 09 70 75 74 63 68 61 72 |int(p);.|.putchar|
|00004310| 28 20 27 5c 6e 27 20 29 | 3b 09 2f 2a 20 74 65 72 |( '\n' )|;./* ter|
|00004320| 6d 69 6e 61 74 65 20 6c | 69 6e 65 20 2a 2f 0a 7d |minate l|ine */.}|
|00004330| 0a 0a 2f 2a 0a 20 2a 20 | 72 65 63 75 72 73 69 76 |../*. * |recursiv|
|00004340| 65 6c 79 20 70 72 69 6e | 74 20 74 68 65 20 66 75 |ely prin|t the fu|
|00004350| 6c 6c 20 70 61 74 68 20 | 62 79 20 70 72 69 6e 74 |ll path |by print|
|00004360| 69 6e 67 20 74 68 65 20 | 22 70 61 72 74 20 62 65 |ing the |"part be|
|00004370| 66 6f 72 65 20 6d 65 22 | 2c 0a 20 2a 20 74 68 65 |fore me"|,. * the|
|00004380| 6e 20 70 72 69 6e 74 69 | 6e 67 20 6d 79 20 63 6f |n printi|ng my co|
|00004390| 6d 70 6f 6e 65 6e 74 20 | 6e 61 6d 65 2e 0a 20 2a |mponent |name.. *|
|000043a0| 2f 0a 70 61 74 68 5f 70 | 72 69 6e 74 28 20 70 20 |/.path_p|rint( p |
|000043b0| 29 0a 09 73 74 72 75 63 | 74 09 6e 6f 64 65 09 2a |)..struc|t.node.*|
|000043c0| 70 3b 0a 7b 0a 09 2f 2a | 20 74 68 69 73 20 73 68 |p;.{../*| this sh|
|000043d0| 6f 75 6c 64 20 6e 6f 74 | 20 65 76 65 72 20 68 61 |ould not| ever ha|
|000043e0| 70 70 65 6e 2c 20 62 65 | 63 61 75 73 65 20 6f 66 |ppen, be|cause of|
|000043f0| 20 68 6f 77 20 70 61 74 | 68 5f 70 72 69 6e 74 28 | how pat|h_print(|
|00004400| 29 20 69 73 20 77 72 69 | 74 74 65 6e 20 2a 2f 0a |) is wri|tten */.|
|00004410| 09 69 66 20 28 70 20 3d | 3d 20 4e 55 4c 4c 29 0a |.if (p =|= NULL).|
|00004420| 09 09 72 65 74 75 72 6e | 3b 09 09 2f 2a 20 70 61 |..return|;../* pa|
|00004430| 72 61 6e 65 6e 6f 69 64 | 20 2a 2f 0a 0a 09 2f 2a |ranenoid| */.../*|
|00004440| 20 74 68 69 73 20 63 6f | 64 65 20 69 73 20 73 74 | this co|de is st|
|00004450| 72 75 63 74 75 72 65 64 | 20 73 6f 20 74 68 61 74 |ructured| so that|
|00004460| 20 61 20 6c 65 61 64 69 | 6e 67 20 73 6c 61 73 68 | a leadi|ng slash|
|00004470| 20 77 69 6c 6c 20 4e 4f | 54 0a 09 20 2a 20 62 65 | will NO|T.. * be|
|00004480| 20 70 72 69 6e 74 65 64 | 20 62 65 66 6f 72 65 20 | printed| before |
|00004490| 74 68 65 20 66 69 72 73 | 74 20 63 6f 6d 70 6f 6e |the firs|t compon|
|000044a0| 65 6e 74 2c 20 62 75 74 | 20 72 61 74 68 65 72 20 |ent, but| rather |
|000044b0| 4f 4e 4c 59 0a 09 20 2a | 20 62 65 74 77 65 65 6e |ONLY.. *| between|
|000044c0| 20 61 6c 6c 20 63 6f 6d | 70 6f 6e 65 6e 74 73 2c | all com|ponents,|
|000044d0| 20 61 6e 64 20 4e 4f 54 | 20 61 66 74 65 72 20 74 | and NOT| after t|
|000044e0| 68 65 20 6c 61 73 74 20 | 63 6f 6d 70 6f 6e 65 6e |he last |componen|
|000044f0| 74 2e 0a 09 20 2a 2f 0a | 09 69 66 20 28 70 20 2d |t... */.|.if (p -|
|00004500| 3e 20 66 61 74 68 65 72 | 20 3d 3d 20 72 6f 6f 74 |> father| == root|
|00004510| 29 0a 09 09 7b 0a 09 09 | 70 72 69 6e 74 66 28 22 |)...{...|printf("|
|00004520| 25 73 22 2c 20 70 20 2d | 3e 6e 61 6d 65 20 29 3b |%s", p -|>name );|
|00004530| 0a 09 09 72 65 74 75 72 | 6e 3b 0a 09 09 7d 0a 09 |...retur|n;...}..|
|00004540| 65 6c 73 65 0a 09 09 7b | 0a 09 09 2f 2a 20 72 65 |else...{|.../* re|
|00004550| 63 75 72 73 69 6f 6e 20 | 2a 2f 0a 09 09 70 61 74 |cursion |*/...pat|
|00004560| 68 5f 70 72 69 6e 74 28 | 20 70 20 2d 3e 20 66 61 |h_print(| p -> fa|
|00004570| 74 68 65 72 20 29 3b 09 | 2f 2a 20 70 72 69 6e 74 |ther );.|/* print|
|00004580| 20 63 6f 6d 70 6f 6e 65 | 6e 74 73 20 62 65 66 6f | compone|nts befo|
|00004590| 72 65 20 6d 65 20 2a 2f | 0a 09 09 70 72 69 6e 74 |re me */|...print|
|000045a0| 66 28 20 22 2f 25 73 22 | 2c 20 70 20 2d 3e 20 6e |f( "/%s"|, p -> n|
|000045b0| 61 6d 65 20 29 3b 09 2f | 2a 20 70 72 69 6e 74 20 |ame );./|* print |
|000045c0| 6d 79 20 63 6f 6d 70 6f | 6e 65 6e 74 20 2a 2f 0a |my compo|nent */.|
|000045d0| 09 09 7d 0a 7d 0a 0a 2f | 2a 0a 20 2a 20 63 6f 6d |..}.}../|*. * com|
|000045e0| 70 75 74 65 20 73 69 7a | 65 20 6f 66 20 74 68 69 |pute siz|e of thi|
|000045f0| 73 20 64 69 72 65 63 74 | 6f 72 79 20 6f 6e 6c 79 |s direct|ory only|
|00004600| 2c 20 69 65 20 64 6f 6e | 27 74 20 69 6e 63 6c 75 |, ie don|'t inclu|
|00004610| 64 65 0a 20 2a 20 73 69 | 7a 65 20 6f 66 20 63 68 |de. * si|ze of ch|
|00004620| 69 6c 64 72 65 6e 20 64 | 69 72 65 63 74 6f 72 69 |ildren d|irectori|
|00004630| 65 73 2e 20 20 54 68 69 | 73 20 6c 65 61 76 65 73 |es. Thi|s leaves|
|00004640| 20 73 70 61 63 65 20 6f | 6e 6c 79 0a 20 2a 20 6f | space o|nly. * o|
|00004650| 63 63 75 70 69 65 64 20 | 62 79 20 74 68 69 73 20 |ccupied |by this |
|00004660| 64 69 72 65 63 74 6f 72 | 79 20 72 65 6d 61 69 6e |director|y remain|
|00004670| 69 6e 67 20 69 6e 20 74 | 68 65 20 22 6d 65 5f 73 |ing in t|he "me_s|
|00004680| 69 7a 65 22 2e 0a 20 2a | 2f 0a 76 6f 69 64 0a 6d |ize".. *|/.void.m|
|00004690| 79 5f 73 70 61 63 65 28 | 20 70 20 29 0a 09 73 74 |y_space(| p )..st|
|000046a0| 72 75 63 74 09 6e 6f 64 | 65 09 2a 70 3b 0a 7b 0a |ruct.nod|e.*p;.{.|
|000046b0| 09 6c 6f 6e 67 09 74 6f | 74 61 6c 20 3d 20 30 3b |.long.to|tal = 0;|
|000046c0| 0a 09 73 74 72 75 63 74 | 09 6e 6f 64 65 09 2a 73 |..struct|.node.*s|
|000046d0| 3b 09 2f 2a 20 65 61 63 | 68 20 73 6f 6e 20 6f 66 |;./* eac|h son of|
|000046e0| 20 74 68 65 20 70 61 72 | 65 6e 74 20 70 20 2a 2f | the par|ent p */|
|000046f0| 0a 0a 09 74 6f 74 61 6c | 20 3d 20 70 20 2d 3e 20 |...total| = p -> |
|00004700| 73 69 7a 65 3b 09 2f 2a | 20 62 6c 6f 63 6b 73 20 |size;./*| blocks |
|00004710| 75 73 65 64 20 62 79 20 | 74 68 69 73 20 64 69 72 |used by |this dir|
|00004720| 65 63 74 6f 72 79 20 2a | 2f 0a 0a 09 2f 2a 20 73 |ectory *|/.../* s|
|00004730| 75 62 74 72 61 63 74 20 | 62 6c 6f 63 6b 73 20 75 |ubtract |blocks u|
|00004740| 73 65 64 20 62 79 20 69 | 6d 6d 65 64 69 61 74 65 |sed by i|mmediate|
|00004750| 20 63 68 69 6c 64 72 65 | 6e 20 64 69 72 65 63 74 | childre|n direct|
|00004760| 6f 72 69 65 73 2e 0a 09 | 20 2a 20 57 49 4c 4c 20 |ories...| * WILL |
|00004770| 4e 4f 54 20 57 4f 52 4b | 20 43 4f 52 52 45 43 54 |NOT WORK| CORRECT|
|00004780| 4c 59 20 69 66 20 61 20 | 63 68 69 6c 64 20 69 73 |LY if a |child is|
|00004790| 20 61 20 66 69 6c 65 20 | 21 21 21 21 21 0a 09 20 | a file |!!!!!.. |
|000047a0| 2a 20 74 68 69 73 20 77 | 69 6c 6c 20 6c 65 61 76 |* this w|ill leav|
|000047b0| 65 20 74 6f 74 61 6c 20 | 63 6f 6e 74 61 69 6e 69 |e total |containi|
|000047c0| 6e 67 20 6f 6e 6c 79 20 | 74 68 65 20 6e 75 6d 62 |ng only |the numb|
|000047d0| 65 72 20 6f 66 20 62 6c | 6f 63 6b 73 0a 09 20 2a |er of bl|ocks.. *|
|000047e0| 20 69 6e 20 74 68 69 73 | 20 64 69 72 65 63 74 6f | in this| directo|
|000047f0| 72 79 2e 0a 09 20 2a 2f | 0a 09 66 6f 72 20 28 20 |ry... */|..for ( |
|00004800| 73 20 3d 20 70 20 2d 3e | 20 6c 73 6f 6e 3b 20 73 |s = p ->| lson; s|
|00004810| 3b 20 73 20 3d 20 73 20 | 2d 3e 20 72 62 72 6f 74 |; s = s |-> rbrot|
|00004820| 68 65 72 29 0a 09 09 74 | 6f 74 61 6c 20 2d 3d 20 |her)...t|otal -= |
|00004830| 73 20 2d 3e 20 73 69 7a | 65 3b 0a 0a 09 2f 2a 20 |s -> siz|e;.../* |
|00004840| 73 74 6f 72 65 20 6d 79 | 20 73 69 7a 65 20 6f 6e |store my| size on|
|00004850| 6c 79 20 66 6f 72 20 74 | 68 69 73 20 70 61 72 65 |ly for t|his pare|
|00004860| 6e 74 20 2a 2f 0a 09 70 | 20 2d 3e 20 6d 65 5f 73 |nt */..p| -> me_s|
|00004870| 69 7a 65 20 3d 20 74 6f | 74 61 6c 3b 0a 7d 0a 0a |ize = to|tal;.}..|
|00004880| 2f 2a 0a 20 2a 20 73 6f | 72 74 20 74 68 65 20 64 |/*. * so|rt the d|
|00004890| 69 72 65 63 74 6f 72 69 | 65 73 20 75 6e 64 65 72 |irectori|es under|
|000048a0| 20 61 20 64 69 72 65 63 | 74 6f 72 79 20 62 79 20 | a direc|tory by |
|000048b0| 6e 61 6d 65 2e 0a 20 2a | 0a 20 2a 20 74 68 69 73 |name.. *|. * this|
|000048c0| 20 69 73 20 6a 75 73 74 | 20 74 68 65 20 6f 6c 64 | is just| the old|
|000048d0| 20 22 73 6f 72 74 28 29 | 22 20 72 6f 75 74 69 6e | "sort()|" routin|
|000048e0| 65 20 5b 73 6f 72 74 28 | 29 20 72 65 6e 61 6d 65 |e [sort(|) rename|
|000048f0| 64 20 74 6f 0a 20 2a 20 | 73 6f 72 74 5f 73 69 7a |d to. * |sort_siz|
|00004900| 65 28 29 20 66 6f 72 20 | 63 6c 61 72 69 74 79 5d |e() for |clarity]|
|00004910| 20 77 69 74 68 20 61 20 | 6d 69 6e 6f 72 20 63 68 | with a |minor ch|
|00004920| 61 6e 67 65 2c 20 77 68 | 65 72 65 0a 20 2a 20 77 |ange, wh|ere. * w|
|00004930| 65 20 6e 6f 77 20 63 6f | 6d 70 61 72 65 20 6e 61 |e now co|mpare na|
|00004940| 6d 65 73 2c 20 6e 6f 74 | 20 73 69 7a 65 2e 20 20 |mes, not| size. |
|00004950| 54 68 61 74 20 69 73 2c | 20 77 65 20 73 6f 72 74 |That is,| we sort|
|00004960| 0a 20 2a 20 74 68 65 20 | 62 72 6f 74 68 65 72 73 |. * the |brothers|
|00004970| 20 6f 72 20 70 65 65 72 | 73 20 61 74 20 65 61 63 | or peer|s at eac|
|00004980| 68 20 6c 65 76 65 6c 2e | 0a 20 2a 20 53 45 45 20 |h level.|. * SEE |
|00004990| 41 4c 53 4f 20 74 68 65 | 20 61 6e 6f 6d 6f 6c 79 |ALSO the| anomoly|
|000049a0| 20 63 6f 6e 63 65 72 6e | 69 6e 67 20 22 2e 22 20 | concern|ing "." |
|000049b0| 61 6e 64 20 22 2f 22 20 | 77 69 74 68 20 72 65 67 |and "/" |with reg|
|000049c0| 61 72 64 73 0a 20 2a 20 | 74 6f 20 73 6f 72 74 69 |ards. * |to sorti|
|000049d0| 6e 67 2c 20 64 65 73 63 | 72 69 62 65 64 20 61 74 |ng, desc|ribed at|
|000049e0| 20 74 68 65 20 74 6f 70 | 20 6f 66 20 74 68 69 73 | the top| of this|
|000049f0| 20 66 69 6c 65 2e 0a 20 | 2a 2f 0a 76 6f 69 64 20 | file.. |*/.void |
|00004a00| 73 6f 72 74 5f 6e 61 6d | 65 28 74 29 0a 09 73 74 |sort_nam|e(t)..st|
|00004a10| 72 75 63 74 20 6e 6f 64 | 65 09 2a 74 3b 0a 09 7b |ruct nod|e.*t;..{|
|00004a20| 0a 09 73 74 72 75 63 74 | 20 6e 6f 64 65 09 2a 70 |..struct| node.*p|
|00004a30| 31 2c 20 2a 70 32 2c 20 | 2a 70 33 2c 20 2a 70 70 |1, *p2, |*p3, *pp|
|00004a40| 3b 09 09 2f 2a 20 73 63 | 72 61 74 63 68 20 70 6f |;../* sc|ratch po|
|00004a50| 69 6e 74 65 72 73 20 2a | 2f 0a 09 69 6e 74 09 09 |inters *|/..int..|
|00004a60| 09 6e 6f 64 65 73 2c 20 | 6e 3b 09 09 09 09 2f 2a |.nodes, |n;..../*|
|00004a70| 20 73 63 72 61 74 63 68 | 20 2a 2f 0a 09 69 6e 74 | scratch| */..int|
|00004a80| 09 63 6d 70 3b 0a 0a 09 | 2f 2a 20 63 6f 75 6e 74 |.cmp;...|/* count|
|00004a90| 20 74 68 65 20 6e 75 6d | 62 65 72 20 6f 66 20 6e | the num|ber of n|
|00004aa0| 6f 64 65 73 20 2a 2f 0a | 09 6e 6f 64 65 73 20 3d |odes */.|.nodes =|
|00004ab0| 20 30 3b 0a 09 66 6f 72 | 20 28 70 31 20 3d 20 74 | 0;..for| (p1 = t|
|00004ac0| 2d 3e 6c 73 6f 6e 3b 20 | 70 31 20 21 3d 20 4e 55 |->lson; |p1 != NU|
|00004ad0| 4c 4c 3b 20 70 31 20 3d | 20 70 31 2d 3e 72 62 72 |LL; p1 =| p1->rbr|
|00004ae0| 6f 74 68 65 72 29 0a 09 | 09 6e 6f 64 65 73 2b 2b |other)..|.nodes++|
|00004af0| 3b 0a 09 2f 2a 20 6a 75 | 73 74 20 61 20 73 69 6d |;../* ju|st a sim|
|00004b00| 70 6c 65 20 61 6e 64 20 | 69 6e 65 66 66 69 63 69 |ple and |ineffici|
|00004b10| 65 6e 74 20 62 75 62 62 | 6c 65 20 73 6f 72 74 20 |ent bubb|le sort |
|00004b20| 2a 2f 0a 09 66 6f 72 20 | 28 6e 20 3d 20 31 3b 20 |*/..for |(n = 1; |
|00004b30| 6e 20 3c 20 6e 6f 64 65 | 73 3b 20 6e 2b 2b 29 0a |n < node|s; n++).|
|00004b40| 09 09 66 6f 72 20 28 70 | 31 20 3d 20 4e 55 4c 4c |..for (p|1 = NULL|
|00004b50| 2c 20 70 32 20 3d 20 74 | 2d 3e 6c 73 6f 6e 2c 20 |, p2 = t|->lson, |
|00004b60| 70 33 20 3d 20 70 32 2d | 3e 72 62 72 6f 74 68 65 |p3 = p2-|>rbrothe|
|00004b70| 72 3b 20 70 33 20 21 3d | 20 4e 55 4c 4c 3b 0a 09 |r; p3 !=| NULL;..|
|00004b80| 09 09 09 70 31 20 3d 20 | 70 32 2c 20 70 32 20 3d |...p1 = |p2, p2 =|
|00004b90| 20 70 33 2c 20 70 33 20 | 3d 20 70 33 2d 3e 72 62 | p3, p3 |= p3->rb|
|00004ba0| 72 6f 74 68 65 72 29 0a | 09 09 09 7b 0a 09 09 09 |rother).|...{....|
|00004bb0| 63 6d 70 20 3d 20 73 74 | 72 63 6d 70 28 20 70 32 |cmp = st|rcmp( p2|
|00004bc0| 20 2d 3e 20 6e 61 6d 65 | 2c 20 70 33 20 2d 3e 20 | -> name|, p3 -> |
|00004bd0| 6e 61 6d 65 20 29 3b 0a | 09 09 09 69 66 20 28 63 |name );.|...if (c|
|00004be0| 6d 70 20 3e 20 30 29 09 | 2f 2a 20 6e 6f 74 20 61 |mp > 0).|/* not a|
|00004bf0| 6c 70 68 61 62 65 74 69 | 7a 65 64 2c 20 70 33 20 |lphabeti|zed, p3 |
|00004c00| 31 73 74 2c 20 70 32 20 | 32 6e 64 20 2a 2f 0a 09 |1st, p2 |2nd */..|
|00004c10| 09 09 09 7b 0a 09 09 09 | 09 2f 2a 20 65 78 63 68 |...{....|./* exch|
|00004c20| 61 6e 67 65 20 74 68 65 | 20 6e 6f 64 65 73 20 70 |ange the| nodes p|
|00004c30| 32 20 61 6e 64 20 70 33 | 20 2a 2f 0a 09 09 09 09 |2 and p3| */.....|
|00004c40| 70 70 20 3d 20 70 33 2d | 3e 72 62 72 6f 74 68 65 |pp = p3-|>rbrothe|
|00004c50| 72 3b 0a 09 09 09 09 70 | 33 2d 3e 72 62 72 6f 74 |r;.....p|3->rbrot|
|00004c60| 68 65 72 20 3d 20 70 32 | 3b 0a 09 09 09 09 70 32 |her = p2|;.....p2|
|00004c70| 2d 3e 72 62 72 6f 74 68 | 65 72 20 3d 20 70 70 3b |->rbroth|er = pp;|
|00004c80| 0a 09 09 09 09 69 66 20 | 28 70 31 20 21 3d 20 4e |.....if |(p1 != N|
|00004c90| 55 4c 4c 29 0a 09 09 09 | 09 09 70 31 2d 3e 72 62 |ULL)....|..p1->rb|
|00004ca0| 72 6f 74 68 65 72 20 3d | 20 70 33 3b 0a 09 09 09 |rother =| p3;....|
|00004cb0| 09 65 6c 73 65 0a 09 09 | 09 09 09 74 2d 3e 6c 73 |.else...|...t->ls|
|00004cc0| 6f 6e 20 3d 20 70 33 3b | 0a 09 09 09 09 2f 2a 20 |on = p3;|...../* |
|00004cd0| 65 78 63 68 61 6e 67 65 | 20 74 68 65 20 76 61 6c |exchange| the val|
|00004ce0| 75 65 73 20 6f 66 20 70 | 32 20 61 6e 64 20 70 33 |ues of p|2 and p3|
|00004cf0| 20 2a 2f 0a 09 09 09 09 | 70 70 20 3d 20 70 32 3b | */.....|pp = p2;|
|00004d00| 0a 09 09 09 09 70 32 20 | 3d 20 70 33 3b 0a 09 09 |.....p2 |= p3;...|
|00004d10| 09 09 70 33 20 3d 20 70 | 70 3b 0a 09 09 09 09 7d |..p3 = p|p;.....}|
|00004d20| 0a 09 09 09 7d 0a 09 7d | 0a 0a 5c 53 48 41 52 5f |....}..}|..\SHAR_|
|00004d30| 45 4f 46 0a 23 20 2e 2e | 2e 2e 2e 2e 2e 2e 2e 2e |EOF.# ..|........|
|00004d40| 2e 2e 20 20 20 20 46 20 | 20 49 20 20 20 4c 20 20 |.. F | I L |
|00004d50| 20 45 20 20 20 20 20 20 | 45 20 20 4e 20 20 44 20 | E |E N D |
|00004d60| 20 2e 2e 2e 2e 2e 2e 2e | 2e 2e 2e 20 64 75 6f 6e | .......|... duon|
|00004d70| 6c 79 2e 63 0a 66 69 20 | 23 20 65 6e 64 20 6f 66 |ly.c.fi |# end of|
|00004d80| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|00004d90| 63 6b 0a 69 66 20 74 65 | 73 74 20 2d 66 20 64 75 |ck.if te|st -f du|
|00004da0| 6f 6e 6c 79 2e 68 65 6c | 70 0a 74 68 65 6e 0a 65 |only.hel|p.then.e|
|00004db0| 63 68 6f 20 73 68 61 72 | 3a 20 77 69 6c 6c 20 6e |cho shar|: will n|
|00004dc0| 6f 74 20 6f 76 65 72 2d | 77 72 69 74 65 20 65 78 |ot over-|write ex|
|00004dd0| 69 73 74 69 6e 67 20 66 | 69 6c 65 20 27 64 75 6f |isting f|ile 'duo|
|00004de0| 6e 6c 79 2e 68 65 6c 70 | 27 0a 65 6c 73 65 0a 65 |nly.help|'.else.e|
|00004df0| 63 68 6f 20 78 20 2d 20 | 64 75 6f 6e 6c 79 2e 68 |cho x - |duonly.h|
|00004e00| 65 6c 70 0a 23 20 2e 2e | 2e 2e 2e 2e 2e 2e 2e 2e |elp.# ..|........|
|00004e10| 2e 2e 20 20 20 20 46 20 | 20 49 20 20 20 4c 20 20 |.. F | I L |
|00004e20| 20 45 20 20 20 20 20 20 | 42 20 20 45 20 20 47 20 | E |B E G |
|00004e30| 20 2e 2e 2e 2e 2e 2e 2e | 2e 2e 2e 20 64 75 6f 6e | .......|... duon|
|00004e40| 6c 79 2e 68 65 6c 70 0a | 63 61 74 20 3c 3c 20 27 |ly.help.|cat << '|
|00004e50| 5c 53 48 41 52 5f 45 4f | 46 27 20 3e 20 64 75 6f |\SHAR_EO|F' > duo|
|00004e60| 6e 6c 79 2e 68 65 6c 70 | 0a 64 75 6f 6e 6c 79 0a |nly.help|.duonly.|
|00004e70| 0a 50 72 69 6e 74 73 20 | 64 69 73 6b 20 75 73 61 |.Prints |disk usa|
|00004e80| 67 65 20 62 6c 6f 63 6b | 20 73 69 7a 65 73 20 6f |ge block| sizes o|
|00004e90| 6e 6c 79 20 66 6f 72 20 | 64 69 72 65 63 74 6f 72 |nly for |director|
|00004ea0| 69 65 73 2c 0a 62 75 74 | 20 4e 4f 54 20 69 6e 63 |ies,.but| NOT inc|
|00004eb0| 6c 75 64 69 6e 67 20 73 | 69 7a 65 73 20 63 6f 6e |luding s|izes con|
|00004ec0| 74 72 69 62 75 74 65 64 | 20 62 79 20 73 75 62 2d |tributed| by sub-|
|00004ed0| 64 69 72 65 63 74 6f 72 | 69 65 73 2e 0a 0a 54 68 |director|ies...Th|
|00004ee0| 69 73 20 74 6f 6f 6c 20 | 77 61 73 20 64 65 76 65 |is tool |was deve|
|00004ef0| 6c 6f 70 65 64 20 62 65 | 63 61 75 73 65 20 77 68 |loped be|cause wh|
|00004f00| 65 6e 20 76 69 65 77 69 | 6e 67 20 74 68 65 20 6f |en viewi|ng the o|
|00004f10| 75 74 70 75 74 20 6f 66 | 20 61 0a 72 65 67 75 6c |utput of| a.regul|
|00004f20| 61 72 20 64 75 2c 20 69 | 74 20 77 61 73 20 64 69 |ar du, i|t was di|
|00004f30| 66 66 69 63 75 6c 74 20 | 74 6f 20 73 65 65 20 77 |fficult |to see w|
|00004f40| 68 69 63 68 20 64 69 72 | 65 63 74 6f 72 69 65 73 |hich dir|ectories|
|00004f50| 20 77 65 72 65 0a 74 68 | 65 20 72 65 61 6c 20 63 | were.th|e real c|
|00004f60| 75 6c 70 72 69 74 73 20 | 66 6f 72 20 6f 63 63 75 |ulprits |for occu|
|00004f70| 70 79 69 6e 67 20 74 68 | 65 20 6d 6f 73 74 20 6e |pying th|e most n|
|00004f80| 75 6d 62 65 72 20 6f 66 | 20 64 69 73 6b 20 62 6c |umber of| disk bl|
|00004f90| 6f 63 6b 73 2e 0a 46 6f | 72 20 65 78 61 6d 70 6c |ocks..Fo|r exampl|
|00004fa0| 65 2c 20 69 66 20 79 6f | 75 20 64 69 64 20 61 20 |e, if yo|u did a |
|00004fb0| 22 64 75 20 2f 75 73 72 | 22 2c 20 74 68 65 20 6c |"du /usr|", the l|
|00004fc0| 61 73 74 20 6c 69 6e 65 | 20 77 6f 75 6c 64 20 62 |ast line| would b|
|00004fd0| 65 0a 73 6f 6d 65 74 68 | 69 6e 67 20 6c 69 6b 65 |e.someth|ing like|
|00004fe0| 3a 0a 0a 31 38 31 31 32 | 09 2f 75 73 72 0a 0a 65 |:..18112|./usr..e|
|00004ff0| 76 65 6e 20 74 68 6f 75 | 67 68 20 2f 75 73 72 20 |ven thou|gh /usr |
|00005000| 6d 69 67 68 74 20 6f 6e | 6c 79 20 63 6f 6e 74 61 |might on|ly conta|
|00005010| 69 6e 20 73 75 62 2d 64 | 69 72 65 63 74 6f 72 69 |in sub-d|irectori|
|00005020| 65 73 2c 20 62 75 74 20 | 6e 6f 20 66 69 6c 65 73 |es, but |no files|
|00005030| 2e 0a 48 65 6e 63 65 2c | 20 69 74 20 6d 69 67 68 |..Hence,| it migh|
|00005040| 74 20 62 65 20 74 68 61 | 74 20 61 20 73 75 62 2d |t be tha|t a sub-|
|00005050| 64 69 72 65 63 74 6f 72 | 79 20 6f 66 20 2f 75 73 |director|y of /us|
|00005060| 72 20 77 61 73 20 74 68 | 65 20 72 65 61 6c 0a 63 |r was th|e real.c|
|00005070| 75 6c 70 72 69 74 20 66 | 6f 72 20 62 65 69 6e 67 |ulprit f|or being|
|00005080| 20 61 20 64 69 73 6b 20 | 68 6f 67 2c 20 61 6e 64 | a disk |hog, and|
|00005090| 20 6e 6f 74 20 2f 75 73 | 72 20 28 6f 72 20 61 20 | not /us|r (or a |
|000050a0| 73 75 62 2d 73 75 62 2d | 64 69 72 65 63 74 6f 72 |sub-sub-|director|
|000050b0| 79 2c 0a 65 74 63 2e 2c | 20 6f 66 20 2f 75 73 72 |y,.etc.,| of /usr|
|000050c0| 20 6d 69 67 68 74 20 62 | 65 20 74 68 65 20 63 75 | might b|e the cu|
|000050d0| 6c 70 72 69 74 29 2e 0a | 0a 44 75 6f 6e 6c 79 20 |lprit)..|.Duonly |
|000050e0| 69 73 20 64 65 73 69 67 | 6e 65 64 20 74 6f 20 72 |is desig|ned to r|
|000050f0| 65 61 64 20 73 74 61 6e | 64 61 72 64 20 69 6e 70 |ead stan|dard inp|
|00005100| 75 74 20 67 65 6e 65 72 | 61 74 65 64 20 62 79 20 |ut gener|ated by |
|00005110| 22 64 75 22 2c 20 61 6e | 64 20 70 72 69 6e 74 0a |"du", an|d print.|
|00005120| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 69 6e 20 74 |informat|ion in t|
|00005130| 68 65 20 73 61 6d 65 20 | 73 74 79 6c 65 20 61 73 |he same |style as|
|00005140| 20 64 75 3a 0a 0a 73 69 | 7a 65 09 64 69 72 65 63 | du:..si|ze.direc|
|00005150| 74 6f 72 79 5f 6e 61 6d | 65 0a 0a 48 6f 77 65 76 |tory_nam|e..Howev|
|00005160| 65 72 2c 20 74 68 65 20 | 73 69 7a 65 20 72 65 70 |er, the |size rep|
|00005170| 6f 72 74 65 64 20 62 79 | 20 64 75 6f 6e 6c 79 20 |orted by| duonly |
|00005180| 69 73 20 74 68 65 20 73 | 69 7a 65 20 69 6e 20 62 |is the s|ize in b|
|00005190| 6c 6f 63 6b 73 0a 63 6f | 6e 74 72 69 62 75 74 65 |locks.co|ntribute|
|000051a0| 64 20 22 4f 4e 4c 59 20 | 62 79 20 74 68 65 20 64 |d "ONLY |by the d|
|000051b0| 69 72 65 63 74 6f 72 79 | 5f 6e 61 6d 65 20 69 74 |irectory|_name it|
|000051c0| 73 65 6c 66 2c 20 69 6e | 63 6c 75 64 69 6e 67 0a |self, in|cluding.|
|000051d0| 74 68 65 20 73 75 6d 20 | 6f 66 20 74 68 65 20 73 |the sum |of the s|
|000051e0| 69 7a 65 73 20 6f 66 20 | 61 6c 6c 20 72 65 67 75 |izes of |all regu|
|000051f0| 6c 61 72 20 66 69 6c 65 | 73 20 64 69 72 65 63 74 |lar file|s direct|
|00005200| 6c 79 20 62 65 6e 65 61 | 74 68 0a 64 69 72 65 63 |ly benea|th.direc|
|00005210| 74 6f 72 79 5f 6e 61 6d | 65 22 2e 20 20 49 74 20 |tory_nam|e". It |
|00005220| 64 6f 65 73 20 4e 4f 54 | 20 69 6e 63 6c 75 64 65 |does NOT| include|
|00005230| 20 74 68 65 20 73 69 7a | 65 73 20 69 6e 68 65 72 | the siz|es inher|
|00005240| 69 74 65 64 0a 62 79 20 | 41 4e 59 20 6f 66 20 74 |ited.by |ANY of t|
|00005250| 68 65 20 63 68 69 6c 64 | 72 65 6e 20 64 69 72 65 |he child|ren dire|
|00005260| 63 74 6f 72 69 65 73 2e | 20 20 54 68 75 73 20 74 |ctories.| Thus t|
|00005270| 68 65 20 73 69 7a 65 20 | 72 65 70 6f 72 74 65 64 |he size |reported|
|00005280| 0a 62 79 20 64 75 6f 6e | 6c 79 20 6d 69 67 68 74 |.by duon|ly might|
|00005290| 20 62 65 20 74 68 6f 75 | 67 68 74 20 6f 66 20 61 | be thou|ght of a|
|000052a0| 73 20 4f 4e 4c 59 20 66 | 6f 72 20 74 68 61 74 20 |s ONLY f|or that |
|000052b0| 64 69 72 65 63 74 6f 72 | 79 2e 0a 0a 0a 53 41 4d |director|y....SAM|
|000052c0| 50 4c 45 20 55 53 41 47 | 45 0a 0a 09 64 75 20 7c |PLE USAG|E...du ||
|000052d0| 20 64 75 6f 6e 6c 79 0a | 09 64 75 20 2f 75 73 72 | duonly.|.du /usr|
|000052e0| 20 7c 20 64 75 6f 6e 6c | 79 0a 0a 0a 4e 4f 54 45 | | duonl|y...NOTE|
|000052f0| 53 0a 0a 54 68 65 20 64 | 69 72 65 63 74 6f 72 79 |S..The d|irectory|
|00005300| 20 6e 61 6d 65 73 20 61 | 72 65 20 73 6f 72 74 65 | names a|re sorte|
|00005310| 64 20 61 6c 70 68 61 62 | 65 74 69 63 61 6c 6c 79 |d alphab|etically|
|00005320| 20 62 79 20 65 61 63 68 | 20 6c 65 76 65 6c 2e 0a | by each| level..|
|00005330| 54 68 65 72 65 20 69 73 | 20 6f 6e 65 20 6d 69 6e |There is| one min|
|00005340| 6f 72 20 61 6e 6f 6d 6f | 6c 79 20 61 62 6f 75 74 |or anomo|ly about|
|00005350| 20 74 68 65 20 73 6f 72 | 74 65 64 20 6f 72 64 65 | the sor|ted orde|
|00005360| 72 20 6f 66 20 64 69 72 | 65 63 74 6f 72 79 0a 6e |r of dir|ectory.n|
|00005370| 61 6d 65 73 2e 20 44 75 | 6f 6e 6c 79 20 77 69 6c |ames. Du|only wil|
|00005380| 6c 20 6f 75 74 70 75 74 | 20 74 68 69 73 20 6f 72 |l output| this or|
|00005390| 64 65 72 3a 0a 09 31 30 | 09 64 69 72 0a 09 35 09 |der:..10|.dir..5.|
|000053a0| 64 69 72 2f 73 75 62 64 | 69 72 0a 09 33 09 64 69 |dir/subd|ir..3.di|
|000053b0| 72 2e 32 0a 62 75 74 20 | 61 20 74 72 75 65 20 22 |r.2.but |a true "|
|000053c0| 64 75 20 7c 20 64 75 6f | 6e 6c 79 20 7c 20 73 6f |du | duo|nly | so|
|000053d0| 72 74 20 2b 31 22 2c 20 | 77 69 74 68 20 73 6f 72 |rt +1", |with sor|
|000053e0| 74 69 6e 67 20 61 70 70 | 6c 69 65 64 20 74 6f 0a |ting app|lied to.|
|000053f0| 74 68 65 20 73 65 63 6f | 6e 64 20 63 6f 6c 75 6d |the seco|nd colum|
|00005400| 6e 20 77 6f 75 6c 64 20 | 72 65 61 6c 6c 79 20 6f |n would |really o|
|00005410| 75 74 70 75 74 3a 0a 09 | 31 30 09 64 69 72 0a 09 |utput:..|10.dir..|
|00005420| 33 09 64 69 72 2e 32 0a | 09 35 09 64 69 72 2f 73 |3.dir.2.|.5.dir/s|
|00005430| 75 62 64 69 72 0a 73 69 | 6e 63 65 20 22 2e 22 20 |ubdir.si|nce "." |
|00005440| 6c 65 78 69 63 61 6c 6c | 79 20 70 72 65 63 65 65 |lexicall|y precee|
|00005450| 64 73 20 22 2f 22 2e 0a | 57 69 74 68 20 74 68 65 |ds "/"..|With the|
|00005460| 20 65 78 63 65 70 74 69 | 6f 6e 20 6e 6f 74 65 64 | excepti|on noted|
|00005470| 2c 20 74 68 65 20 72 65 | 73 74 20 6f 66 20 74 68 |, the re|st of th|
|00005480| 65 20 6f 75 74 70 75 74 | 20 67 65 6e 65 72 61 74 |e output| generat|
|00005490| 65 64 20 62 79 20 64 75 | 0a 69 73 20 69 6e 20 74 |ed by du|.is in t|
|000054a0| 68 65 20 63 6f 72 72 65 | 63 74 20 6f 72 64 65 72 |he corre|ct order|
|000054b0| 2e 0a 5c 53 48 41 52 5f | 45 4f 46 0a 23 20 2e 2e |..\SHAR_|EOF.# ..|
|000054c0| 2e 2e 2e 2e 2e 2e 2e 2e | 2e 2e 20 20 20 20 46 20 |........|.. F |
|000054d0| 20 49 20 20 20 4c 20 20 | 20 45 20 20 20 20 20 20 | I L | E |
|000054e0| 45 20 20 4e 20 20 44 20 | 20 2e 2e 2e 2e 2e 2e 2e |E N D | .......|
|000054f0| 2e 2e 2e 20 64 75 6f 6e | 6c 79 2e 68 65 6c 70 0a |... duon|ly.help.|
|00005500| 66 69 20 23 20 65 6e 64 | 20 6f 66 20 6f 76 65 72 |fi # end| of over|
|00005510| 77 72 69 74 69 6e 67 20 | 63 68 65 63 6b 0a 23 20 |writing |check.# |
|00005520| 65 6e 64 20 6f 66 20 73 | 68 65 6c 6c 20 61 72 63 |end of s|hell arc|
|00005530| 68 69 76 65 0a 65 78 69 | 74 20 30 0a 2d 2d 20 0a |hive.exi|t 0.-- .|
|00005540| 46 75 6c 6c 4e 61 6d 65 | 3a 09 44 65 6e 6e 69 73 |FullName|:.Dennis|
|00005550| 20 42 65 64 6e 61 72 0a | 55 55 43 50 3a 09 09 7b | Bednar.|UUCP:..{|
|00005560| 75 75 6e 65 74 7c 73 75 | 6e 64 63 7d 21 72 6c 67 |uunet|su|ndc}!rlg|
|00005570| 76 61 78 21 64 65 6e 6e | 69 73 0a 55 53 4d 61 69 |vax!denn|is.USMai|
|00005580| 6c 3a 09 09 43 43 49 3b | 20 31 31 34 39 30 20 43 |l:..CCI;| 11490 C|
|00005590| 6f 6d 6d 65 72 63 65 20 | 50 61 72 6b 20 44 72 2e |ommerce |Park Dr.|
|000055a0| 3b 20 52 65 73 74 6f 6e | 20 56 41 20 32 32 30 39 |; Reston| VA 2209|
|000055b0| 31 0a 54 65 6c 65 70 68 | 6f 6e 65 3a 09 2b 31 20 |1.Teleph|one:.+1 |
|000055c0| 37 30 33 20 36 34 38 20 | 33 33 30 30 0a |703 648 |3300. |
+--------+-------------------------+-------------------------+--------+--------+