Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
704b2c2122 | ||
|
|
53b55ac08d | ||
|
|
c36c2ba598 | ||
|
|
7f1978570f | ||
|
|
4aaefc2a50 | ||
|
|
c5b3242d3d | ||
|
|
056960d8dc | ||
|
|
0d5051def0 | ||
|
|
3a0057e2c5 | ||
|
|
f71378c4ad | ||
|
|
0a6f1d31e7 | ||
|
|
e708cb5f9a | ||
|
|
a4edd0e946 | ||
|
|
f9ff8a7d90 | ||
|
|
af9e533a54 | ||
|
|
48dcc16548 | ||
|
|
730cdb1904 | ||
|
|
0d4e51d390 | ||
|
|
0b57e28373 | ||
|
|
b0c2b7dfe3 | ||
|
|
2825ee8c2c | ||
|
|
a8035a51be | ||
|
|
7384d7dce0 | ||
|
|
0d3a02eba7 | ||
|
|
670bea210e | ||
|
|
d8adaa279e | ||
|
|
3bf60aa723 | ||
|
|
e110ccb672 | ||
|
|
0e0883e0e9 | ||
|
|
038c8eb5a9 | ||
|
|
7ddaf7caae | ||
|
|
bac75ac2d5 | ||
|
|
1ef92685cf | ||
|
|
ce4a586edb | ||
|
|
40e5e7c7ea | ||
|
|
20f61d35de | ||
|
|
44a9914709 | ||
|
|
2892c35bdb | ||
|
|
82d8502409 | ||
|
|
53f5061c7e | ||
|
|
bdc8db9685 | ||
|
|
741f2c9898 | ||
|
|
b9a1e56a80 | ||
|
|
2b1c367a98 | ||
|
|
3c0b425cde | ||
|
|
14e9e9d1ca | ||
|
|
9c09e0eeaa | ||
|
|
c319601db5 | ||
|
|
4e7244e6b2 | ||
|
|
8658816f71 | ||
|
|
f594986b37 | ||
|
|
c75f83d874 | ||
|
|
b3d6e2df95 | ||
|
|
798ab301c7 | ||
|
|
f6ba2da29f | ||
|
|
e0bf91d7c6 | ||
|
|
53737c5421 | ||
|
|
6bff9cc487 | ||
|
|
bd2e42f162 | ||
|
|
94fd480bab | ||
|
|
6317c4baf7 | ||
|
|
4987bbf979 | ||
|
|
5ec5415402 | ||
|
|
1a49fc5e92 | ||
|
|
fe4e13fb97 | ||
|
|
22b889a998 | ||
|
|
68ea1d0325 | ||
|
|
1365bb7861 | ||
|
|
78f57460f2 | ||
|
|
d2117e9c82 | ||
|
|
09f4af5afd | ||
|
|
827e45c518 | ||
|
|
fa45f22e50 | ||
|
|
d92168486b | ||
|
|
4aaf89f49f | ||
|
|
f90c28dd1e | ||
|
|
8d4c397d9d | ||
|
|
3e6ff9017f | ||
|
|
dd91724aa0 | ||
|
|
74e056bfc8 | ||
|
|
3c7361f53a | ||
|
|
ce89871ff7 | ||
|
|
195743f195 | ||
|
|
eba8ed71f0 | ||
|
|
9ba5bce06f | ||
|
|
01658a3eec | ||
|
|
3dbf1e877a | ||
|
|
afffbfe8c4 | ||
|
|
b180dd9e50 | ||
|
|
13d1fa1d01 | ||
|
|
df351d6109 | ||
|
|
39eea898c4 | ||
|
|
7e5291f111 | ||
|
|
32f8c170b0 | ||
|
|
ca6045955d | ||
|
|
e2c44fc966 | ||
|
|
5de909873a | ||
|
|
4cc8f31ffe | ||
|
|
ae5612ca6e | ||
|
|
ae20128e9f | ||
|
|
26d53eb197 | ||
|
|
ec9fad9a49 | ||
|
|
a7db19bb81 | ||
|
|
11ae573320 | ||
|
|
7850f1e2ac | ||
|
|
5986f8d1c6 | ||
|
|
651f8c04ef | ||
|
|
6c563bc1a1 | ||
|
|
8b728a25a3 | ||
|
|
702ec5926f | ||
|
|
8bb7df49c2 | ||
|
|
0f430e34af | ||
|
|
36278b9576 | ||
|
|
54851d3c65 | ||
|
|
07f2f3917a | ||
|
|
1a046d5f9d | ||
|
|
138ece09b5 | ||
|
|
e6c4de03c6 | ||
|
|
f15d4dad66 | ||
|
|
5efa2291aa | ||
|
|
c27b9544b6 | ||
|
|
47cdcdd359 | ||
|
|
21b7459add | ||
|
|
afbff22e6e | ||
|
|
452fd33ffa | ||
|
|
076cdc24fc | ||
|
|
9ead68975c | ||
|
|
323434be42 | ||
|
|
446dd27843 | ||
|
|
42ab250709 | ||
|
|
3b565cdf91 | ||
|
|
85adecb668 | ||
|
|
450736cd3c | ||
|
|
016771834a | ||
|
|
39842defda | ||
|
|
de4406747b | ||
|
|
7b91f02021 | ||
|
|
93ba60f01d | ||
|
|
1b6cff3df4 | ||
|
|
4f76bb6f3e | ||
|
|
4142d4dc66 | ||
|
|
e677dfedd1 | ||
|
|
d11578f916 | ||
|
|
2bf658d5cd | ||
|
|
afeb96547f | ||
|
|
d160a27ec1 | ||
|
|
dc12190ba2 | ||
|
|
37977622c4 | ||
|
|
7d597c4833 | ||
|
|
dbfff6cbde | ||
|
|
e6967b20cb | ||
|
|
3757f98d86 | ||
|
|
8373e70c55 | ||
|
|
7a9cc2dcdd | ||
|
|
15f9b92127 | ||
|
|
df1e9daf30 | ||
|
|
ed0d958c3e | ||
|
|
2498b155fd | ||
|
|
a0cfe94c4e | ||
|
|
b83ffafc15 | ||
|
|
56082dc2ae | ||
|
|
68c1d8400c | ||
|
|
b249fbb1dc | ||
|
|
8c16bc5012 | ||
|
|
4a25d8c9c3 | ||
|
|
0ed9923887 | ||
|
|
3574b70efc | ||
|
|
8079b155c2 | ||
|
|
bbc8e4789f | ||
|
|
2f3105725f | ||
|
|
5723934f7c | ||
|
|
41492d6c23 | ||
|
|
c163e5107f | ||
|
|
544891dd26 | ||
|
|
adea7a6101 | ||
|
|
4b2e69a1cf | ||
|
|
e13bc0bc68 | ||
|
|
ffc40bf3de | ||
|
|
b2007bffc5 | ||
|
|
5d9cad0253 | ||
|
|
7aa1f5c42a | ||
|
|
dbcd8ce464 | ||
|
|
7e9276b50a | ||
|
|
8fc300976f | ||
|
|
be30a6b8b0 | ||
|
|
54006bce25 | ||
|
|
7c3e7ac940 | ||
|
|
8d7bdc9deb | ||
|
|
9e37007edb | ||
|
|
90fe7fea10 | ||
|
|
477aedd77f | ||
|
|
5165fbed63 | ||
|
|
caeeb36784 | ||
|
|
a183f05825 | ||
|
|
f1142c5b11 | ||
|
|
cbe31dace5 | ||
|
|
94456f5984 | ||
|
|
12dceb1147 | ||
|
|
963791a9e9 | ||
|
|
f1bbb22dca | ||
|
|
f57a832063 | ||
|
|
b50da53e0c | ||
|
|
3d20f772c2 | ||
|
|
966b3a6f79 | ||
|
|
1cf8166329 | ||
|
|
47aea4ee71 | ||
|
|
19f86207f5 | ||
|
|
69c8572f29 | ||
|
|
f6a7227fd6 | ||
|
|
28a78ab62c | ||
|
|
6faae7deb4 | ||
|
|
361ee514c6 | ||
|
|
ca0f458ada | ||
|
|
733c4ad6eb | ||
|
|
fa4f146d7d | ||
|
|
5f2c79d8c7 | ||
|
|
af12bc6de4 | ||
|
|
3f5bcbfa3c | ||
|
|
a9c69762ba | ||
|
|
825ae5a166 | ||
|
|
99806ad2bd | ||
|
|
11b7a1deb7 | ||
|
|
d69d2da165 | ||
|
|
b50d707633 | ||
|
|
02b9f42a27 | ||
|
|
81bcc92c32 | ||
|
|
8305006f7c | ||
|
|
c1c43113b4 | ||
|
|
3ec8ffb121 | ||
|
|
67991cf824 | ||
|
|
68be2ab914 | ||
|
|
98e599ca06 | ||
|
|
ec45595300 | ||
|
|
88a5ceb450 | ||
|
|
fc83c4c353 | ||
|
|
6fd8c664c1 | ||
|
|
3af1f88725 | ||
|
|
dadf9c6dcd | ||
|
|
821fbf0f42 | ||
|
|
bc9afadecd | ||
|
|
728875f340 | ||
|
|
631064613f | ||
|
|
0c9d77ccfd | ||
|
|
de556615dc | ||
|
|
510f0ddafa | ||
|
|
649968ceb1 | ||
|
|
af8c65deaa | ||
|
|
c900575dc4 | ||
|
|
c30ab0f4a8 | ||
|
|
e78fd0f721 | ||
|
|
2fd52989f7 | ||
|
|
d238a7bcc8 | ||
|
|
1d70267450 | ||
|
|
df8ccb6350 | ||
|
|
096370d349 | ||
|
|
a164c647ac | ||
|
|
925edb828d | ||
|
|
c3fc3c5e7a | ||
|
|
29cff26f32 | ||
|
|
76c5e60d54 | ||
|
|
af4ac77d9d | ||
|
|
b5c29850e3 | ||
|
|
065c7e779a | ||
|
|
9b300d0b1f | ||
|
|
f2cc2762bb | ||
|
|
05e782ddd3 | ||
|
|
bd018b1bab | ||
|
|
dd19c69904 | ||
|
|
63ec273245 | ||
|
|
82d5e59ea2 | ||
|
|
79e898ac0e | ||
|
|
65225df2dc | ||
|
|
53cfb7e231 | ||
|
|
704d2a6c43 | ||
|
|
39573f7130 | ||
|
|
18d5064c47 | ||
|
|
9ba0daf4ba | ||
|
|
93a8e2e64b | ||
|
|
306f4fe480 | ||
|
|
22332fd26f | ||
|
|
ac21e93a3f | ||
|
|
4bbdd788e0 | ||
|
|
30f64c3aa2 | ||
|
|
8526067336 | ||
|
|
e57d54b456 | ||
|
|
201dc0d5a9 | ||
|
|
ceade5c856 | ||
|
|
8ec10a9483 | ||
|
|
90ca2848fd | ||
|
|
ed3ef50c23 | ||
|
|
ab050f5522 | ||
|
|
3654ca56fa | ||
|
|
4e33875759 | ||
|
|
a68b21a28e | ||
|
|
6e25f92636 | ||
|
|
a528dc7071 | ||
|
|
1e4b957ac3 | ||
|
|
5c9c8b4b26 | ||
|
|
d5cad14b11 | ||
|
|
dff9d54e32 | ||
|
|
5307eca7de | ||
|
|
114ad9c753 | ||
|
|
dbb8f8d123 | ||
|
|
d35c21587a | ||
|
|
ffde8673fe | ||
|
|
8ba1b1120e | ||
|
|
0bc20caea5 | ||
|
|
537d165216 | ||
|
|
c1b8f1224c | ||
|
|
155c89b0c3 | ||
|
|
15f29e7d86 | ||
|
|
cc2bcdc41d | ||
|
|
39b727f498 | ||
|
|
3862423884 | ||
|
|
70c6086474 | ||
|
|
86f3d5bad6 | ||
|
|
54e9457920 | ||
|
|
23a93f52aa | ||
|
|
f5d5e77321 | ||
|
|
26439a2991 | ||
|
|
088d9e0f05 | ||
|
|
7d69701d39 | ||
|
|
8c5cb31e1b | ||
|
|
a18aaf1b6a | ||
|
|
c5cd470fdb | ||
|
|
f6c6d9aacc | ||
|
|
24be980004 | ||
|
|
a5b55ca8a9 | ||
|
|
f1b0c77c22 | ||
|
|
59ab025363 | ||
|
|
2b8d07c590 | ||
|
|
9136e3c84e | ||
|
|
e132119f07 | ||
|
|
6705986f27 | ||
|
|
6d0921cc0b | ||
|
|
3b3f5c364a | ||
|
|
8f8dab94e5 | ||
|
|
0d5a08ed92 | ||
|
|
b098b6d74c | ||
|
|
fe9888ad97 | ||
|
|
965fa326a1 | ||
|
|
e2310b5a91 | ||
|
|
c73a7f9ba0 | ||
|
|
370fb08e79 | ||
|
|
6092680305 | ||
|
|
5f825ee6d6 | ||
|
|
f914a8af2b | ||
|
|
6f65a3a7e8 | ||
|
|
1d269432b1 | ||
|
|
8392acd8fc | ||
|
|
12f417edbd | ||
|
|
c9acf8c766 | ||
|
|
fd4c58d7c5 | ||
|
|
9aa23ba5a8 | ||
|
|
541ffe30a2 | ||
|
|
55787401ea | ||
|
|
744b064a34 | ||
|
|
59d31b68c3 | ||
|
|
8ea28be6d2 | ||
|
|
0bcc813a34 | ||
|
|
b0970d4fed | ||
|
|
eb60d8bcd1 | ||
|
|
55bccf315e | ||
|
|
defcd5e75e | ||
|
|
6c6ea6cba2 | ||
|
|
92386561f1 | ||
|
|
05ebdd03d4 | ||
|
|
0810f723b1 | ||
|
|
09acc06c10 | ||
|
|
849083c886 | ||
|
|
b3dc3b8990 | ||
|
|
70a7855980 | ||
|
|
1171c2fcb4 | ||
|
|
be7499c83c | ||
|
|
a9711a5969 | ||
|
|
59c09d06e3 | ||
|
|
5e23e3d631 | ||
|
|
fa0443216d | ||
|
|
47b005217e | ||
|
|
5e8b3ea19d | ||
|
|
58a408512b | ||
|
|
7541e3a812 | ||
|
|
004827d715 | ||
|
|
1944f547bd | ||
|
|
28b3c53f0d | ||
|
|
01bda5de6b | ||
|
|
27c7bec4d4 | ||
|
|
e6e818309e | ||
|
|
e9e182e255 | ||
|
|
2d5b64273f | ||
|
|
a9819b2908 | ||
|
|
e9f07fb6e8 | ||
|
|
16fdbe8b27 | ||
|
|
a6cd07099d | ||
|
|
e111d69ca2 | ||
|
|
70da6a66d2 | ||
|
|
3680c58084 | ||
|
|
5e8c0ffb75 | ||
|
|
e75f6a972c | ||
|
|
e80a2633bc | ||
|
|
8eb5985f94 | ||
|
|
8a6b619c96 | ||
|
|
eac2636513 | ||
|
|
a1f9775981 | ||
|
|
24ac017961 | ||
|
|
0d2acb0ead | ||
|
|
86349776d0 | ||
|
|
1fa1adea2a | ||
|
|
0dab829977 | ||
|
|
bfa7967c4a | ||
|
|
8677d7b6ec | ||
|
|
e699b9f0fb | ||
|
|
4f1b0124c7 | ||
|
|
8abc78aa84 | ||
|
|
1b622ff5ac | ||
|
|
aefe5629ab | ||
|
|
95fa0ea3d4 | ||
|
|
6f6aa9b428 | ||
|
|
e3a94f7d08 | ||
|
|
95d1f6d7c7 | ||
|
|
4362200712 | ||
|
|
1e1d232f38 | ||
|
|
235f66dea3 | ||
|
|
d0fa0a12f1 | ||
|
|
02ced93ec2 | ||
|
|
46948366fa | ||
|
|
21125543e1 | ||
|
|
4836fd44f0 | ||
|
|
bd193a42a5 | ||
|
|
77508b29fa | ||
|
|
f361ac29b0 | ||
|
|
483262f633 | ||
|
|
4d4b3b1d88 | ||
|
|
e3a48d865a | ||
|
|
d9d03b83f8 | ||
|
|
b12e506d8d | ||
|
|
69a6b2d4ae | ||
|
|
e48eea63d3 | ||
|
|
a2d61e761e | ||
|
|
5ec241d3b3 | ||
|
|
2d6282bb37 | ||
|
|
d323d32c5b | ||
|
|
5a964f9d0b | ||
|
|
20c2bdd7f2 | ||
|
|
5c365da884 | ||
|
|
4ed17829ac | ||
|
|
b2356f6de9 | ||
|
|
59ec601b8e | ||
|
|
a293a516ad | ||
|
|
394cf22668 | ||
|
|
cf7982e908 | ||
|
|
70d09ed1cf | ||
|
|
9962cd9f78 | ||
|
|
c8eedd56ac | ||
|
|
46f44d24fc | ||
|
|
00732b57c7 | ||
|
|
c52a97d79f | ||
|
|
9df3833370 | ||
|
|
29edd005f9 | ||
|
|
afdde3e356 | ||
|
|
5b5db38a7d | ||
|
|
1bca5ed886 | ||
|
|
8c28fd7849 | ||
|
|
7da312058c | ||
|
|
f21aa84389 | ||
|
|
eb4218d0a4 | ||
|
|
bf2b8ae49a | ||
|
|
76fef0a5d0 | ||
|
|
9cff4fbac9 | ||
|
|
5e09b6e3a8 | ||
|
|
f3b2b52b58 | ||
|
|
f57c944e09 | ||
|
|
7b5c16ebe5 | ||
|
|
87afb526b5 | ||
|
|
1e1d9d1c95 | ||
|
|
da7b82981b | ||
|
|
02553a2a18 | ||
|
|
3d957c87b7 | ||
|
|
6b78fe383f | ||
|
|
1e7cea952b | ||
|
|
bc5941a540 | ||
|
|
bfa54143f6 | ||
|
|
8ffabf5825 | ||
|
|
1d3523b7aa | ||
|
|
21adca750a | ||
|
|
e884970c87 | ||
|
|
92ed8a3519 | ||
|
|
ab147f608d | ||
|
|
26a3adb244 | ||
|
|
deb9d4d765 | ||
|
|
4758368505 | ||
|
|
cf61fe14ae | ||
|
|
d27753afd9 | ||
|
|
0e836ed8db | ||
|
|
2187adc619 | ||
|
|
8cede00b9e | ||
|
|
f484e7e65c | ||
|
|
868c057d25 | ||
|
|
e73fda8311 | ||
|
|
29be79c5f6 | ||
|
|
4c45e0991a | ||
|
|
b8b8d81c24 | ||
|
|
4d449c42f2 | ||
|
|
e2f6e12213 | ||
|
|
09a34e5368 | ||
|
|
02f3b2e0c8 | ||
|
|
87559829ff | ||
|
|
3e856ce428 | ||
|
|
b558e76eb1 | ||
|
|
cabafae7b0 | ||
|
|
c119ab9e29 | ||
|
|
8c725e624a | ||
|
|
8c2d3f46ab | ||
|
|
9bd71e8323 | ||
|
|
8fff78d66e | ||
|
|
ddea368dbe | ||
|
|
618e8ed4c4 | ||
|
|
0730943b49 | ||
|
|
20ea5c3352 | ||
|
|
7b5d59464f | ||
|
|
cf1189f5a7 | ||
|
|
4bfb6b7b67 | ||
|
|
e500d20835 | ||
|
|
d58ff8731c | ||
|
|
9a71af54f5 | ||
|
|
ab8f9e286b | ||
|
|
768a2340b5 | ||
|
|
e93abf9e69 | ||
|
|
5022d0e55f | ||
|
|
0053087587 | ||
|
|
9028e2c96a | ||
|
|
a683ee81d9 | ||
|
|
e5aef92e22 | ||
|
|
cf32e23796 | ||
|
|
50b3113dc2 | ||
|
|
337ec1bb32 | ||
|
|
e790ddb2e1 | ||
|
|
4e573f4729 | ||
|
|
8045c08e1c | ||
|
|
e2e2c29ea1 | ||
|
|
3c5ee9a379 | ||
|
|
46f0beb167 | ||
|
|
2aa1091130 | ||
|
|
6d5b73d183 | ||
|
|
f61caf0411 | ||
|
|
7918e1fd54 | ||
|
|
d8ad76cb31 | ||
|
|
63a862272c | ||
|
|
eb69ead091 | ||
|
|
e7ff2842dd | ||
|
|
2dc192fd99 | ||
|
|
a75466e981 | ||
|
|
ef936da7c5 | ||
|
|
3e07541e5f | ||
|
|
269e07cadc | ||
|
|
a5bd26831f | ||
|
|
b273d66518 | ||
|
|
c559d30776 | ||
|
|
b344c21709 | ||
|
|
d1ee7e39f7 | ||
|
|
84bdc75c7e | ||
|
|
e8c55f42c1 | ||
|
|
2dab174daa | ||
|
|
a0428eee9e | ||
|
|
ef5529b278 | ||
|
|
9133c98a9d | ||
|
|
3180413e76 | ||
|
|
ac1169b20f | ||
|
|
97d2612566 | ||
|
|
324a778f31 | ||
|
|
b60208dd8f | ||
|
|
130005cd89 | ||
|
|
207061ac0d | ||
|
|
2be4797a06 | ||
|
|
6050618096 | ||
|
|
69229a6c92 | ||
|
|
4f94e826cf | ||
|
|
567cdd1d51 | ||
|
|
9a6e67c960 | ||
|
|
33fdae54d1 | ||
|
|
e7e1e2dcad | ||
|
|
0d5835a767 | ||
|
|
872138de50 | ||
|
|
7a86e61a54 | ||
|
|
62f987e95f | ||
|
|
958c78f9a1 | ||
|
|
13241dfbdd | ||
|
|
aa3908d1b7 | ||
|
|
b520e083e0 | ||
|
|
25b669c144 | ||
|
|
ba1ff9b4eb | ||
|
|
c2bf5cad79 | ||
|
|
43f3e6114c | ||
|
|
8d369e98a5 | ||
|
|
c0321f9bc6 | ||
|
|
e7c1af1e0d | ||
|
|
bbaef66b3f | ||
|
|
e0bcce09ba | ||
|
|
8ce85ce4e3 | ||
|
|
bdcc6fbd95 | ||
|
|
f8263516c2 | ||
|
|
db7f2af089 | ||
|
|
f6b7139971 | ||
|
|
d266748c76 | ||
|
|
53323695c5 | ||
|
|
67fdf5e538 | ||
|
|
ff1ed7215c | ||
|
|
d89882da16 | ||
|
|
3570a34de4 | ||
|
|
caffb6eff0 | ||
|
|
c5949f62e5 | ||
|
|
e081eae7a4 | ||
|
|
bf73909f23 | ||
|
|
944be90b21 | ||
|
|
fe4208fe93 | ||
|
|
488aac2e2a | ||
|
|
896fa4ea1d | ||
|
|
57f83fffd8 | ||
|
|
6f283c2f77 | ||
|
|
9ae3838657 | ||
|
|
1b1cfde1f8 | ||
|
|
0102a9fd48 | ||
|
|
2da90d3b58 | ||
|
|
285b446d17 | ||
|
|
32e95f988d | ||
|
|
96bdde97fb | ||
|
|
6d66817b6b | ||
|
|
82e0614101 | ||
|
|
a37d5b772b | ||
|
|
5b17693f0a | ||
|
|
ebc0dd7a8a | ||
|
|
92a61c1206 | ||
|
|
90f580ad5b | ||
|
|
d995493987 | ||
|
|
a2f2a8f8c0 | ||
|
|
810d38f850 | ||
|
|
a1b35c4512 | ||
|
|
8c185f9600 | ||
|
|
75610e18b3 | ||
|
|
2c1faecba7 | ||
|
|
c873d61008 | ||
|
|
ba35b98444 | ||
|
|
d2f5677762 | ||
|
|
d1de4a16ad | ||
|
|
f34aa4c378 | ||
|
|
8a2e56c5df | ||
|
|
350b3f9236 | ||
|
|
ae22612792 | ||
|
|
624cc771da | ||
|
|
8847b9a03a | ||
|
|
7c22b77162 | ||
|
|
cff3fe3ae9 | ||
|
|
0cccdfaf36 | ||
|
|
b938e2ff99 | ||
|
|
46a98dfb13 | ||
|
|
56f3e353da | ||
|
|
06f64b2370 | ||
|
|
0b2da467a8 | ||
|
|
721119e1db | ||
|
|
cd26ff4eac | ||
|
|
252bacc9ea | ||
|
|
fd3741d712 | ||
|
|
38c8551cf2 | ||
|
|
63dde9d4ce | ||
|
|
b2f36af157 | ||
|
|
6fc2a7d04d | ||
|
|
82cfbad216 | ||
|
|
c9db2e8665 | ||
|
|
d2d3aa39ef | ||
|
|
2aee993118 | ||
|
|
f5cf8c6c65 | ||
|
|
33bee33af0 | ||
|
|
5f84fd7066 | ||
|
|
cbe05e45db | ||
|
|
7e3bf6e339 | ||
|
|
ce40fc044b | ||
|
|
5d63884a8f | ||
|
|
31e6829bd8 | ||
|
|
131241f71c | ||
|
|
cbbe4d6bc2 | ||
|
|
56a328810b | ||
|
|
b4c3c59a45 | ||
|
|
f8e04f7113 | ||
|
|
fb6a50820c | ||
|
|
d39d120998 | ||
|
|
5d513f7256 | ||
|
|
dd450a0ded | ||
|
|
322ae93a5e | ||
|
|
b89075298e | ||
|
|
23ad7f7f06 | ||
|
|
ccb0a9ba88 | ||
|
|
fca8050f0f | ||
|
|
ac19b7e032 | ||
|
|
49352adf9c | ||
|
|
605a819a17 | ||
|
|
f0b073f55a | ||
|
|
de34e43755 | ||
|
|
cbb61c78ae | ||
|
|
73de6561ca | ||
|
|
729216cb11 | ||
|
|
18310f1ce3 | ||
|
|
0ae8e5a645 | ||
|
|
bd7c67136a | ||
|
|
1c6917d2c4 | ||
|
|
e2b345a6d8 | ||
|
|
437bf72785 | ||
|
|
6fb88e73f7 | ||
|
|
8324b9f1aa | ||
|
|
11c655295c | ||
|
|
44e3840343 | ||
|
|
17c8851813 | ||
|
|
6085c72b6e | ||
|
|
9dd79791c8 | ||
|
|
ebee301c8b | ||
|
|
d13ebff163 | ||
|
|
1eec89df4c | ||
|
|
3639c5d950 | ||
|
|
1b355ebba6 | ||
|
|
43c8c38bbf | ||
|
|
61a9d8d145 | ||
|
|
9670083818 | ||
|
|
b92223b6f5 | ||
|
|
fd50c3d2f9 | ||
|
|
cb91d69b3f | ||
|
|
73bdf13d35 | ||
|
|
3a957b9d4c | ||
|
|
18a1014c95 | ||
|
|
da542f3a0c | ||
|
|
f446297afd | ||
|
|
e99674a70f | ||
|
|
5eb5912790 | ||
|
|
4e61db2284 | ||
|
|
ad3d90f91e | ||
|
|
a3de24e85d | ||
|
|
1638488d26 | ||
|
|
ab60f6987a | ||
|
|
88cc3057fd | ||
|
|
06aeb6c417 | ||
|
|
4d5ac2f346 | ||
|
|
3a0f4baf2f | ||
|
|
8237add8d0 | ||
|
|
32f2769800 | ||
|
|
089d12d762 | ||
|
|
aaa94fb8a9 | ||
|
|
ce82c8ab77 | ||
|
|
2368a387ed | ||
|
|
e4c4d69c04 | ||
|
|
6ab22027d0 | ||
|
|
fba9c00071 | ||
|
|
acf5551099 | ||
|
|
918507edda | ||
|
|
851ce895bd | ||
|
|
a1f16bba72 | ||
|
|
e2205f093b | ||
|
|
0e4cec0be8 | ||
|
|
dc746169cf | ||
|
|
282c364148 | ||
|
|
fa405d0cb2 | ||
|
|
202995c612 | ||
|
|
c86e5e6145 | ||
|
|
be0dc0d06a | ||
|
|
b2fc5a0647 | ||
|
|
e89267c8b3 | ||
|
|
8cbac440d6 | ||
|
|
6ac18a3d83 | ||
|
|
bb39a31e33 | ||
|
|
79565b6c91 | ||
|
|
f9ca653faa | ||
|
|
88f50b6bf5 | ||
|
|
40406e6bad | ||
|
|
adbf018dc4 | ||
|
|
deb95f69b6 | ||
|
|
46ade97983 | ||
|
|
0c8e2a6580 | ||
|
|
fdd5103348 | ||
|
|
5ae166813f | ||
|
|
807f0fd637 | ||
|
|
d5fa3e3e9a | ||
|
|
080d51bf45 | ||
|
|
0f8f7b8a35 | ||
|
|
98bbd688a8 | ||
|
|
43c17b3d96 | ||
|
|
616d13bcd1 | ||
|
|
259972e565 | ||
|
|
9cf306d55e | ||
|
|
6a4c33c5c0 | ||
|
|
6150df320a | ||
|
|
d5704686b1 | ||
|
|
1428c4f136 | ||
|
|
a5716d3029 | ||
|
|
501c88b245 | ||
|
|
6a99aaf020 | ||
|
|
7ce41ad692 | ||
|
|
e92108ae6d | ||
|
|
0d49dd53cf | ||
|
|
cc10a5b42b | ||
|
|
83e85f6a08 | ||
|
|
52681b48dc | ||
|
|
fad9c1198a | ||
|
|
b040d4f3da | ||
|
|
b9ea02c04b | ||
|
|
d34595d857 | ||
|
|
e5db406690 | ||
|
|
40bfc76385 | ||
|
|
e99f7500e0 | ||
|
|
ea824fb937 | ||
|
|
bf960f58e2 | ||
|
|
7df345e149 | ||
|
|
ec8d60f0f8 | ||
|
|
0010ee45e3 | ||
|
|
c768ab490e | ||
|
|
ced2cefcca | ||
|
|
1f45b268cb | ||
|
|
1ac435c15e | ||
|
|
51154bacbe | ||
|
|
3950596e1e | ||
|
|
99e370f0c6 | ||
|
|
aa4f108338 | ||
|
|
27a804246a | ||
|
|
869057238b | ||
|
|
2f46b664b7 | ||
|
|
91a4400fd5 | ||
|
|
a16c66335e | ||
|
|
ae6eae02dd | ||
|
|
52d6fa3bb3 | ||
|
|
1d255be78d | ||
|
|
2ef880b236 | ||
|
|
a9d69fb568 | ||
|
|
8f122431f5 | ||
|
|
6efc48c1ae | ||
|
|
9c5fcc3408 | ||
|
|
cc8a66b113 | ||
|
|
97562bd9d7 | ||
|
|
21ddb38fcf | ||
|
|
a1d187a8a8 | ||
|
|
bc0aed79a8 | ||
|
|
47d4926244 | ||
|
|
bf181b9338 | ||
|
|
3bd8bd89ee | ||
|
|
464c5de00d | ||
|
|
70705d7c96 | ||
|
|
add09fd558 | ||
|
|
17ad45aace | ||
|
|
df4532bfa3 | ||
|
|
ff5a9033f9 | ||
|
|
f626dcbc84 | ||
|
|
9027bcf2f4 | ||
|
|
93c0d9f090 | ||
|
|
fad04fdd12 | ||
|
|
b870af09ae | ||
|
|
d6912c97de | ||
|
|
58361a44b5 | ||
|
|
e7413a9cde | ||
|
|
d537a95fdb | ||
|
|
4ac6cb534d | ||
|
|
ec10b9d534 | ||
|
|
34623db618 | ||
|
|
02008346c0 | ||
|
|
94074a980c | ||
|
|
496e33feeb | ||
|
|
4f7fe77d07 | ||
|
|
06f3529ada | ||
|
|
156959ea93 | ||
|
|
f4c022649b | ||
|
|
55380700d8 | ||
|
|
00143ba921 | ||
|
|
ac48461da9 | ||
|
|
37653aaf9c | ||
|
|
c41e8c840f | ||
|
|
6f96e674b9 | ||
|
|
be84cd4ef6 | ||
|
|
e58771e73c | ||
|
|
e714bce003 | ||
|
|
3ecbe9f4dc | ||
|
|
97426e082a | ||
|
|
8fbaeece53 | ||
|
|
68fda241d2 | ||
|
|
858c1adf2b | ||
|
|
7719008a85 | ||
|
|
aec27bca98 | ||
|
|
960be79964 | ||
|
|
be909b1cd5 | ||
|
|
d006c9e630 | ||
|
|
9ebccb2891 | ||
|
|
f1f6d58598 | ||
|
|
0c838af50b | ||
|
|
195fa15caf | ||
|
|
61dc057183 | ||
|
|
df5f6ba115 | ||
|
|
da9841efc1 | ||
|
|
da1d1e763d | ||
|
|
cc54d12ef7 | ||
|
|
dd23b8bb43 | ||
|
|
c674d70699 | ||
|
|
6315ce603b | ||
|
|
85c552035e | ||
|
|
9b2297a34e | ||
|
|
a0053735dc | ||
|
|
3849f9bfcc | ||
|
|
9a8243aa1e | ||
|
|
928faac503 | ||
|
|
34e1941c32 | ||
|
|
0b4551faf5 | ||
|
|
a03d86cf54 | ||
|
|
44735f8744 | ||
|
|
999bf72f49 | ||
|
|
e9b527ae48 | ||
|
|
161cf93404 | ||
|
|
f12724c21a | ||
|
|
a57ba4db64 | ||
|
|
2cd439f7f0 | ||
|
|
bd22ed8067 | ||
|
|
877a71bbf0 | ||
|
|
9cf44e79aa | ||
|
|
8f282f1b02 | ||
|
|
acecc47261 | ||
|
|
e6b9dfa967 | ||
|
|
53a955786d | ||
|
|
a2c83d885e | ||
|
|
03f9c81cec | ||
|
|
bb374a6935 | ||
|
|
4c95a28461 | ||
|
|
3312b0b626 | ||
|
|
2158092344 | ||
|
|
b9eb0233a9 | ||
|
|
b0b732bfe4 | ||
|
|
03f4c27bd6 | ||
|
|
67536ffa43 | ||
|
|
8845adc545 | ||
|
|
02bc25be56 | ||
|
|
e5cec4e3ac | ||
|
|
62bb2d02b6 | ||
|
|
a5dbb39dac | ||
|
|
c8c10c5715 | ||
|
|
f86aee74ce | ||
|
|
b1e379f7f3 | ||
|
|
78eab2f6c6 | ||
|
|
3cfa9ec09c | ||
|
|
6f5e281479 | ||
|
|
b2731b11ef | ||
|
|
1e03add675 | ||
|
|
5d893b6beb | ||
|
|
89bc256c94 | ||
|
|
f7cf2f7ef9 | ||
|
|
57ebebfb01 | ||
|
|
2086e3d679 | ||
|
|
028fb625f5 | ||
|
|
5331025f79 | ||
|
|
b02c54ebee | ||
|
|
72965e3454 | ||
|
|
b54833cde0 | ||
|
|
7c31ea4e29 | ||
|
|
5d41d60f1e | ||
|
|
2e1148b239 | ||
|
|
8bd891cbec | ||
|
|
1ca41775bb | ||
|
|
d37218941c | ||
|
|
268b8c4f38 | ||
|
|
0c96eba3de | ||
|
|
a44790f539 | ||
|
|
a2db097d66 | ||
|
|
1c314ad655 | ||
|
|
47cac6779a | ||
|
|
eb0283333b | ||
|
|
7cdc76dfbf | ||
|
|
d0edef3cbe | ||
|
|
495869f59a | ||
|
|
cb1d841f09 | ||
|
|
27b5924b96 | ||
|
|
8f425dbf9a | ||
|
|
83a949cb22 | ||
|
|
1386e70210 | ||
|
|
ef40aa81c5 | ||
|
|
3adffb7fc8 | ||
|
|
10dc9d4d17 | ||
|
|
8a24a6783a | ||
|
|
4a971aef59 | ||
|
|
3c37598dc2 | ||
|
|
a29dec28cb | ||
|
|
ccd32cbb61 | ||
|
|
9d9610b8de | ||
|
|
6f9985e2f2 | ||
|
|
addc9c28ad | ||
|
|
4fa84e6b54 | ||
|
|
c6cdf58747 | ||
|
|
07edff4ba4 | ||
|
|
45087b1010 | ||
|
|
766c012975 | ||
|
|
c5c5e3d144 | ||
|
|
afa0662860 | ||
|
|
1a804e4b3c | ||
|
|
f929641c51 | ||
|
|
feb47c024a | ||
|
|
f7a01951fb | ||
|
|
7ac06a3ff1 | ||
|
|
0021679b0d | ||
|
|
b405dfa54d | ||
|
|
c03525475e | ||
|
|
e63ad9ba06 | ||
|
|
28c88a9430 | ||
|
|
339b892313 | ||
|
|
4eb1b30411 | ||
|
|
bd4a75f6c8 | ||
|
|
bb245ba0c2 | ||
|
|
9ca57d377e | ||
|
|
e1e23eecab | ||
|
|
5e29c6ffce | ||
|
|
a15cd0be34 | ||
|
|
b7362e36a8 | ||
|
|
67e32304b1 | ||
|
|
be5023a84d | ||
|
|
b610615be9 | ||
|
|
dbb3019d0d | ||
|
|
30f0f2d040 | ||
|
|
b108a5b780 | ||
|
|
110fc0cacc | ||
|
|
74c66ad06e | ||
|
|
98cd53e86d | ||
|
|
852ff13fc4 | ||
|
|
b991395405 | ||
|
|
2e965239ee | ||
|
|
3f75503fa0 | ||
|
|
28c70b3a16 | ||
|
|
e97da40079 | ||
|
|
1af7ed5573 | ||
|
|
3c709b45b3 | ||
|
|
d84990eb1f | ||
|
|
854e11581f | ||
|
|
2b6ab3cbf8 | ||
|
|
053b1462b7 | ||
|
|
baf22bff21 | ||
|
|
c7ccfc99fc | ||
|
|
9f16d61408 | ||
|
|
44760d058c | ||
|
|
5db60a7a7a | ||
|
|
0c6a970eb2 | ||
|
|
b3d235f63b | ||
|
|
b3cf9baeb9 | ||
|
|
049b706591 | ||
|
|
da10ec0eaa | ||
|
|
0024abcbbc | ||
|
|
0b66577368 | ||
|
|
a42982e8f5 | ||
|
|
1f6262b8e2 | ||
|
|
fb8ba506bb | ||
|
|
3232203226 | ||
|
|
d05e3ce5c2 | ||
|
|
eec2f63b3f | ||
|
|
700a5aed75 | ||
|
|
517cab761f | ||
|
|
6ca28ba65c | ||
|
|
680d65a646 | ||
|
|
68480dc30f | ||
|
|
815e904470 | ||
|
|
c389d91181 | ||
|
|
82c0ac7e4f | ||
|
|
f2fffefe49 | ||
|
|
36fe1a30b1 | ||
|
|
926e0e3465 | ||
|
|
afeb683459 | ||
|
|
46a38dbb9b | ||
|
|
ef4268efa7 | ||
|
|
832000f7f3 | ||
|
|
f0c30b71be | ||
|
|
5a0a2aa00b | ||
|
|
808d03ec19 | ||
|
|
9c8ffa02f4 | ||
|
|
3199bda52e | ||
|
|
6082917e34 | ||
|
|
380e58a05f | ||
|
|
ec480c49c2 | ||
|
|
86ab8a32bd | ||
|
|
4062268bc7 | ||
|
|
08e9289ab3 | ||
|
|
b6c6d87a99 | ||
|
|
77bd2db325 | ||
|
|
1624813459 | ||
|
|
b83e0ed3a1 | ||
|
|
89960b8af2 | ||
|
|
b5966368d7 | ||
|
|
deb0331eb6 | ||
|
|
108a44345c | ||
|
|
e511e7c116 | ||
|
|
8ea7d8cdaf | ||
|
|
330fd2b576 | ||
|
|
d356c6e9d1 | ||
|
|
5b46d792f1 | ||
|
|
499f65fb98 | ||
|
|
969f9b0486 | ||
|
|
67a0dd8f3c | ||
|
|
c3f5c9c2ee | ||
|
|
bcd6177853 | ||
|
|
73c8c9cf9a | ||
|
|
23dea9b712 | ||
|
|
7ab9c7ee52 | ||
|
|
3d427ac5ef | ||
|
|
59b9e87024 | ||
|
|
ac130e1dca | ||
|
|
0a027e6880 | ||
|
|
691f49d3c1 | ||
|
|
0e713cef9d | ||
|
|
6c5f2c6021 | ||
|
|
9b15e50835 | ||
|
|
a59d7094a6 | ||
|
|
0a704e8ff6 | ||
|
|
a19bc64653 | ||
|
|
e31c06608e | ||
|
|
03ccce6e30 | ||
|
|
5afc864422 | ||
|
|
3c1217cfad | ||
|
|
8f8d6d5f2d | ||
|
|
d16665810d | ||
|
|
12d1b378be | ||
|
|
9b7d964581 | ||
|
|
f378fced43 | ||
|
|
4625240674 | ||
|
|
94f5e0ba7c | ||
|
|
28c49b6c9c | ||
|
|
25c44c623d | ||
|
|
923ef599f3 | ||
|
|
6ed02a0ee0 | ||
|
|
abc199eb0c | ||
|
|
4f3f757d56 | ||
|
|
227a59b05d | ||
|
|
f93a95de69 | ||
|
|
e90f4045af | ||
|
|
1d1d95051a | ||
|
|
cf8d38a3eb | ||
|
|
7d6ba57bba | ||
|
|
e3ed156eeb | ||
|
|
1101d23604 | ||
|
|
eef658068b | ||
|
|
2e397341d9 | ||
|
|
262dd039eb | ||
|
|
3fe7f9f20b | ||
|
|
a3e57ca700 | ||
|
|
f13df3752c | ||
|
|
9a8195cc03 | ||
|
|
b9167cb67f | ||
|
|
632bb57135 | ||
|
|
c366050a23 | ||
|
|
f29f797f54 | ||
|
|
0a64de9b4f | ||
|
|
229dd2b905 | ||
|
|
5d68857b9c | ||
|
|
a6c752201e | ||
|
|
91e581fa04 | ||
|
|
5a50def0f4 | ||
|
|
6e703034f4 | ||
|
|
26702fe191 | ||
|
|
e5b6c7dd9c | ||
|
|
4fd10fc73b | ||
|
|
200be97e36 | ||
|
|
5a728cfdfe | ||
|
|
3becdfc316 | ||
|
|
53642b066c | ||
|
|
9057b6a918 | ||
|
|
ab01ed12bd | ||
|
|
5e1189e187 | ||
|
|
95c1c1e05f | ||
|
|
d5ba77d03e | ||
|
|
50ed0676ad | ||
|
|
cbd6628c8c | ||
|
|
9cf3bfa7c1 | ||
|
|
b4f8606c05 | ||
|
|
08e7f75ba2 | ||
|
|
f17792ca9b | ||
|
|
61677feff7 | ||
|
|
62dc17a3b1 | ||
|
|
f0657d3229 | ||
|
|
a2685735b1 | ||
|
|
f3b3d17060 | ||
|
|
0817d1372c | ||
|
|
84e09e4437 | ||
|
|
ecd512453c | ||
|
|
5dd853ad2a | ||
|
|
6a34b539db | ||
|
|
825aead68b | ||
|
|
93d6513d93 | ||
|
|
7a4b719486 | ||
|
|
6bd3602988 | ||
|
|
c0dac18d6d | ||
|
|
e9fee653dc | ||
|
|
d4bc1fcad8 | ||
|
|
5661fe078e | ||
|
|
cbb0a4b40d | ||
|
|
b99ca13261 | ||
|
|
68a9ea4208 | ||
|
|
183da4ade1 | ||
|
|
983b51b17b | ||
|
|
3364d78b18 | ||
|
|
6acaa40f27 | ||
|
|
deea048bec | ||
|
|
1ad302ac90 | ||
|
|
e454fb68a3 | ||
|
|
298854f029 | ||
|
|
ec5bd90916 | ||
|
|
016ffe9307 | ||
|
|
0d068a2067 | ||
|
|
c053e41fa0 | ||
|
|
42094cdad5 | ||
|
|
1dbe340eba | ||
|
|
c7c634bd88 | ||
|
|
6c41c44898 | ||
|
|
531bcb6826 | ||
|
|
6273f655c8 | ||
|
|
161220c498 | ||
|
|
13456d1fcd | ||
|
|
d75af99529 | ||
|
|
a967e3c8f0 | ||
|
|
ce91732416 | ||
|
|
3522eb1ab3 | ||
|
|
269bba2514 | ||
|
|
47d3bb3b6d | ||
|
|
54969a1f64 | ||
|
|
692a4502b0 | ||
|
|
2ac2fae728 | ||
|
|
cbd0d625c7 | ||
|
|
06249f24f3 | ||
|
|
ea6b67de65 | ||
|
|
246cc6dddd | ||
|
|
e916d24805 | ||
|
|
9c5c29d442 | ||
|
|
65fc1c70f7 | ||
|
|
fb002d0df0 | ||
|
|
66be5e7e29 | ||
|
|
6437170cb3 | ||
|
|
029011b9ee | ||
|
|
7c4b2f3fe5 | ||
|
|
a51ecdd9e4 | ||
|
|
5b911ddd57 | ||
|
|
dc75a739ac | ||
|
|
f7c49ef2d1 | ||
|
|
3b9522f2af | ||
|
|
6e769df47d | ||
|
|
d07ee46919 | ||
|
|
fa4718efcf | ||
|
|
42387e4964 | ||
|
|
27fdd081ef | ||
|
|
e272915e1f | ||
|
|
bf5f009862 | ||
|
|
08c965a0a1 | ||
|
|
5e2b96345c | ||
|
|
9ffdaa647e | ||
|
|
5e1b2ca116 | ||
|
|
fa376f8034 | ||
|
|
c1dc5d9473 | ||
|
|
91f3df3c45 | ||
|
|
4d0543138e | ||
|
|
fb1793f03c | ||
|
|
07f5604046 | ||
|
|
d7ce5e7802 | ||
|
|
e132f4b09e | ||
|
|
e49d5ecbbe | ||
|
|
c0bf817bbc | ||
|
|
d0480c26ab | ||
|
|
31cf8e0056 | ||
|
|
79ac30da83 | ||
|
|
d7cd21aed5 | ||
|
|
fac10d7c59 | ||
|
|
50bc101b7d | ||
|
|
b332e779e6 | ||
|
|
04e97024e7 | ||
|
|
a6d0dbc86f | ||
|
|
8e759aa31f | ||
|
|
d7a44c76fe | ||
|
|
ce5b466bcc | ||
|
|
ccc7488615 | ||
|
|
de7965ca7e | ||
|
|
5cbdd712f5 | ||
|
|
3fe39dce5d | ||
|
|
bf3a838aac | ||
|
|
5509af7073 | ||
|
|
9bc7e89fc1 | ||
|
|
a4a8fd05f4 | ||
|
|
06936df164 | ||
|
|
de552874d2 | ||
|
|
f4acea8cf5 | ||
|
|
b2660c703d | ||
|
|
8ad12e32c8 | ||
|
|
4581b4cdd9 | ||
|
|
08fe43d3f9 | ||
|
|
a2f69e5485 | ||
|
|
46a4e76243 | ||
|
|
3a1b6be7d8 | ||
|
|
05100cd477 | ||
|
|
83865e3e90 | ||
|
|
3163821967 | ||
|
|
b7cc49d992 | ||
|
|
05df239ed9 | ||
|
|
9a9a261569 | ||
|
|
ac6e71f0c4 | ||
|
|
766f9c7a19 | ||
|
|
1dbc17f630 | ||
|
|
5338ce19c8 | ||
|
|
5f2df6ccb4 | ||
|
|
9b5c0b7611 | ||
|
|
812d46667d | ||
|
|
96e2abd084 | ||
|
|
286b0de74d | ||
|
|
d38eaef70b | ||
|
|
0e3782f7c3 | ||
|
|
9324b400ab | ||
|
|
9d83165d9e | ||
|
|
96f1f33e56 | ||
|
|
3695052813 | ||
|
|
9e7372584f | ||
|
|
0b874ed41f | ||
|
|
abb4772b28 | ||
|
|
0881de706e | ||
|
|
f4a99cc02c | ||
|
|
fb62e3225f | ||
|
|
7dc160721e | ||
|
|
9c88cac5cb | ||
|
|
1266a13e1f | ||
|
|
a89910829c | ||
|
|
f664c004db | ||
|
|
2fe08c7afb | ||
|
|
00266d3df6 | ||
|
|
69ba6b2956 | ||
|
|
98f67e35d8 | ||
|
|
00417a38c1 | ||
|
|
ee512a3f86 | ||
|
|
568cb7b45f | ||
|
|
d19385e160 | ||
|
|
f3e59041b5 | ||
|
|
019513a59f | ||
|
|
38efa7902e | ||
|
|
c0ca473af9 | ||
|
|
3fe2ecf0d9 | ||
|
|
d387d01f11 | ||
|
|
f294a0288d | ||
|
|
021043205c | ||
|
|
10c341af35 | ||
|
|
4d1d0113fd | ||
|
|
6da0ae8183 | ||
|
|
c144e330c0 | ||
|
|
2129b146db | ||
|
|
3d7e3414da | ||
|
|
0aa6118167 | ||
|
|
1c5b2589d1 | ||
|
|
6f23cec5d0 | ||
|
|
935fb3886f | ||
|
|
25ab653457 | ||
|
|
e1618e42a8 | ||
|
|
3cd5d2541f | ||
|
|
0f0fcecf7f | ||
|
|
664584b50e | ||
|
|
19db07b3d4 | ||
|
|
59248bad97 | ||
|
|
84b009256f | ||
|
|
b52a218c95 | ||
|
|
59017e80da | ||
|
|
cf53687376 | ||
|
|
2cb55077e2 | ||
|
|
c5ff0165ad | ||
|
|
3157b1fba9 | ||
|
|
a3e0d7928b | ||
|
|
9835541c54 | ||
|
|
21818c8a80 | ||
|
|
70e2f0b111 | ||
|
|
14c82b64c9 | ||
|
|
2ad2afd05c | ||
|
|
059f152a7a | ||
|
|
29fcc90f3e | ||
|
|
6805d5d69e | ||
|
|
f95ca97d1b | ||
|
|
395b216a2e | ||
|
|
7a98606d85 | ||
|
|
0f5e1ab949 | ||
|
|
f0758dd6ba | ||
|
|
1792f8c489 | ||
|
|
c24db7b591 | ||
|
|
8cd6a1f9a2 | ||
|
|
48091fb3d3 | ||
|
|
abc0f4f8f9 | ||
|
|
2285f367e2 | ||
|
|
fcdb57a0fc | ||
|
|
d29edf34d6 | ||
|
|
485b9550fd | ||
|
|
d00c262847 | ||
|
|
0ecb54a0f3 | ||
|
|
14ec6cf3c2 | ||
|
|
de1d61268e | ||
|
|
b186d980d6 | ||
|
|
77619b9dda | ||
|
|
bb58702833 | ||
|
|
03018f7551 | ||
|
|
1667fb4b63 | ||
|
|
c054b21f7d | ||
|
|
4c78147755 | ||
|
|
ec33d45e89 | ||
|
|
befda6e4ed | ||
|
|
3843e96252 | ||
|
|
b99df0fd65 | ||
|
|
394f764e7d | ||
|
|
cb41c2e83b | ||
|
|
5d44d1fda5 | ||
|
|
0f4c0848c7 | ||
|
|
0727458a97 | ||
|
|
fa213cd71e | ||
|
|
e1850ddde4 | ||
|
|
6a76e652aa | ||
|
|
08b1034f4f | ||
|
|
ab746abfc0 | ||
|
|
1c43d0c5af | ||
|
|
b052b47722 | ||
|
|
ded6259f62 | ||
|
|
d80e851dc0 | ||
|
|
a9c95ea655 | ||
|
|
80974fad03 | ||
|
|
b6a44b8d39 | ||
|
|
eded54bd96 | ||
|
|
96bcfd346b | ||
|
|
0dfac6b9ce | ||
|
|
c296b54827 | ||
|
|
d73dc5b073 | ||
|
|
84d8568071 | ||
|
|
5556c1874b | ||
|
|
3e2bb288da | ||
|
|
add0158554 | ||
|
|
3d8dbe1ca0 | ||
|
|
50d6360771 | ||
|
|
fbb39c83b6 | ||
|
|
07e5297ca7 | ||
|
|
dc6301e7ca | ||
|
|
350577c5a0 | ||
|
|
29d2e362de | ||
|
|
bc34190694 | ||
|
|
f14937d177 | ||
|
|
e18c75a563 | ||
|
|
9997685953 |
No files matched your search
@@ -1,2 +1,5 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
loop.h
|
||||
applet_source_list
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--break-before-boolean-operator
|
||||
--no-blank-lines-after-commas
|
||||
--braces-on-if-line
|
||||
--braces-on-struct-decl-line
|
||||
--comment-indentation25
|
||||
--declaration-comment-column25
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--cuddle-else
|
||||
--continuation-indentation4
|
||||
--case-indentation0
|
||||
--else-endif-column33
|
||||
--space-after-cast
|
||||
--line-comments-indentation0
|
||||
--declaration-indentation1
|
||||
--dont-format-first-column-comments
|
||||
--dont-format-comments
|
||||
--honour-newlines
|
||||
--indent-level4
|
||||
/* changed from 0 to 4 */
|
||||
--parameter-indentation4
|
||||
--line-length78 /* changed from 75 */
|
||||
--continue-at-parentheses
|
||||
--no-space-after-function-call-names
|
||||
--dont-break-procedure-type
|
||||
--dont-star-comments
|
||||
--leave-optional-blank-lines
|
||||
--dont-space-special-semicolon
|
||||
--tab-size4
|
||||
/* additions by Mark */
|
||||
--case-brace-indentation0
|
||||
--leave-preprocessor-space
|
||||
@@ -0,0 +1,75 @@
|
||||
List of the authors of code contained in BusyBox.
|
||||
|
||||
If you have code in BusyBox, you should be listed here. If you should be
|
||||
listed, or the description of what you have done needs more detail, or is
|
||||
incorect, _please_ let me know.
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
|
||||
Edward Betts <edward@debian.org>
|
||||
expr, hostid, logname, tty, wc, whoami, yes
|
||||
|
||||
John Beppu <beppu@lineo.com>
|
||||
du, head, nslookup, sort, tee, uniq
|
||||
|
||||
Brian Candler <B.Candler@pobox.com>
|
||||
tiny-ls(ls)
|
||||
|
||||
Randolph Chung <tausq@debian.org>
|
||||
fbset, ping, hostname, and mkfifo
|
||||
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Karl M. Hegbloom <karlheg@debian.org>
|
||||
cp_mv.c, the test suite, various fixes to utility.c, &c.
|
||||
|
||||
Daniel Jacobowitz <dan@debian.org>
|
||||
mktemp.c
|
||||
|
||||
Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
documentation, bugfixes
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
dirname, tr
|
||||
|
||||
Glenn McGrath <bug1@netconnect.com.au>
|
||||
ar.c
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox. His code is still in many apps.
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patchs.
|
||||
|
||||
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
|
||||
wget - Contributed by permission of Covad Communications
|
||||
|
||||
Pavel Roskin <proski@gnu.org>
|
||||
Lots of bugs fixes and patches.
|
||||
|
||||
Gyepi Sam <gyepi@praxis-sw.com>
|
||||
Remote logging feature for syslogd
|
||||
|
||||
Linus Torvalds <torvalds@transmeta.com>
|
||||
mkswap, fsck.minix, mkfs.minix
|
||||
|
||||
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
|
||||
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
|
||||
|
||||
Charles P. Wright <cpwright@villagenet.com>
|
||||
gzip, mini-netcat(nc)
|
||||
|
||||
Enrique Zanardi <ezanardi@ull.es>
|
||||
tarcat (since removed), loadkmap, various fixes, Debian maintenance
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
//#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
//#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
//#define BB_EXPR
|
||||
//#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
//#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
//#define BB_NSLOOKUP
|
||||
//#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
//#define BB_TELNET
|
||||
//#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
//#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Some deeply embedded systems don't have usernames or even hostnames,
|
||||
// and the default prompt can look rather hideous on them. Uncomment
|
||||
// this option for a simpler, path-only prompt (which was the default until
|
||||
// around BusyBox-0.48). On by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
//#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
//#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
//#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
|
||||
// NOTE: This file only defines features usefull under the Hurd,
|
||||
// To compile for the Hurd raname this to Config.h prior to make
|
||||
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
//#define BB_CHVT /* not needed */
|
||||
#define BB_CLEAR
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT /* inot needed */
|
||||
//#define BB_DF /* different implementation */
|
||||
#define BB_DIRNAME
|
||||
//#define BB_DMESG /* doesnt compile, different implementation */
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP /* not needed */
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
//#define BB_FBSET /* not needed, doesnt compile */
|
||||
//#define BB_FDFLUSH /* is this needed? */
|
||||
#define BB_FIND
|
||||
//#define BB_FREE /* doesnt compile */
|
||||
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_INIT /* not needed?, doesnt compile */
|
||||
//#define BB_INSMOD /* not needed, doesnt compile */
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM /* not needed, doesnt compile */
|
||||
//#define BB_LOADFONT /* not needed, doesnt compile */
|
||||
//#define BB_LOADKMAP /* not needed */
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
//#define BB_LSMOD /* not needed, doesnt compile */
|
||||
//#define BB_MAKEDEVS /* different implementation */
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
//#define BB_MKSWAP /* different impelementation (i think) */
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
//#define BB_MOUNT /* different implementation */
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
|
||||
//#define BB_POWEROFF /* different implementation i assume */
|
||||
#define BB_PRINTF
|
||||
//#define BB_PS /* needs /proc */
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
//#define BB_REBOOT /* different implementation */
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD /* not needed, doesnt compile */
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES /* is this needed ? */
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
|
||||
#define BB_SYNC
|
||||
//#define BB_SYSLOGD /* doesnt compile */
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UPTIME /* doesnt compile */
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UMOUNT /* different implementation */
|
||||
#define BB_UNIQ
|
||||
//#define BB_UNAME /* doesnt compile */
|
||||
//#define BB_UPDATE /* doesnt compile */
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names (still a bit buggy)
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
//#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
//#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
|
||||
@@ -17,15 +17,362 @@ Copyright 1998 Dave Cinege <dcinege@psychosis.com>
|
||||
mini-gzip(gzip), mini-netcat(mnc)
|
||||
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
|
||||
|
||||
|
||||
bunches of stuff as noted in header files
|
||||
Copyright (C) 1999 by Lineo, inc. and written by
|
||||
Tons of new stuff as noted in header files
|
||||
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
|
||||
copyright and license info.
|
||||
|
||||
This program suite may be distributed under the GNU General Public License.
|
||||
|
||||
|
||||
Please send patches, suggestions, insults, and bribes to <andersee@debian.org>.
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
Busybox may be used and distributed under the GNU General Public License.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -15,68 +17,359 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.50
|
||||
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
PROG=busybox
|
||||
VERSION=0.32
|
||||
BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
# developers use), all of the following configuration values can be
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# Comment out the following to make a debuggable build
|
||||
# Leave this off for production use.
|
||||
DODEBUG=false
|
||||
# If you want a static binary, turn this on. I can't think
|
||||
# of many situations where anybody would ever want it static,
|
||||
# but...
|
||||
DOSTATIC=false
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA =
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = false
|
||||
|
||||
#This will choke on a non-debian system
|
||||
ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
|
||||
# Set the following to `true' to make a debuggable build.
|
||||
# Leave this set to `false' for production use.
|
||||
# eg: `make DODEBUG=true tests'
|
||||
# Do not enable this for production builds...
|
||||
DODEBUG = false
|
||||
|
||||
# Setting this to `true' will cause busybox to directly use the system's
|
||||
# password and group functions. Assuming you use GNU libc, when this is
|
||||
# `true', you will need to install the /etc/nsswitch.conf configuration file
|
||||
# and the required libnss_* libraries. This generally makes your embedded
|
||||
# system quite a bit larger... If you leave this off, busybox will directly
|
||||
# use the /etc/password, /etc/group files (and your system will be smaller, and
|
||||
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
|
||||
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
|
||||
# Most people will want to leave this set to false.
|
||||
USE_SYSTEM_PWD_GRP = true
|
||||
|
||||
# -D_GNU_SOURCE is needed because environ is used in init.c
|
||||
ifeq ($(DODEBUG),true)
|
||||
CFLAGS=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
|
||||
STRIP=
|
||||
LDFLAGS=
|
||||
# This enables compiling with dmalloc ( http://dmalloc.com/ )
|
||||
# which is an excellent public domain mem leak and malloc problem
|
||||
# detector. To enable dmalloc, before running busybox you will
|
||||
# want to first set up your environment.
|
||||
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
|
||||
# Do not enable this for production builds...
|
||||
DODMALLOC = false
|
||||
|
||||
# If you want large file summit support, turn this on.
|
||||
# This has no effect if you don't have a kernel with lfs
|
||||
# support, and a system with libc-2.1.3 or later.
|
||||
# Some of the programs that can benefit from lfs support
|
||||
# are dd, gzip, mount, tar, and mkfs_minix.
|
||||
# LFS allows you to use the above programs for files
|
||||
# larger than 2GB!
|
||||
DOLFS = false
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@opensource.lineo.com> if you do or don't like it so far.
|
||||
BB_SRC_DIR =
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting, like "powerpc-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# This make things very easy? Everything should compile and work as
|
||||
# expected these days...
|
||||
#CC = ../uClibc/extra/gcc-uClibc/gcc-uClibc-i386
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
#
|
||||
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
||||
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
||||
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
||||
#LIBCDIR=/usr/i386-glibc20-linux
|
||||
#
|
||||
# The following is used for libc5 (if you install altgcc and libc5-altdev
|
||||
# on a Debian system).
|
||||
#LIBCDIR=/usr/i486-linuxlibc1
|
||||
#
|
||||
# For other libraries, you are on your own...
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
then echo "-Os"; else echo "-O2" ; fi)
|
||||
|
||||
WARNINGS = -Wall
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(DOLFS)),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(strip $(DODMALLOC)),true)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES = -ldmalloc
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
endif
|
||||
ifeq ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
else
|
||||
CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
|
||||
LDFLAGS= -s
|
||||
STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
|
||||
#Only staticly link when _not_ debugging
|
||||
ifeq ($(DOSTATIC),true)
|
||||
LDFLAGS+= --static
|
||||
endif
|
||||
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
#
|
||||
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
|
||||
# work) to try and strip out any unused junk. Doesn't do much for me,
|
||||
# but you may want to give it a shot...
|
||||
#
|
||||
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
|
||||
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
|
||||
# --gc-sections -v >/dev/null && echo 1),1)
|
||||
# CFLAGS += -ffunction-sections -fdata-sections
|
||||
# LDFLAGS += --gc-sections
|
||||
#endif
|
||||
endif
|
||||
|
||||
ifndef $(prefix)
|
||||
prefix=`pwd`
|
||||
ifndef $(PREFIX)
|
||||
PREFIX = `pwd`/_install
|
||||
endif
|
||||
BINDIR=$(prefix)
|
||||
|
||||
LIBRARIES=
|
||||
OBJECTS=$(shell ./busybox.sh)
|
||||
CFLAGS+= -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH = $(BB_SRC_DIR)
|
||||
endif
|
||||
#ifneq ($(strip $(VPATH)),)
|
||||
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
||||
#endif
|
||||
|
||||
all: busybox links
|
||||
# We need to set APPLET_SOURCES to something like
|
||||
# $(shell busybox.sh Config.h)
|
||||
# but in a manner that works with VPATH and BB_SRC_DIR.
|
||||
# Possible ways to approach this:
|
||||
#
|
||||
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
|
||||
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
|
||||
#
|
||||
# 2. Explicity search through .:$(VPATH) for slist.mk,
|
||||
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
|
||||
#
|
||||
# 3. Create slist.mk in this directory, with commands embedded in
|
||||
# a $(shell ...) command, and $(MAKE) it immediately.
|
||||
#
|
||||
# 4. Use a real rule within this makefile to create a file that sets
|
||||
# APPLET_SOURCE_LIST, then include that file. Has complications
|
||||
# with the first trip through the makefile (before processing the
|
||||
# include) trying to do too much, and a spurious warning the first
|
||||
# time make is run.
|
||||
#
|
||||
# This is option 3:
|
||||
#
|
||||
#APPLET_SOURCES = $(shell \
|
||||
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
|
||||
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
|
||||
#)
|
||||
# And option 4:
|
||||
-include applet_source_list
|
||||
|
||||
busybox: $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
|
||||
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o messages.o usage.o utility.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
|
||||
PWD_GRP = pwd_grp
|
||||
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
|
||||
PWD_LIB = libpwd.a
|
||||
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
|
||||
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
|
||||
initgroups.c setgroups.c
|
||||
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
|
||||
PWD_CFLAGS = -I$(PWD_GRP_DIR)
|
||||
else
|
||||
CFLAGS += -DUSE_SYSTEM_PWD_GRP
|
||||
endif
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
|
||||
|
||||
doc: olddoc
|
||||
|
||||
# Old Docs...
|
||||
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
-mkdir -p docs
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2html*
|
||||
|
||||
|
||||
# New docs based on DOCBOOK SGML
|
||||
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
|
||||
|
||||
docs/busybox.txt: docs/busybox.sgml
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b txt busybox.sgml)
|
||||
|
||||
docs/busybox.dvi: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b dvi busybox.sgml)
|
||||
|
||||
docs/busybox.ps: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b ps busybox.sgml)
|
||||
|
||||
docs/busybox.pdf: docs/busybox.ps
|
||||
- mkdir -p docs
|
||||
(cd docs; ps2pdf busybox.ps)
|
||||
|
||||
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
|
||||
busybox: $(PWD_LIB) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES) $(PWD_LIB)
|
||||
$(STRIP)
|
||||
|
||||
links:
|
||||
- ./busybox.mkll | sort >busybox.links
|
||||
|
||||
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
|
||||
# but with VPATH, some or all of those file names are resolved to the
|
||||
# directories in which they live.
|
||||
busybox.links: busybox.mkll Config.h applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
sh.o: cmdedit.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
|
||||
|
||||
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
- mkdir -p $(PWD_GRP)
|
||||
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
|
||||
|
||||
libpwd.a: $(PWD_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
usage.o: usage.h
|
||||
|
||||
utility.o: loop.h
|
||||
|
||||
loop.h: mk_loop_h.sh
|
||||
@ $(SHELL) $< > $@
|
||||
|
||||
test tests:
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
cd tests && ./tester.sh
|
||||
|
||||
clean:
|
||||
- rm -f $(PROG) busybox.links *~ *.o core
|
||||
- cd tests && $(MAKE) clean
|
||||
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
|
||||
- rm -f multibuild.log Config.h.orig
|
||||
- rm -rf docs/busybox _install libpwd.a
|
||||
- rm -f busybox.links loop.h *~ slist.mk core applet_source_list
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f $(PROG)
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
force:
|
||||
install: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
$(OBJECTS): busybox.def.h internal.h Makefile
|
||||
install-hardlinks: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
install: $(PROG)
|
||||
install.sh $(BINDIR)
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
cd ..; \
|
||||
rm -rf busybox-$(VERSION); \
|
||||
cp -a busybox busybox-$(VERSION); \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type d \
|
||||
-name CVS \
|
||||
-print \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .cvsignore \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
.PHONY: tags
|
||||
tags:
|
||||
ctags -R .
|
||||
@@ -1,26 +1,122 @@
|
||||
Please see the LICENSE file for copyright information.
|
||||
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
|
||||
embedded system. The utilities in BusyBox generally have fewer options than
|
||||
their full featured GNU cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their GNU counterparts.
|
||||
|
||||
Busybox is a multicall binary used to provide a minimal subset of
|
||||
POSIX style commands and specialized functions.
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add /dev, a kernel, and an editor,
|
||||
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
|
||||
the busybox shell (not Bourne compatible, but very small and quite usable).
|
||||
|
||||
It is geared toward the very small, i.e. boot floppies, embedded-
|
||||
systems, etc. Specifically it is used in the Debian Rescue/Install
|
||||
system (which caused the original busybox to be made), the Linux Router
|
||||
Project, and others.
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
As of version 0.20 there is a version number. : )
|
||||
Also as of version 0.20, BB is modularized to allow an easy build of
|
||||
only the BB parts you need, to reduce binary size.
|
||||
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
|
||||
BusyBox is now modularized to easily allow you to build only the components you
|
||||
need, thereby reducing binary size. To turn off unwanted BusyBox components,
|
||||
simply edit the file "Config.h" and comment out the components you do not need
|
||||
using C++ style (//) comments.
|
||||
|
||||
Edit the file busybox.def.h and comment out the parts you do not need
|
||||
using C++ comments (//)
|
||||
After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e., 'make PREFIX=/tmp/foo install')
|
||||
|
||||
After the build is complete a busybox.links file is generated to allow
|
||||
you to easily make the sym/hard links to the busybox binary.
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Note the modular system is Makefile based, and purposely very
|
||||
simplistic. It does no dependency checking. That is left for you
|
||||
to figure out by trial and error.
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, and SH3/4.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
|
||||
newlib and diet-libc, but consider them unsupported, untested, or worse.
|
||||
|
||||
Supported kernels:
|
||||
|
||||
Full functionality requires Linux 2.0.x, 2.2.x, or 2.4.x. A large fraction
|
||||
of the code should run on just about anything.
|
||||
|
||||
----------------
|
||||
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://opensource.lineo.com/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
Bugs:
|
||||
|
||||
If you find bugs, please submit a bug report. Full instructions on how to
|
||||
report a bug are found at http://bugs.lineo.com/Reporting.html.
|
||||
|
||||
For the impatient: To submit a bug, simply send an email describing the problem
|
||||
to submit@bugs.lineo.com. Bug reports should look something like this:
|
||||
|
||||
To: submit@bugs.lineo.com
|
||||
From: diligent@testing.linux.org
|
||||
Subject: /bin/true doesn't work
|
||||
|
||||
Package: busybox
|
||||
Version: 0.48
|
||||
|
||||
When I invoke '/bin/true' it doesn't work. I expected it to return
|
||||
a "0" but it returned a "1" instead. Here is the transcript:
|
||||
$ /bin/true ; echo $?
|
||||
1
|
||||
With GNU /bin/true, I get the following output:
|
||||
$ /bin/true ; echo $?
|
||||
0
|
||||
I am using Debian 2.2r2, kernel version 2.2.18, and the latest
|
||||
uClibc from CVS. Thanks for the wonderful program!
|
||||
-Diligent
|
||||
|
||||
Note the careful description and use of examples showing not only what BusyBox
|
||||
does, but also a counter example showing what an equivalent GNU app does. Bug
|
||||
reports lacking such detail may take a _long_ time to be fixed... Thanks for
|
||||
understanding.
|
||||
|
||||
----------------
|
||||
|
||||
FTP:
|
||||
|
||||
Source for the latest released version can always be downloaded from
|
||||
ftp://ftp.lineo.com/pub/busybox.
|
||||
|
||||
----------------
|
||||
|
||||
CVS:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
http://opensource.lineo.com/cvs_anon.html
|
||||
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://opensource.lineo.com/cvs_write.html
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
</blatant plug>
|
||||
|
||||
Please feed patches back to:
|
||||
Erik Andersen <andersee@deban.org>
|
||||
@@ -0,0 +1,57 @@
|
||||
TODO list for busybox in no particular order. Just because something
|
||||
is listed here doesn't mean that it is going to be added to busybox,
|
||||
or that doing so is even a good idea. It just means that I _might_ get
|
||||
around to it some time. If you have any good ideas, please let me know.
|
||||
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* We _were_ going to split networking apps into a new package called
|
||||
netkit-tiny. Per discussions on the mailing list, this isn't going
|
||||
to happen. False alarm. Sorry about the confusion.
|
||||
|
||||
* The busybox shell, lash, is really too weak for serious use, although it is
|
||||
possible to run simple systems with it. BusyBox 0.49 was supposed to have
|
||||
a new shell, updated to understand full Bourne grammer. Well, that simply
|
||||
didn't happen in time for the release. A rewrite is in progress that will
|
||||
result in a new shell that understands the full Bourne grammar. This new
|
||||
shell is being championed by Larry Doolittle <ldoolitt@recycle.lbl.gov>, and
|
||||
could use your help. Please see the work in progress at
|
||||
http://doolittle.faludi.com/~larry/parser.html
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------
|
||||
|
||||
Write a fixup_globals function to do just that right before calling
|
||||
non-forking applets. Or, just always fork...
|
||||
|
||||
-----------------------
|
||||
|
||||
Run the following:
|
||||
|
||||
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
|
||||
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
|
||||
|
||||
reveals the list of all external (i.e. libc) things that BusyBox depends on.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox, especially when staticly linking with
|
||||
libraries such as uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
Compile with debugging on, run 'nm --size-sort ./busybox'
|
||||
and then start with the biggest things and make them smaller...
|
||||
|
||||
-----------------------
|
||||
|
||||
du.c probably ought to have an -x switch like GNU du does...
|
||||
|
||||
------------------------------------------------------------------
|
||||
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* applets.h - a listing of all busybox applets.
|
||||
*
|
||||
* If you write a new applet, you need to add an entry to this list to make
|
||||
* busybox aware of it.
|
||||
*
|
||||
* It is CRUCIAL that this listing be kept in ascii order, otherwise the binary
|
||||
* search lookup contributed by Gaute B Strokkenes stops working. If you value
|
||||
* your kneecaps, you'll be sure to *make sure* that any changes made to this
|
||||
* file result in the listing remaining in ascii order. You have been warned.
|
||||
*/
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_ODDNAME
|
||||
#undef APPLET_NOUSAGE
|
||||
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
|
||||
extern const char usage_messages[];
|
||||
#elif defined(MAKE_USAGE)
|
||||
#ifdef BB_FEATURE_TRIVIAL_HELP
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
|
||||
#else
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
|
||||
#endif
|
||||
#elif defined(MAKE_LINKS)
|
||||
# define APPLET(a,b,c) LINK c a
|
||||
# define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET_ODDNAME(a,b,c,d) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c) {#a,b,c},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
|
||||
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET(cat, cat_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chgrp, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chmod, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chown, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET(cp, cp_mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET(date, date_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET(dd, dd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET(df, df_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG
|
||||
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG_DEB
|
||||
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET(du, du_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET(echo, echo_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
|
||||
APPLET_NOUSAGE("egrep", init_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(false, false_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET(find, find_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET(free, free_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET(getopt, getopt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET(grep, grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET(gzip, gzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET(halt, halt_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET(head, head_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET(hostname, hostname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET(id, id_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_IFCONFIG
|
||||
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET(init, init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KLOGD
|
||||
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET(length, length_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET(ln, ln_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGREAD
|
||||
APPLET(logread, logread_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET(ls, ls_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET(mknod, mknod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET(more, more_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET(mount, mount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET(mt, mt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET(mv, cp_mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET(ping, ping_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PIVOT_ROOT
|
||||
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET(ps, ps_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET(pwd, pwd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET(rm, rm_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ROUTE
|
||||
APPLET(route, route_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET(rpmunpack, rpmunpack_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET(sed, sed_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET(sh, shell_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET(sleep, sleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_STTY
|
||||
APPLET(stty, stty_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET(sync, sync_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET(tar, tar_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET(test, test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TFTP
|
||||
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET(touch, touch_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(true, true_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET(umount, umount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET(update, update_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET(usleep, usleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WATCHDOG
|
||||
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET(which, which_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
|
||||
{ 0,NULL,0 }
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
+171
-222
@@ -1,246 +1,195 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
const char *applet_name;
|
||||
|
||||
static const struct Applet applets[] = {
|
||||
|
||||
#ifdef BB_BUSYBOX //bin
|
||||
{"busybox", busybox_main},
|
||||
#endif
|
||||
#ifdef BB_BLOCK_DEVICE //sbin
|
||||
{"block_device", block_device_main},
|
||||
#endif
|
||||
#ifdef BB_CAT //bin
|
||||
{"cat", cat_main},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP //bin
|
||||
{"chmod", chmod_chown_chgrp_main},
|
||||
{"chown", chmod_chown_chgrp_main},
|
||||
{"chgrp", chmod_chown_chgrp_main},
|
||||
#endif
|
||||
#ifdef BB_CHROOT //sbin
|
||||
{"chroot", chroot_main},
|
||||
#endif
|
||||
#ifdef BB_CLEAR //usr/bin
|
||||
{"clear", clear_main},
|
||||
#endif
|
||||
#ifdef BB_CP //bin
|
||||
{"cp", cp_main},
|
||||
#endif
|
||||
#ifdef BB_DATE //bin
|
||||
{"date", date_main},
|
||||
#endif
|
||||
#ifdef BB_DD //bin
|
||||
{"dd", dd_main},
|
||||
#endif
|
||||
#ifdef BB_DF //bin
|
||||
{"df", df_main},
|
||||
#endif
|
||||
#ifdef BB_DMESG //bin
|
||||
{"dmesg", dmesg_main},
|
||||
#endif
|
||||
#ifdef BB_DUTMP //usr/sbin
|
||||
{"dutmp", dutmp_main},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH //bin
|
||||
{"fdflush", fdflush_main},
|
||||
#endif
|
||||
#ifdef BB_FIND //usr/bin
|
||||
{"find", find_main},
|
||||
#endif
|
||||
#ifdef BB_CHVT //usr/bin
|
||||
{"chvt", chvt_main},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT //usr/bin
|
||||
{"deallocvt", deallocvt_main},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX //sbin
|
||||
{"fsck.minix", fsck_minix_main},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX //sbin
|
||||
{"mkfs.minix", mkfs_minix_main},
|
||||
#endif
|
||||
#ifdef BB_GREP //bin
|
||||
{"grep", grep_main},
|
||||
#endif
|
||||
#ifdef BB_HALT //sbin
|
||||
{"halt", halt_main},
|
||||
#endif
|
||||
#ifdef BB_INIT //sbin
|
||||
{"init", init_main},
|
||||
#endif
|
||||
#ifdef BB_KILL //bin
|
||||
{"kill", kill_main},
|
||||
#endif
|
||||
#ifdef BB_LENGTH //usr/bin
|
||||
{"length", length_main},
|
||||
#endif
|
||||
#ifdef BB_LN //bin
|
||||
{"ln", ln_main},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT //usr/bin
|
||||
{"loadfont", loadfont_main},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP //sbin
|
||||
{"loadkmap", loadkmap_main},
|
||||
#endif
|
||||
#ifdef BB_LS //bin
|
||||
{"ls", ls_main},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS //sbin
|
||||
{"makedevs", makedevs_main},
|
||||
#endif
|
||||
#ifdef BB_MATH //usr/bin
|
||||
{"math", math_main},
|
||||
#endif
|
||||
#ifdef BB_MKDIR //bin
|
||||
{"mkdir", mkdir_main},
|
||||
#endif
|
||||
#ifdef BB_MKNOD //bin
|
||||
{"mknod", mknod_main},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP //sbin
|
||||
{"mkswap", mkswap_main},
|
||||
#endif
|
||||
#ifdef BB_MNC //usr/bin
|
||||
{"mnc", mnc_main},
|
||||
#endif
|
||||
#ifdef BB_MORE //bin
|
||||
{"more", more_main},
|
||||
#endif
|
||||
#ifdef BB_MOUNT //bin
|
||||
{"mount", mount_main},
|
||||
#endif
|
||||
#ifdef BB_MT //bin
|
||||
{"mt", mt_main},
|
||||
#endif
|
||||
#ifdef BB_MV //bin
|
||||
{"mv", mv_main},
|
||||
#endif
|
||||
#ifdef BB_PRINTF //usr/bin
|
||||
{"printf", printf_main},
|
||||
#endif
|
||||
#ifdef BB_PS //bin
|
||||
{"ps", ps_main},
|
||||
#endif
|
||||
#ifdef BB_PWD //bin
|
||||
{"pwd", pwd_main},
|
||||
#endif
|
||||
#ifdef BB_REBOOT //sbin
|
||||
{"reboot", reboot_main},
|
||||
#endif
|
||||
#ifdef BB_RM //bin
|
||||
{"rm", rm_main},
|
||||
#endif
|
||||
#ifdef BB_RMDIR //bin
|
||||
{"rmdir", rmdir_main},
|
||||
#endif
|
||||
#ifdef BB_SFDISK //sbin
|
||||
{"fdisk", sfdisk_main},
|
||||
{"sfdisk", sfdisk_main},
|
||||
#endif
|
||||
#ifdef BB_SED //bin
|
||||
{"sed", sed_main},
|
||||
#endif
|
||||
#ifdef BB_SLEEP //bin
|
||||
{"sleep", sleep_main},
|
||||
#endif
|
||||
#ifdef BB_TAR //bin
|
||||
{"tar", tar_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF //sbin
|
||||
{"swapon", swap_on_off_main},
|
||||
{"swapoff", swap_on_off_main},
|
||||
#endif
|
||||
#ifdef BB_SYNC //bin
|
||||
{"sync", sync_main},
|
||||
#endif
|
||||
#ifdef BB_TOUCH //usr/bin
|
||||
{"touch", touch_main},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE //bin
|
||||
{"true", true_main},
|
||||
{"false", false_main},
|
||||
#endif
|
||||
#ifdef BB_UNAME //bin
|
||||
{"uname", uname_main},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT //bin
|
||||
{"umount", umount_main},
|
||||
#endif
|
||||
#ifdef BB_UPDATE //sbin
|
||||
{"update", update_main},
|
||||
#endif
|
||||
#ifdef BB_ZCAT //bin
|
||||
{"zcat", zcat_main},
|
||||
{"gunzip", zcat_main},
|
||||
#endif
|
||||
#ifdef BB_GZIP //bin
|
||||
{"gzip", gzip_main},
|
||||
#endif
|
||||
{0}
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Where in the filesystem is this busybox?
|
||||
* [return]
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *s = argv[0];
|
||||
char *name = argv[0];
|
||||
const struct Applet *a = applets;
|
||||
const char *s;
|
||||
|
||||
while (*s != '\0') {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
}
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
int status;
|
||||
|
||||
status = ((*(a->main)) (argc, argv));
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(status);
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
exit (busybox_main(argc, argv));
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col=0;
|
||||
argc--;
|
||||
argv++;
|
||||
int col = 0, len, i;
|
||||
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct Applet *a = applets;
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "\nUsage:\t[function] [arguments]...\n");
|
||||
fprintf(stderr, "\tbusybox [function] [arguments]...\n");
|
||||
fprintf(stderr,
|
||||
"\n\tMost people will create a symlink to busybox for each\n"
|
||||
"\tfunction name, and busybox will act like whatever you invoke it as.\n");
|
||||
fprintf(stderr, "\nCurrently defined functions:\n");
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
while (a->name != 0) {
|
||||
col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
|
||||
if (col>60) {
|
||||
fprintf(stderr, ",\n");
|
||||
col=0;
|
||||
}
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > 60 && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+20
-11
@@ -1,15 +1,24 @@
|
||||
#!/bin/sh
|
||||
#Make busybox links list file
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="busybox.c"
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n 's/^#ifdef \<'$def'\>.*\/\/\(.*$\)/\/\1\//gp' $MF`
|
||||
j=`sed -n '/^#ifdef '$def'.*/,/^#endif/{ s/.*\"\(.*\)\".*/\1/gp; }' $MF`
|
||||
for k in $j; do
|
||||
echo $i$k
|
||||
done
|
||||
done
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
+14
-2
@@ -1,4 +1,16 @@
|
||||
#!/bin/sh
|
||||
sed -n '/^#define/{s/.*BB_//; s/$/.o/p; }' busybox.def.h | \
|
||||
tr [:upper:] [:lower:]
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
prefix=$1
|
||||
if [ "$prefix" = "" ]; then
|
||||
echo "No installation directory, aborting."
|
||||
exit 1;
|
||||
fi
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
linkopts="-f"
|
||||
else
|
||||
linkopts="-fs"
|
||||
fi
|
||||
h=`sort busybox.links | uniq`
|
||||
|
||||
|
||||
rm -f $prefix/bin/busybox || exit 1
|
||||
mkdir -p $prefix/bin || exit 1
|
||||
install -m 755 busybox $prefix/bin/busybox || exit 1
|
||||
|
||||
for i in $h ; do
|
||||
appdir=`dirname $i`
|
||||
mkdir -p $prefix/$appdir || exit 1
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
else
|
||||
case "$appdir" in
|
||||
/)
|
||||
bb_path="bin/busybox"
|
||||
;;
|
||||
/bin)
|
||||
bb_path="busybox"
|
||||
;;
|
||||
/sbin)
|
||||
bb_path="../bin/busybox"
|
||||
;;
|
||||
/usr/bin|/usr/sbin)
|
||||
bb_path="../../bin/busybox"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown installation directory: $appdir"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo " $prefix$i -> $bb_path"
|
||||
ln $linkopts $bb_path $prefix$i || exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
+1716
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,227 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
/* find files to extract or display */
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
/* find files to extract or display */
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+855
@@ -0,0 +1,855 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if !defined __GLIBC__ && !defined __UCLIBC__
|
||||
#error It looks like you are using libc5, which does not support
|
||||
#error tfind(). tfind() is used by busybox dpkg.
|
||||
#error Please disable BB_DPKG. Sorry.
|
||||
#endif
|
||||
|
||||
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
|
||||
|
||||
/* Should we do full dependency checking? */
|
||||
#define DODEPENDS 1
|
||||
|
||||
/* Should we do debugging? */
|
||||
#define DODEBUG 1
|
||||
|
||||
#ifdef DODEBUG
|
||||
#define SYSTEM(x) do_system(x)
|
||||
#define DPRINTF(fmt,args...) fprintf(stderr, fmt, ##args)
|
||||
#else
|
||||
#define SYSTEM(x) system(x)
|
||||
#define DPRINTF(fmt,args...) /* nothing */
|
||||
#endif
|
||||
|
||||
/* from dpkg-deb.c */
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
static const char statusfile[] = "/var/lib/dpkg/status.udeb";
|
||||
static const char new_statusfile[] = "/var/lib/dpkg/status.udeb.new";
|
||||
static const char bak_statusfile[] = "/var/lib/dpkg/status.udeb.bak";
|
||||
|
||||
static const char dpkgcidir[] = "/var/lib/dpkg/tmp.ci/";
|
||||
|
||||
static const char infodir[] = "/var/lib/dpkg/info/";
|
||||
static const char udpkg_quiet[] = "UDPKG_QUIET";
|
||||
|
||||
//static const int status_wantstart = 0;
|
||||
//static const int status_wantunknown = (1 << 0);
|
||||
static const int status_wantinstall = (1 << 1);
|
||||
//static const int status_wanthold = (1 << 2);
|
||||
//static const int status_wantdeinstall = (1 << 3);
|
||||
//static const int status_wantpurge = (1 << 4);
|
||||
static const int status_wantmask = 31;
|
||||
|
||||
//static const int status_flagstart = 5;
|
||||
static const int status_flagok = (1 << 5); /* 32 */
|
||||
//static const int status_flagreinstreq = (1 << 6);
|
||||
//static const int status_flaghold = (1 << 7);
|
||||
//static const int status_flagholdreinstreq = (1 << 8);
|
||||
static const int status_flagmask = 480;
|
||||
|
||||
//static const int status_statusstart = 9;
|
||||
//static const int status_statusnoninstalled = (1 << 9); /* 512 */
|
||||
static const int status_statusunpacked = (1 << 10);
|
||||
static const int status_statushalfconfigured = (1 << 11);
|
||||
static const int status_statusinstalled = (1 << 12);
|
||||
static const int status_statushalfinstalled = (1 << 13);
|
||||
//static const int status_statusconfigfiles = (1 << 14);
|
||||
//static const int status_statuspostinstfailed = (1 << 15);
|
||||
//static const int status_statusremovalfailed = (1 << 16);
|
||||
static const int status_statusmask = 130560; /* i assume status_statusinstalled is supposed to be included */
|
||||
|
||||
static const char *statuswords[][10] = {
|
||||
{ (char *) 0, "unknown", "install", "hold", "deinstall", "purge", 0 },
|
||||
{ (char *) 5, "ok", "reinstreq", "hold", "hold-reinstreq", 0 },
|
||||
{ (char *) 9, "not-installed", "unpacked", "half-configured",
|
||||
"installed", "half-installed", "config-files",
|
||||
"post-inst-failed", "removal-failed", 0 }
|
||||
};
|
||||
|
||||
static const int color_white = 0;
|
||||
static const int color_grey = 1;
|
||||
static const int color_black = 2;
|
||||
|
||||
/* data structures */
|
||||
typedef struct package_s {
|
||||
char *file;
|
||||
char *package;
|
||||
char *version;
|
||||
char *depends;
|
||||
char *provides;
|
||||
char *description;
|
||||
int installer_menu_item;
|
||||
unsigned long status;
|
||||
char color; /* for topo-sort */
|
||||
struct package_s *requiredfor[DEPENDSMAX];
|
||||
unsigned short requiredcount;
|
||||
struct package_s *next;
|
||||
} package_t;
|
||||
|
||||
#ifdef DODEBUG
|
||||
static int do_system(const char *cmd)
|
||||
{
|
||||
DPRINTF("cmd is %s\n", cmd);
|
||||
return system(cmd);
|
||||
}
|
||||
#else
|
||||
#define do_system(cmd) system(cmd)
|
||||
#endif
|
||||
|
||||
static int package_compare(const void *p1, const void *p2)
|
||||
{
|
||||
return strcmp(((package_t *)p1)->package,
|
||||
((package_t *)p2)->package);
|
||||
}
|
||||
|
||||
static int remove_dpkgcidir()
|
||||
{
|
||||
char *rm_dpkgcidir = NULL;
|
||||
|
||||
rm_dpkgcidir = (char *) xmalloc(strlen(dpkgcidir) + 8);
|
||||
strcpy(rm_dpkgcidir, "rm -rf ");
|
||||
strcat(rm_dpkgcidir, dpkgcidir);
|
||||
|
||||
if (SYSTEM(rm_dpkgcidir) != 0) {
|
||||
perror("mkdir ");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef DODEPENDS
|
||||
#include <ctype.h>
|
||||
|
||||
static char **depends_split(const char *dependsstr)
|
||||
{
|
||||
static char *dependsvec[DEPENDSMAX];
|
||||
char *p;
|
||||
int i = 0;
|
||||
|
||||
dependsvec[0] = 0;
|
||||
if (dependsstr == 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
p = strdup(dependsstr);
|
||||
while (*p != 0 && *p != '\n') {
|
||||
if (*p != ' ') {
|
||||
if (*p == ',') {
|
||||
*p = 0;
|
||||
dependsvec[++i] = 0;
|
||||
} else {
|
||||
if (dependsvec[i] == 0) {
|
||||
dependsvec[i] = p;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*p = 0; /* eat the space... */
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
end:
|
||||
dependsvec[i+1] = 0;
|
||||
return dependsvec;
|
||||
}
|
||||
|
||||
/* Topological sort algorithm:
|
||||
* ordered is the output list, pkgs is the dependency graph, pkg is
|
||||
* the current node
|
||||
*
|
||||
* recursively add all the adjacent nodes to the ordered list, marking
|
||||
* each one as visited along the way
|
||||
*
|
||||
* yes, this algorithm looks a bit odd when all the params have the
|
||||
* same type :-)
|
||||
*/
|
||||
static void depends_sort_visit(package_t **ordered, package_t *pkgs,
|
||||
package_t *pkg)
|
||||
{
|
||||
unsigned short i;
|
||||
|
||||
/* mark node as processing */
|
||||
pkg->color = color_grey;
|
||||
|
||||
/* visit each not-yet-visited node */
|
||||
for (i = 0; i < pkg->requiredcount; i++)
|
||||
if (pkg->requiredfor[i]->color == color_white)
|
||||
depends_sort_visit(ordered, pkgs, pkg->requiredfor[i]);
|
||||
|
||||
#if 0
|
||||
/* add it to the list */
|
||||
newnode = (struct package_t *)xmalloc(sizeof(struct package_t));
|
||||
/* make a shallow copy */
|
||||
*newnode = *pkg;
|
||||
newnode->next = *ordered;
|
||||
*ordered = newnode;
|
||||
#endif
|
||||
|
||||
pkg->next = *ordered;
|
||||
*ordered = pkg;
|
||||
|
||||
/* mark node as done */
|
||||
pkg->color = color_black;
|
||||
}
|
||||
|
||||
static package_t *depends_sort(package_t *pkgs)
|
||||
{
|
||||
/* TODO: it needs to break cycles in the to-be-installed package
|
||||
* graph... */
|
||||
package_t *ordered = NULL;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
pkg->color = color_white;
|
||||
}
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
if (pkg->color == color_white) {
|
||||
depends_sort_visit(&ordered, pkgs, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Leaks the old list... return the new one... */
|
||||
return ordered;
|
||||
}
|
||||
|
||||
|
||||
/* resolve package dependencies --
|
||||
* for each package in the list of packages to be installed, we parse its
|
||||
* dependency info to determine if the dependent packages are either
|
||||
* already installed, or are scheduled to be installed. If both tests fail
|
||||
* than bail.
|
||||
*
|
||||
* The algorithm here is O(n^2*m) where n = number of packages to be
|
||||
* installed and m is the # of dependencies per package. Not a terribly
|
||||
* efficient algorithm, but given that at any one time you are unlikely
|
||||
* to install a very large number of packages it doesn't really matter
|
||||
*/
|
||||
static package_t *depends_resolve(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *pkg, *chk;
|
||||
package_t dependpkg;
|
||||
char **dependsvec;
|
||||
int i;
|
||||
void *found;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
dependsvec = depends_split(pkg->depends);
|
||||
i = 0;
|
||||
while (dependsvec[i] != 0) {
|
||||
/* Check for dependencies; first look for installed packages */
|
||||
dependpkg.package = dependsvec[i];
|
||||
if ((found = tfind(&dependpkg, &status, package_compare)) == 0 ||
|
||||
((chk = *(package_t **)found) &&
|
||||
(chk->status & (status_flagok | status_statusinstalled)) !=
|
||||
(status_flagok | status_statusinstalled))) {
|
||||
|
||||
/* if it fails, we look through the list of packages we are going to
|
||||
* install */
|
||||
for (chk = pkgs; chk != 0; chk = chk->next) {
|
||||
if (strcmp(chk->package, dependsvec[i]) == 0 || (chk->provides &&
|
||||
strncmp(chk->provides, dependsvec[i], strlen(dependsvec[i])) == 0)) {
|
||||
if (chk->requiredcount >= DEPENDSMAX) {
|
||||
fprintf(stderr, "Too many dependencies for %s\n", chk->package);
|
||||
return 0;
|
||||
}
|
||||
if (chk != pkg) {
|
||||
chk->requiredfor[chk->requiredcount++] = pkg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chk == 0) {
|
||||
fprintf(stderr, "%s depends on %s, but it is not going to be installed\n", pkg->package, dependsvec[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return depends_sort(pkgs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Status file handling routines
|
||||
*
|
||||
* This is a fairly minimalistic implementation. there are two main functions
|
||||
* that are supported:
|
||||
*
|
||||
* 1) reading the entire status file:
|
||||
* the status file is read into memory as a binary-tree, with just the
|
||||
* package and status info preserved
|
||||
*
|
||||
* 2) merging the status file
|
||||
* control info from (new) packages is merged into the status file,
|
||||
* replacing any pre-existing entries. when a merge happens, status info
|
||||
* read using the status_read function is written back to the status file
|
||||
*/
|
||||
static unsigned long status_parse(const char *line)
|
||||
{
|
||||
char *p;
|
||||
int i, j;
|
||||
unsigned long l = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((p = strchr(line, ' ')) != NULL) {
|
||||
*p = 0;
|
||||
}
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if (strcmp(line, statuswords[i][j]) == 0) {
|
||||
l |= (1 << ((int)statuswords[i][0] + j - 1));
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
/* parse error */
|
||||
if (statuswords[i][j] == 0) {
|
||||
return 0;
|
||||
}
|
||||
line = p+1;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static const char *status_print(unsigned long flags)
|
||||
{
|
||||
/* this function returns a static buffer... */
|
||||
static char buf[256];
|
||||
int i, j;
|
||||
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if ((flags & (1 << ((int)statuswords[i][0] + j - 1))) != 0) {
|
||||
strcat(buf, statuswords[i][j]);
|
||||
if (i < 2) strcat(buf, " ");
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (statuswords[i][j] == 0) {
|
||||
fprintf(stderr, "corrupted status flag!!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a control file (or a stanza of a status file) and parse it,
|
||||
* filling parsed fields into the package structure
|
||||
*/
|
||||
static int control_read(FILE *file, package_t *p)
|
||||
{
|
||||
char *line;
|
||||
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
line[strlen(line)] = 0;
|
||||
|
||||
if (strlen(line) == 0) {
|
||||
break;
|
||||
} else
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
p->package = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Status: ") == line) {
|
||||
p->status = status_parse(line + 8);
|
||||
} else
|
||||
if (strstr(line, "Depends: ") == line) {
|
||||
p->depends = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Provides: ") == line) {
|
||||
p->provides = strdup(line + 10);
|
||||
} else
|
||||
if (strstr(line, "Description: ") == line) {
|
||||
p->description = strdup(line + 13);
|
||||
/* This is specific to the Debian Installer. Ifdef? */
|
||||
} else
|
||||
if (strstr(line, "installer-menu-item: ") == line) {
|
||||
p->installer_menu_item = atoi(line + 21);
|
||||
}
|
||||
/* TODO: localized descriptions */
|
||||
}
|
||||
free(line);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void *status_read(void)
|
||||
{
|
||||
FILE *f;
|
||||
void *status = 0;
|
||||
package_t *m = 0, *p = 0, *t = 0;
|
||||
|
||||
if ((f = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Reading database...)\n");
|
||||
}
|
||||
|
||||
while (!feof(f)) {
|
||||
m = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(m, 0, sizeof(package_t));
|
||||
control_read(f, m);
|
||||
if (m->package) {
|
||||
/*
|
||||
* If there is an item in the tree by this name,
|
||||
* it must be a virtual package; insert real
|
||||
* package in preference.
|
||||
*/
|
||||
tdelete(m, &status, package_compare);
|
||||
tsearch(m, &status, package_compare);
|
||||
if (m->provides) {
|
||||
/*
|
||||
* A "Provides" triggers the insertion
|
||||
* of a pseudo package into the status
|
||||
* binary-tree.
|
||||
*/
|
||||
p = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
p->package = strdup(m->provides);
|
||||
|
||||
t = *(package_t **)tsearch(p, &status, package_compare);
|
||||
if (t != p) {
|
||||
free(p->package);
|
||||
free(p);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Pseudo package status is the
|
||||
* same as the status of the
|
||||
* package providing it
|
||||
* FIXME: (not quite right, if 2
|
||||
* packages of different statuses
|
||||
* provide it).
|
||||
*/
|
||||
t->status = m->status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int status_merge(void *status, package_t *pkgs)
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
char *line;
|
||||
package_t *pkg = 0, *statpkg = 0;
|
||||
package_t locpkg;
|
||||
int r = 0;
|
||||
|
||||
if ((fin = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
if ((fout = fopen(new_statusfile, "w")) == NULL) {
|
||||
perror(new_statusfile);
|
||||
return 0;
|
||||
}
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Updating database...)\n");
|
||||
}
|
||||
|
||||
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
|
||||
line[strlen(line)] = 0; /* trim newline */
|
||||
/* If we see a package header, find out if it's a package
|
||||
* that we have processed. if so, we skip that block for
|
||||
* now (write it at the end).
|
||||
*
|
||||
* we also look at packages in the status cache and update
|
||||
* their status fields
|
||||
*/
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
for (pkg = pkgs; pkg != 0 && strncmp(line + 9,
|
||||
pkg->package, strlen(line) - 9) != 0;
|
||||
pkg = pkg->next) ;
|
||||
|
||||
locpkg.package = line + 9;
|
||||
statpkg = tfind(&locpkg, &status, package_compare);
|
||||
|
||||
/* note: statpkg should be non-zero, unless the status
|
||||
* file was changed while we are processing (no locking
|
||||
* is currently done...
|
||||
*/
|
||||
if (statpkg != 0) {
|
||||
statpkg = *(package_t **)statpkg;
|
||||
}
|
||||
}
|
||||
if (pkg != 0) {
|
||||
continue;
|
||||
}
|
||||
if (strstr(line, "Status: ") == line && statpkg != 0) {
|
||||
snprintf(line, sizeof(line), "Status: %s",
|
||||
status_print(statpkg->status));
|
||||
}
|
||||
fputs(line, fout);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
free(line);
|
||||
|
||||
// Print out packages we processed.
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
fprintf(fout, "Package: %s\nStatus: %s\n",
|
||||
pkg->package, status_print(pkg->status));
|
||||
if (pkg->depends)
|
||||
fprintf(fout, "Depends: %s\n", pkg->depends);
|
||||
if (pkg->provides)
|
||||
fprintf(fout, "Provides: %s\n", pkg->provides);
|
||||
if (pkg->installer_menu_item)
|
||||
fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
|
||||
if (pkg->description)
|
||||
fprintf(fout, "Description: %s\n", pkg->description);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
r = rename(statusfile, bak_statusfile);
|
||||
if (r == 0) {
|
||||
r = rename(new_statusfile, statusfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_file(const char *fn)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat(fn, &statbuf) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return S_ISREG(statbuf.st_mode);
|
||||
}
|
||||
|
||||
static int dpkg_doconfigure(package_t *pkg)
|
||||
{
|
||||
int r;
|
||||
char postinst[1024];
|
||||
char buf[1024];
|
||||
|
||||
DPRINTF("Configuring %s\n", pkg->package);
|
||||
pkg->status &= status_statusmask;
|
||||
snprintf(postinst, sizeof(postinst), "%s%s.postinst", infodir, pkg->package);
|
||||
|
||||
if (is_file(postinst)) {
|
||||
snprintf(buf, sizeof(buf), "%s configure", postinst);
|
||||
if ((r = do_system(buf)) != 0) {
|
||||
fprintf(stderr, "postinst exited with status %d\n", r);
|
||||
pkg->status |= status_statushalfconfigured;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pkg->status |= status_statusinstalled;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_dounpack(package_t *pkg)
|
||||
{
|
||||
int r = 0, i;
|
||||
char *cwd;
|
||||
FILE *outfp;
|
||||
char *src_file = NULL;
|
||||
char *dst_file = NULL;
|
||||
char *lst_file = NULL;
|
||||
char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
|
||||
"/conffiles", "/md5sums", "/shlibs", "/templates" };
|
||||
char buf[1024], buf2[1024];
|
||||
|
||||
DPRINTF("Unpacking %s\n", pkg->package);
|
||||
|
||||
cwd = getcwd(0, 0);
|
||||
chdir("/");
|
||||
deb_extract(dpkg_deb_extract, "/", pkg->file);
|
||||
|
||||
/* Installs the package scripts into the info directory */
|
||||
for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]); i++) {
|
||||
/* The full path of the current location of the admin file */
|
||||
src_file = xrealloc(src_file, strlen(dpkgcidir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(src_file, dpkgcidir);
|
||||
strcat(src_file, pkg->package);
|
||||
strcat(src_file, adminscripts[i]);
|
||||
|
||||
/* the full path of where we want the file to be copied to */
|
||||
dst_file = xrealloc(dst_file, strlen(infodir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(dst_file, infodir);
|
||||
strcat(dst_file, pkg->package);
|
||||
strcat(dst_file, adminscripts[i]);
|
||||
|
||||
/* copy admin file to permanent home */
|
||||
if (copy_file(src_file, dst_file, TRUE, FALSE, FALSE) < 0) {
|
||||
error_msg_and_die("Cannot copy %s to %s ", buf, buf2);
|
||||
}
|
||||
|
||||
/* create the list file */
|
||||
lst_file = (char *) xmalloc(strlen(infodir) + strlen(pkg->package) + 6);
|
||||
strcpy(lst_file, infodir);
|
||||
strcat(lst_file, pkg->package);
|
||||
strcat(lst_file, ".list");
|
||||
outfp = freopen(lst_file, "w", stdout);
|
||||
deb_extract(dpkg_deb_list, NULL, pkg->file);
|
||||
stdout = freopen(NULL, "w", outfp);
|
||||
|
||||
printf("done\n");
|
||||
getchar();
|
||||
|
||||
fclose(outfp);
|
||||
}
|
||||
|
||||
pkg->status &= status_wantmask;
|
||||
pkg->status |= status_wantinstall;
|
||||
pkg->status &= status_flagmask;
|
||||
pkg->status |= status_flagok;
|
||||
pkg->status &= status_statusmask;
|
||||
|
||||
if (r == 0) {
|
||||
pkg->status |= status_statusunpacked;
|
||||
} else {
|
||||
pkg->status |= status_statushalfinstalled;
|
||||
}
|
||||
chdir(cwd);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and parse the control.tar.gz from the specified package
|
||||
*/
|
||||
static int dpkg_unpackcontrol(package_t *pkg)
|
||||
{
|
||||
char *tmp_name;
|
||||
FILE *file;
|
||||
int length;
|
||||
|
||||
/* clean the temp directory (dpkgcidir) be recreating it */
|
||||
remove_dpkgcidir();
|
||||
if (mkdir(dpkgcidir, S_IRWXU) != 0) {
|
||||
perror("mkdir");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the package name from the file name,
|
||||
* first remove the directories
|
||||
*/
|
||||
if ((tmp_name = strrchr(pkg->file, '/')) == NULL) {
|
||||
tmp_name = pkg->file;
|
||||
} else {
|
||||
tmp_name++;
|
||||
}
|
||||
/* now remove trailing version numbers etc */
|
||||
length = strcspn(tmp_name, "_.");
|
||||
pkg->package = (char *) xmalloc(length + 1);
|
||||
/* store the package name */
|
||||
strncpy(pkg->package, tmp_name, length);
|
||||
|
||||
/* work out the full extraction path */
|
||||
tmp_name = (char *) xmalloc(strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
memset(tmp_name, 0, strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
strcpy(tmp_name, dpkgcidir);
|
||||
strcat(tmp_name, pkg->package);
|
||||
|
||||
/* extract control.tar.gz to the full extraction path */
|
||||
deb_extract(dpkg_deb_control, tmp_name, pkg->file);
|
||||
|
||||
/* parse the extracted control file */
|
||||
strcat(tmp_name, "/control");
|
||||
if ((file = fopen(tmp_name, "r")) == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (control_read(file, pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int dpkg_unpack(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
if (dpkg_unpackcontrol(pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ((r = dpkg_dounpack(pkg)) != 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
status_merge(status, pkgs);
|
||||
remove_dpkgcidir();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_configure(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
void *found;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0 && r == 0; pkg = pkg->next) {
|
||||
found = tfind(pkg, &status, package_compare);
|
||||
|
||||
if (found == 0) {
|
||||
fprintf(stderr, "Trying to configure %s, but it is not installed\n", pkg->package);
|
||||
r = 1;
|
||||
}
|
||||
/* configure the package listed in the status file;
|
||||
* not pkg, as we have info only for the latter
|
||||
*/
|
||||
else {
|
||||
r = dpkg_doconfigure(*(package_t **)found);
|
||||
}
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_install(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p, *ordered = 0;
|
||||
|
||||
/* Stage 1: parse all the control information */
|
||||
for (p = pkgs; p != 0; p = p->next) {
|
||||
if (dpkg_unpackcontrol(p) == EXIT_FAILURE) {
|
||||
perror(p->file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Stage 2: resolve dependencies */
|
||||
#ifdef DODEPENDS
|
||||
ordered = depends_resolve(pkgs, status);
|
||||
#else
|
||||
ordered = pkgs;
|
||||
#endif
|
||||
|
||||
/* Stage 3: install */
|
||||
for (p = ordered; p != 0; p = p->next) {
|
||||
p->status &= status_wantmask;
|
||||
p->status |= status_wantinstall;
|
||||
|
||||
/* for now the flag is always set to ok... this is probably
|
||||
* not what we want
|
||||
*/
|
||||
p->status &= status_flagmask;
|
||||
p->status |= status_flagok;
|
||||
|
||||
DPRINTF("Installing %s\n", p->package);
|
||||
if (dpkg_dounpack(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
if (dpkg_doconfigure(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
}
|
||||
|
||||
if (ordered != 0) {
|
||||
status_merge(status, pkgs);
|
||||
}
|
||||
remove_dpkgcidir();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_remove(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p;
|
||||
|
||||
for (p = pkgs; p != 0; p = p->next)
|
||||
{
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int dpkg_main(int argc, char **argv)
|
||||
{
|
||||
char opt = 0;
|
||||
char *s;
|
||||
package_t *p, *packages = NULL;
|
||||
char *cwd = getcwd(0, 0);
|
||||
void *status = NULL;
|
||||
|
||||
while (*++argv) {
|
||||
if (**argv == '-') {
|
||||
/* Nasty little hack to "parse" long options. */
|
||||
s = *argv;
|
||||
while (*s == '-') {
|
||||
s++;
|
||||
}
|
||||
opt=s[0];
|
||||
} else {
|
||||
p = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
|
||||
if (**argv == '/') {
|
||||
p->file = *argv;
|
||||
} else
|
||||
if (opt != 'c') {
|
||||
p->file = xmalloc(strlen(cwd) + strlen(*argv) + 2);
|
||||
sprintf(p->file, "%s/%s", cwd, *argv);
|
||||
} else {
|
||||
p->package = strdup(*argv);
|
||||
}
|
||||
|
||||
p->next = packages;
|
||||
packages = p;
|
||||
}
|
||||
}
|
||||
|
||||
status = status_read();
|
||||
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
return dpkg_install(packages, status);
|
||||
case 'r':
|
||||
return dpkg_remove(packages, status);
|
||||
case 'u':
|
||||
return dpkg_unpack(packages, status);
|
||||
case 'c':
|
||||
return dpkg_configure(packages, status);
|
||||
default :
|
||||
show_usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Merge this applet into dpkg when dpkg becomes more stable
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
extern ar_headers_t get_ar_headers(int srcFd);
|
||||
extern int tar_unzip_init(int tarFd);
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList, char** excludeList);
|
||||
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename)
|
||||
{
|
||||
char **extract_list = NULL;
|
||||
ar_headers_t *ar_headers = NULL;
|
||||
char ar_filename[15];
|
||||
int extract_flag = FALSE;
|
||||
int list_flag = FALSE;
|
||||
int verbose_flag = FALSE;
|
||||
int extract_to_stdout = FALSE;
|
||||
int srcFd = 0;
|
||||
int status;
|
||||
|
||||
if (dpkg_deb_contents == (dpkg_deb_contents & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
verbose_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_list == (dpkg_deb_list & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_control == (dpkg_deb_control & optflags)) {
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_extract == (dpkg_deb_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_verbose_extract == (dpkg_deb_verbose_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
|
||||
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
srcFd = open(deb_filename, O_RDONLY);
|
||||
|
||||
*ar_headers = get_ar_headers(srcFd);
|
||||
if (ar_headers->next == NULL) {
|
||||
error_msg_and_die("Couldnt find %s in %s", ar_filename, deb_filename);
|
||||
}
|
||||
|
||||
while (ar_headers->next != NULL) {
|
||||
if (strcmp(ar_headers->name, ar_filename) == 0) {
|
||||
break;
|
||||
}
|
||||
ar_headers = ar_headers->next;
|
||||
}
|
||||
lseek(srcFd, ar_headers->offset, SEEK_SET);
|
||||
srcFd = tar_unzip_init(srcFd);
|
||||
if ( dir_name != NULL) {
|
||||
if (is_directory(dir_name, TRUE, NULL)==FALSE) {
|
||||
mkdir(dir_name, 0755);
|
||||
}
|
||||
if (chdir(dir_name)==-1) {
|
||||
error_msg_and_die("Cannot change to dir %s", dir_name);
|
||||
}
|
||||
}
|
||||
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
char *target_dir = NULL;
|
||||
int opt = 0;
|
||||
int optflag = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "cexXl")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
optflag |= dpkg_deb_contents;
|
||||
break;
|
||||
case 'e':
|
||||
optflag |= dpkg_deb_control;
|
||||
break;
|
||||
case 'X':
|
||||
optflag |= dpkg_deb_verbose_extract;
|
||||
break;
|
||||
case 'x':
|
||||
optflag |= dpkg_deb_extract;
|
||||
break;
|
||||
case 'l':
|
||||
optflag |= dpkg_deb_list;
|
||||
break;
|
||||
/* case 'I':
|
||||
optflag |= dpkg_deb_info;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (((optind + 1 ) > argc) || (optflag == 0)) {
|
||||
show_usage();
|
||||
}
|
||||
if ((optflag & dpkg_deb_control) || (optflag & dpkg_deb_extract) || (optflag & dpkg_deb_verbose_extract)) {
|
||||
if ( (optind + 1) == argc ) {
|
||||
target_dir = (char *) xmalloc(7);
|
||||
strcpy(target_dir, "DEBIAN");
|
||||
} else {
|
||||
target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
|
||||
strcpy(target_dir, argv[optind + 1]);
|
||||
}
|
||||
}
|
||||
deb_extract(optflag, target_dir, argv[optind]);
|
||||
/* else if (optflag & dpkg_deb_info) {
|
||||
extract_flag = TRUE;
|
||||
extract_to_stdout = TRUE;
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_list = argv+optind+1;
|
||||
printf("list one is [%s]\n",extract_list[0]);
|
||||
}
|
||||
*/
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+1363
File diff suppressed because it is too large.
Load diff
+1589
-1417
File diff suppressed because it is too large.
Load diff
+1112
-1073
File diff suppressed because it is too large.
Load diff
+52
@@ -0,0 +1,52 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,246 +1,195 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
const char *applet_name;
|
||||
|
||||
static const struct Applet applets[] = {
|
||||
|
||||
#ifdef BB_BUSYBOX //bin
|
||||
{"busybox", busybox_main},
|
||||
#endif
|
||||
#ifdef BB_BLOCK_DEVICE //sbin
|
||||
{"block_device", block_device_main},
|
||||
#endif
|
||||
#ifdef BB_CAT //bin
|
||||
{"cat", cat_main},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP //bin
|
||||
{"chmod", chmod_chown_chgrp_main},
|
||||
{"chown", chmod_chown_chgrp_main},
|
||||
{"chgrp", chmod_chown_chgrp_main},
|
||||
#endif
|
||||
#ifdef BB_CHROOT //sbin
|
||||
{"chroot", chroot_main},
|
||||
#endif
|
||||
#ifdef BB_CLEAR //usr/bin
|
||||
{"clear", clear_main},
|
||||
#endif
|
||||
#ifdef BB_CP //bin
|
||||
{"cp", cp_main},
|
||||
#endif
|
||||
#ifdef BB_DATE //bin
|
||||
{"date", date_main},
|
||||
#endif
|
||||
#ifdef BB_DD //bin
|
||||
{"dd", dd_main},
|
||||
#endif
|
||||
#ifdef BB_DF //bin
|
||||
{"df", df_main},
|
||||
#endif
|
||||
#ifdef BB_DMESG //bin
|
||||
{"dmesg", dmesg_main},
|
||||
#endif
|
||||
#ifdef BB_DUTMP //usr/sbin
|
||||
{"dutmp", dutmp_main},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH //bin
|
||||
{"fdflush", fdflush_main},
|
||||
#endif
|
||||
#ifdef BB_FIND //usr/bin
|
||||
{"find", find_main},
|
||||
#endif
|
||||
#ifdef BB_CHVT //usr/bin
|
||||
{"chvt", chvt_main},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT //usr/bin
|
||||
{"deallocvt", deallocvt_main},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX //sbin
|
||||
{"fsck.minix", fsck_minix_main},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX //sbin
|
||||
{"mkfs.minix", mkfs_minix_main},
|
||||
#endif
|
||||
#ifdef BB_GREP //bin
|
||||
{"grep", grep_main},
|
||||
#endif
|
||||
#ifdef BB_HALT //sbin
|
||||
{"halt", halt_main},
|
||||
#endif
|
||||
#ifdef BB_INIT //sbin
|
||||
{"init", init_main},
|
||||
#endif
|
||||
#ifdef BB_KILL //bin
|
||||
{"kill", kill_main},
|
||||
#endif
|
||||
#ifdef BB_LENGTH //usr/bin
|
||||
{"length", length_main},
|
||||
#endif
|
||||
#ifdef BB_LN //bin
|
||||
{"ln", ln_main},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT //usr/bin
|
||||
{"loadfont", loadfont_main},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP //sbin
|
||||
{"loadkmap", loadkmap_main},
|
||||
#endif
|
||||
#ifdef BB_LS //bin
|
||||
{"ls", ls_main},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS //sbin
|
||||
{"makedevs", makedevs_main},
|
||||
#endif
|
||||
#ifdef BB_MATH //usr/bin
|
||||
{"math", math_main},
|
||||
#endif
|
||||
#ifdef BB_MKDIR //bin
|
||||
{"mkdir", mkdir_main},
|
||||
#endif
|
||||
#ifdef BB_MKNOD //bin
|
||||
{"mknod", mknod_main},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP //sbin
|
||||
{"mkswap", mkswap_main},
|
||||
#endif
|
||||
#ifdef BB_MNC //usr/bin
|
||||
{"mnc", mnc_main},
|
||||
#endif
|
||||
#ifdef BB_MORE //bin
|
||||
{"more", more_main},
|
||||
#endif
|
||||
#ifdef BB_MOUNT //bin
|
||||
{"mount", mount_main},
|
||||
#endif
|
||||
#ifdef BB_MT //bin
|
||||
{"mt", mt_main},
|
||||
#endif
|
||||
#ifdef BB_MV //bin
|
||||
{"mv", mv_main},
|
||||
#endif
|
||||
#ifdef BB_PRINTF //usr/bin
|
||||
{"printf", printf_main},
|
||||
#endif
|
||||
#ifdef BB_PS //bin
|
||||
{"ps", ps_main},
|
||||
#endif
|
||||
#ifdef BB_PWD //bin
|
||||
{"pwd", pwd_main},
|
||||
#endif
|
||||
#ifdef BB_REBOOT //sbin
|
||||
{"reboot", reboot_main},
|
||||
#endif
|
||||
#ifdef BB_RM //bin
|
||||
{"rm", rm_main},
|
||||
#endif
|
||||
#ifdef BB_RMDIR //bin
|
||||
{"rmdir", rmdir_main},
|
||||
#endif
|
||||
#ifdef BB_SFDISK //sbin
|
||||
{"fdisk", sfdisk_main},
|
||||
{"sfdisk", sfdisk_main},
|
||||
#endif
|
||||
#ifdef BB_SED //bin
|
||||
{"sed", sed_main},
|
||||
#endif
|
||||
#ifdef BB_SLEEP //bin
|
||||
{"sleep", sleep_main},
|
||||
#endif
|
||||
#ifdef BB_TAR //bin
|
||||
{"tar", tar_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF //sbin
|
||||
{"swapon", swap_on_off_main},
|
||||
{"swapoff", swap_on_off_main},
|
||||
#endif
|
||||
#ifdef BB_SYNC //bin
|
||||
{"sync", sync_main},
|
||||
#endif
|
||||
#ifdef BB_TOUCH //usr/bin
|
||||
{"touch", touch_main},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE //bin
|
||||
{"true", true_main},
|
||||
{"false", false_main},
|
||||
#endif
|
||||
#ifdef BB_UNAME //bin
|
||||
{"uname", uname_main},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT //bin
|
||||
{"umount", umount_main},
|
||||
#endif
|
||||
#ifdef BB_UPDATE //sbin
|
||||
{"update", update_main},
|
||||
#endif
|
||||
#ifdef BB_ZCAT //bin
|
||||
{"zcat", zcat_main},
|
||||
{"gunzip", zcat_main},
|
||||
#endif
|
||||
#ifdef BB_GZIP //bin
|
||||
{"gzip", gzip_main},
|
||||
#endif
|
||||
{0}
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Where in the filesystem is this busybox?
|
||||
* [return]
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *s = argv[0];
|
||||
char *name = argv[0];
|
||||
const struct Applet *a = applets;
|
||||
const char *s;
|
||||
|
||||
while (*s != '\0') {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
}
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
int status;
|
||||
|
||||
status = ((*(a->main)) (argc, argv));
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(status);
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
exit (busybox_main(argc, argv));
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col=0;
|
||||
argc--;
|
||||
argv++;
|
||||
int col = 0, len, i;
|
||||
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct Applet *a = applets;
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "\nUsage:\t[function] [arguments]...\n");
|
||||
fprintf(stderr, "\tbusybox [function] [arguments]...\n");
|
||||
fprintf(stderr,
|
||||
"\n\tMost people will create a symlink to busybox for each\n"
|
||||
"\tfunction name, and busybox will act like whatever you invoke it as.\n");
|
||||
fprintf(stderr, "\nCurrently defined functions:\n");
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
while (a->name != 0) {
|
||||
col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
|
||||
if (col>60) {
|
||||
fprintf(stderr, ",\n");
|
||||
col=0;
|
||||
}
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
} else {
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > 60 && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* This file is parsed by sed. You MUST use single line comments.
|
||||
* IE //#define BB_BLAH
|
||||
*/
|
||||
|
||||
#define BB_BUSYBOX
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CLEAR
|
||||
#define BB_CP
|
||||
#define BB_DATE
|
||||
#define BB_DD
|
||||
#define BB_DF
|
||||
#define BB_DMESG
|
||||
//#define BB_DUTMP
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_CHVT
|
||||
#define BB_DEALLOCVT
|
||||
#define BB_GREP
|
||||
//#define BB_HALT
|
||||
#define BB_INIT
|
||||
#define BB_KILL
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
#define BB_LS
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MATH
|
||||
#define BB_MKDIR
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
//#define BB_MNC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
//#define BB_MTAB
|
||||
#define BB_MV
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_REGEXP
|
||||
#define BB_REBOOT
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_SFDISK
|
||||
#define BB_SED
|
||||
#define BB_SLEEP
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_TAR
|
||||
#define BB_TOUCH
|
||||
//#define BB_TRUE_FALSE // Supplied by ash
|
||||
#define BB_UMOUNT
|
||||
#define BB_UPDATE
|
||||
#define BB_UNAME
|
||||
#define BB_ZCAT
|
||||
//#define BB_GZIP
|
||||
// Don't turn BB_UTILITY off. It contains support code
|
||||
// that compiles to 0 if everything else if turned off.
|
||||
#define BB_UTILITY
|
||||
@@ -0,0 +1,271 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Busybox main internal header file
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
#ifndef _BB_INTERNAL_H_
|
||||
#define _BB_INTERNAL_H_ 1
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
#include <features.h>
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if ! defined __GLIBC__ && ! defined __UCLIBC__
|
||||
/* libc5 doesn't define socklen_t */
|
||||
typedef unsigned int socklen_t;
|
||||
#endif
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
#define SKIP ((int) 2)
|
||||
|
||||
/* for mtab.c */
|
||||
#define MTAB_GETMOUNTPT '1'
|
||||
#define MTAB_GETDEVICE '2'
|
||||
|
||||
#define BUF_SIZE 8192
|
||||
#define EXPAND_ALLOC 1024
|
||||
|
||||
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
|
||||
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
/* Macros for min/max. */
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
enum Location {
|
||||
_BB_DIR_ROOT = 0,
|
||||
_BB_DIR_BIN,
|
||||
_BB_DIR_SBIN,
|
||||
_BB_DIR_USR_BIN,
|
||||
_BB_DIR_USR_SBIN
|
||||
};
|
||||
|
||||
struct BB_applet {
|
||||
const char* name;
|
||||
int (*main)(int argc, char** argv);
|
||||
enum Location location;
|
||||
};
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
|
||||
/* Automagically pull in all the applet function prototypes and
|
||||
* applet usage strings. These are all of the form:
|
||||
* extern int foo_main(int argc, char **argv);
|
||||
* extern const char foo_usage[];
|
||||
* These are all autogenerated from the set of currently defined applets.
|
||||
*/
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
extern const char *applet_name;
|
||||
|
||||
extern void show_usage(void) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...);
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
int isDevice(const char *name);
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
|
||||
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
|
||||
void reset_ino_dev_hashtable(void);
|
||||
|
||||
int copy_file(const char *srcName, const char *destName,
|
||||
int setModes, int followLinks, int forceFlag);
|
||||
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
|
||||
char *buildName(const char *dirName, const char *fileName);
|
||||
int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
ssize_t safe_read(int fd, void *buf, size_t count);
|
||||
int full_write(int fd, const char *buf, int len);
|
||||
int full_read(int fd, char *buf, int len);
|
||||
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
void* userData);
|
||||
|
||||
extern int create_path (const char *name, int mode);
|
||||
extern int parse_mode( const char* s, mode_t* theMode);
|
||||
|
||||
extern int get_kernel_revision(void);
|
||||
|
||||
extern int get_console_fd(char* tty_name);
|
||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||
extern void write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags);
|
||||
extern void erase_mtab(const char * name);
|
||||
extern void mtab_read(void);
|
||||
extern char *mtab_first(void **iter);
|
||||
extern char *mtab_next(void **iter);
|
||||
extern char *mtab_getinfo(const char *match, const char which);
|
||||
extern int check_wildcard_match(const char* text, const char* pattern);
|
||||
extern long atoi_w_units (const char *cp);
|
||||
extern pid_t* find_pid_by_name( char* pidName);
|
||||
extern int find_real_root_device_name(char* name);
|
||||
extern char *get_line_from_file(FILE *file);
|
||||
extern void print_file(FILE *file);
|
||||
extern int print_file_by_name(char *filename);
|
||||
extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
extern void chomp(char *s);
|
||||
extern void trim(char *s);
|
||||
extern struct BB_applet *find_applet_by_name(const char *name);
|
||||
void run_applet_by_name(const char *name, int argc, char **argv);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
extern void *xrealloc(void *old, size_t size);
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
extern char *xstrdup (const char *s);
|
||||
#endif
|
||||
extern char *xstrndup (const char *s, int n);
|
||||
extern char * safe_strncpy(char *dst, const char *src, size_t size);
|
||||
|
||||
struct suffix_mult {
|
||||
char *suffix;
|
||||
int mult;
|
||||
};
|
||||
|
||||
extern unsigned long parse_number(const char *numstr,
|
||||
const struct suffix_mult *suffixes);
|
||||
|
||||
|
||||
/* These parse entries in /etc/passwd and /etc/group. This is desirable
|
||||
* for BusyBox since we want to avoid using the glibc NSS stuff, which
|
||||
* increases target size and is often not needed embedded systems. */
|
||||
extern long my_getpwnam(const char *name);
|
||||
extern long my_getgrnam(const char *name);
|
||||
extern void my_getpwuid(char *name, long uid);
|
||||
extern void my_getgrgid(char *group, long gid);
|
||||
extern long my_getpwnamegid(const char *name);
|
||||
|
||||
extern int device_open(char *device, int mode);
|
||||
|
||||
#if defined BB_FEATURE_MOUNT_LOOP
|
||||
extern int del_loop(const char *device);
|
||||
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
|
||||
extern char *find_unused_loop_device (void);
|
||||
#endif
|
||||
|
||||
|
||||
#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
|
||||
extern int vdprintf(int d, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
#if defined BB_NFSMOUNT
|
||||
int nfsmount(const char *spec, const char *node, int *flags,
|
||||
char **extra_opts, char **mount_opts, int running_bg);
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
#if defined(BB_KLOGD) || defined(BB_LOGGER)
|
||||
void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg);
|
||||
void syslog_msg(int facility, int pri, const char *msg);
|
||||
#endif
|
||||
|
||||
/* Include our own copy of struct sysinfo to avoid binary compatability
|
||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
|
||||
};
|
||||
extern int sysinfo (struct sysinfo* info);
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
const char *make_human_readable_str(unsigned long val, unsigned long hr);
|
||||
#endif
|
||||
enum {
|
||||
KILOBYTE = 1024,
|
||||
MEGABYTE = (KILOBYTE*1024),
|
||||
GIGABYTE = (MEGABYTE*1024)
|
||||
};
|
||||
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
|
||||
#else
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
|
||||
#endif
|
||||
|
||||
#if defined(BB_FEATURE_RM_INTERACTIVE) && defined(BB_RM)
|
||||
int ask_confirmation(void);
|
||||
#endif
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
+20
-11
@@ -1,15 +1,24 @@
|
||||
#!/bin/sh
|
||||
#Make busybox links list file
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="busybox.c"
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n 's/^#ifdef \<'$def'\>.*\/\/\(.*$\)/\/\1\//gp' $MF`
|
||||
j=`sed -n '/^#ifdef '$def'.*/,/^#endif/{ s/.*\"\(.*\)\".*/\1/gp; }' $MF`
|
||||
for k in $j; do
|
||||
echo $i$k
|
||||
done
|
||||
done
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
+14
-2
@@ -1,4 +1,16 @@
|
||||
#!/bin/sh
|
||||
sed -n '/^#define/{s/.*BB_//; s/$/.o/p; }' busybox.def.h | \
|
||||
tr [:upper:] [:lower:]
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
+11
-18
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.32
|
||||
Version: 0.50
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
@@ -7,33 +7,26 @@ Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: busybox-0.32.tar.gz
|
||||
Source: %{Name}-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||
provides a pretty complete POSIX environment in a very small package.
|
||||
Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
|
||||
an editor such as "elvis-tiny" or "ae", and you have a full system. This
|
||||
is makes an excellent environment for a "rescue" disk or any small or
|
||||
embedded system.
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small
|
||||
or emdedded system. The utilities in BusyBox generally have fewer options then
|
||||
their full featured GNU cousins; however, the options that are provided behave
|
||||
very much like their GNU counterparts.
|
||||
|
||||
%Prep
|
||||
%setup -q -n busybox
|
||||
%setup -q -n %{Name}-%{Version}
|
||||
|
||||
%Build
|
||||
make
|
||||
|
||||
%Install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT/bin
|
||||
h=`cat busybox.links`
|
||||
|
||||
for i in $h ; do
|
||||
mkdir -p $RPM_BUILD_ROOT/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `
|
||||
(cd $RPM_BUILD_ROOT/bin ; ln -s busybox `echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' ` );
|
||||
done
|
||||
rm -f $RPM_BUILD_ROOT/bin/busybox
|
||||
install -m 755 busybox $RPM_BUILD_ROOT/bin/busybox
|
||||
make PREFIX=$RPM_BUILD_ROOT install
|
||||
|
||||
%Clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __BUSYBOX_FUNCTIONS_H__
|
||||
#define __BUSYBOX_FUNCTIONS_H__
|
||||
|
||||
int
|
||||
mkswap(char *device_name, int pages, int check);
|
||||
/* pages = 0 for autodetection */
|
||||
|
||||
int
|
||||
fdflush(char *filename);
|
||||
|
||||
#endif /* __BUSYBOX_FUNCTIONS_H__ */
|
||||
@@ -1,7 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,43 +21,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static void print_file( FILE *file)
|
||||
{
|
||||
int c;
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc==1) {
|
||||
print_file( stdin);
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
if ( **(argv+1) == '-' ) {
|
||||
usage ("cat [file ...]\n");
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc-- > 0) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
}
|
||||
print_file( file);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit(TRUE);
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+115
-104
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,134 +23,144 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_option
|
||||
#define bb_need_too_few_args
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
static uid_t uid=-1;
|
||||
static gid_t gid=-1;
|
||||
|
||||
static long uid = -1;
|
||||
static long gid = -1;
|
||||
static int whichApp;
|
||||
static char* invocationName=NULL;
|
||||
static mode_t mode=0644;
|
||||
static char *theMode = NULL;
|
||||
|
||||
|
||||
#define CHGRP_APP 1
|
||||
#define CHOWN_APP 2
|
||||
#define CHMOD_APP 3
|
||||
|
||||
static const char chgrp_usage[] = "[OPTION]... GROUP FILE...\n"
|
||||
"Change the group membership of each FILE to GROUP.\n"
|
||||
"\n\tOptions:\n" "\t-R\tchange files and directories recursively\n";
|
||||
static const char chown_usage[] = "[OPTION]... OWNER[.[GROUP] FILE...\n"
|
||||
"Change the owner and/or group of each FILE to OWNER and/or GROUP.\n"
|
||||
"\n\tOptions:\n" "\t-R\tchange files and directories recursively\n";
|
||||
static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n"
|
||||
"Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
|
||||
"one or more of the letters rwxst.\n\n"
|
||||
"\t-R\tchange files and directories recursively.\n";
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
switch (whichApp) {
|
||||
switch (whichApp) {
|
||||
case CHGRP_APP:
|
||||
case CHOWN_APP:
|
||||
if (chown(fileName, (whichApp==CHOWN_APP)? uid : statbuf->st_uid,
|
||||
(gid==-1)? statbuf->st_gid : gid) == 0) {
|
||||
return( TRUE);
|
||||
}
|
||||
break;
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
if (lchown
|
||||
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
|
||||
(gid == -1) ? statbuf->st_gid : gid) == 0)
|
||||
#else
|
||||
if (chown
|
||||
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
|
||||
(gid == -1) ? statbuf->st_gid : gid) == 0)
|
||||
#endif
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
break;
|
||||
case CHMOD_APP:
|
||||
if (chmod(fileName, mode) == 0)
|
||||
return( TRUE);
|
||||
break;
|
||||
}
|
||||
perror(fileName);
|
||||
return( FALSE);
|
||||
/* Parse the specified modes */
|
||||
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s", theMode);
|
||||
}
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
break;
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int recursiveFlag=FALSE;
|
||||
char *groupName;
|
||||
int stopIt = FALSE;
|
||||
int recursiveFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
|
||||
whichApp = (strcmp(*argv, "chown")==0)? CHOWN_APP : (strcmp(*argv, "chmod")==0)? CHMOD_APP : CHGRP_APP;
|
||||
whichApp = (applet_name[2]=='o')? /* chown */
|
||||
CHOWN_APP : (applet_name[2]=='m')? /* chmod */
|
||||
CHMOD_APP : CHGRP_APP;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s %s", *argv,
|
||||
(whichApp==TRUE)? chown_usage : chgrp_usage);
|
||||
exit( FALSE);
|
||||
}
|
||||
invocationName=*argv;
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv)) switch (**argv) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown option: %c\n", **argv);
|
||||
exit( FALSE);
|
||||
}
|
||||
argc--;
|
||||
if (argc < 2)
|
||||
show_usage();
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ( whichApp == CHMOD_APP ) {
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if ( parse_mode(*argv, &mode) == FALSE ) {
|
||||
fprintf(stderr, "%s: Unknown mode: %s\n", invocationName, *argv);
|
||||
exit( FALSE);
|
||||
}
|
||||
} else {
|
||||
|
||||
/* Find the selected group */
|
||||
if ( whichApp==CHGRP_APP ) {
|
||||
groupName = *argv;
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
/* Parse options */
|
||||
while (--argc >= 0 && *argv && (**argv == '-')) {
|
||||
while (stopIt==FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
theMode=*argv-1;
|
||||
stopIt = TRUE;
|
||||
}
|
||||
}
|
||||
if (stopIt==TRUE)
|
||||
break;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc == 0 || *argv == NULL) {
|
||||
error_msg(too_few_args);
|
||||
}
|
||||
|
||||
if (whichApp == CHMOD_APP) {
|
||||
if (theMode==NULL)
|
||||
theMode = *argv;
|
||||
} else {
|
||||
groupName = strchr(*argv, '.');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
} else
|
||||
gid = -1;
|
||||
|
||||
/* Find the selected group */
|
||||
if (whichApp == CHGRP_APP) {
|
||||
groupName = *argv;
|
||||
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else {
|
||||
groupName = strchr(*argv, '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(*argv, ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else
|
||||
gid = -1;
|
||||
}
|
||||
|
||||
|
||||
/* Find the selected user (if appropriate) */
|
||||
if (whichApp == CHOWN_APP) {
|
||||
uid = strtoul(*argv, &p, 10); /* if numeric ... */
|
||||
if (*argv == p)
|
||||
uid = my_getpwnam(*argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Find the selected user (if appropriate) */
|
||||
if (whichApp==CHOWN_APP) {
|
||||
uid = my_getpwnam(*argv);
|
||||
if (uid == -1) {
|
||||
fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv);
|
||||
exit( FALSE);
|
||||
}
|
||||
/* Ok, ready to do the deed now */
|
||||
if (argc < 1) {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "%s: too few arguments", invocationName);
|
||||
exit( FALSE);
|
||||
}
|
||||
while (argc-- > 1) {
|
||||
if (recursiveAction( *(++argv), recursiveFlag, TRUE, FALSE, fileAction, fileAction)==FALSE)
|
||||
exit( FALSE);
|
||||
}
|
||||
exit(TRUE);
|
||||
while (argc-- > 1) {
|
||||
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bad_group:
|
||||
fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,46 +22,51 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
|
||||
"Run COMMAND with root directory set to NEWROOT.\n";
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
if ( (argc < 2) || (**(argv+1) == '-') ) {
|
||||
usage( chroot_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot (*argv) || (chdir ("/"))) {
|
||||
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
fprintf(stderr, "command: %s\n", *argv);
|
||||
execvp (*argv, argv);
|
||||
}
|
||||
else {
|
||||
char *prog;
|
||||
prog = getenv ("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp (prog, prog, NULL);
|
||||
}
|
||||
fprintf(stderr, "chroot: cannot execute %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
exit( FALSE);
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,36 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* chvt.c - aeb - 940227 - Change virtual terminal
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int getfd(void);
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int
|
||||
chvt_main(int argc, char** argv)
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
int fd, num;
|
||||
|
||||
if ( ( argc != 2) || (**(argv+1) == '-' ) ) {
|
||||
usage ("chvt </dev/ttyN>\n");
|
||||
}
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd,VT_ACTIVATE,num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (ioctl(fd,VT_WAITACTIVE,num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
}
|
||||
exit( TRUE);
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,13 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int
|
||||
clear_main(int argc, char** argv)
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
exit( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
#ifdef BB_FEATURE_COMMAND_EDITING
|
||||
#include <stddef.h>
|
||||
#include "busybox.h"
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
|
||||
#endif /* BB_FEATURE_COMMAND_EDITING */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -0,0 +1,66 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
show_usage();
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+29
-22
@@ -1,36 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* chvt.c - aeb - 940227 - Change virtual terminal
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int getfd(void);
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int
|
||||
chvt_main(int argc, char** argv)
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
int fd, num;
|
||||
|
||||
if ( ( argc != 2) || (**(argv+1) == '-' ) ) {
|
||||
usage ("chvt </dev/ttyN>\n");
|
||||
}
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd,VT_ACTIVATE,num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (ioctl(fd,VT_WAITACTIVE,num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
}
|
||||
exit( TRUE);
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,13 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int
|
||||
clear_main(int argc, char** argv)
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
exit( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+28
-33
@@ -1,48 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int getfd(void);
|
||||
char *progname;
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int
|
||||
deallocvt_main(int argc, char *argv[]) {
|
||||
int fd, num, i;
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
if (argc < 1) /* unlikely */
|
||||
exit(1);
|
||||
progname = argv[0];
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd,VT_DISALLOCATE,0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
exit(1);
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
error_msg("0: illegal VT number");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
}
|
||||
} else
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
|
||||
else if (num == 1)
|
||||
fprintf(stderr, "%s: VT 1 cannot be deallocated\n", progname);
|
||||
else
|
||||
if (ioctl(fd,VT_DISALLOCATE,num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
fprintf(stderr, "%s: could not deallocate console %d\n",
|
||||
progname, num);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dumpkmap implementation for busybox
|
||||
*
|
||||
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
write(1, magic, 7);
|
||||
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
|
||||
flags[0]=1;
|
||||
flags[1]=1;
|
||||
flags[2]=1;
|
||||
flags[4]=1;
|
||||
flags[5]=1;
|
||||
flags[6]=1;
|
||||
flags[8]=1;
|
||||
flags[9]=1;
|
||||
flags[10]=1;
|
||||
flags[12]=1;
|
||||
|
||||
/* dump flags */
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Derived from
|
||||
* mapscrn.c - version 0.92
|
||||
*
|
||||
* Was taken from console-tools and adapted by
|
||||
* Peter Novodvorsky <petya@logic.ru>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/kd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
static long int ctoi(unsigned char *s, int *is_unicode);
|
||||
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
|
||||
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
|
||||
unicode utf8_to_ucs2(char *buf);
|
||||
int screen_map_load(int fd, FILE * fp);
|
||||
|
||||
int loadacm_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int screen_map_load(int fd, FILE * fp)
|
||||
{
|
||||
struct stat stbuf;
|
||||
unicode wbuf[E_TABSZ];
|
||||
unsigned char buf[E_TABSZ];
|
||||
int parse_failed = 0;
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
(parse_failed =
|
||||
(-1 == uni_screen_map_read_ascii(fp, wbuf, &is_unicode)))
|
||||
|| (S_ISREG(stbuf.st_mode) && (stbuf.st_size == (sizeof(unicode) * E_TABSZ)))) { /* test for binary UTF map by size */
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
else
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if it was effectively a 16-bit ASCII, OK, else try to read as 8-bit map */
|
||||
/* same if it was binary, ie. if parse_failed */
|
||||
if (parse_failed || is_unicode) {
|
||||
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
|
||||
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
exit(1);
|
||||
else
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
if (!(parse_failed = (-1 == old_screen_map_read_ascii(fp, buf))) ||
|
||||
(S_ISREG(stbuf.st_mode) && (stbuf.st_size == E_TABSZ))) { /* test for binary old 8-bit map by size */
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
error_msg_and_die("fseek() returned ESPIPE !");
|
||||
else
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
error_msg("Error parsing symbolic map");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* - reads `fp' as a 16-bit ASCII SFM file.
|
||||
* - returns -1 on error.
|
||||
* - returns it in `unicode' in an E_TABSZ-elements array.
|
||||
* - sets `*is_unicode' flagiff there were any non-8-bit
|
||||
* (ie. real 16-bit) mapping.
|
||||
*
|
||||
* FIXME: ignores everything after second word
|
||||
*/
|
||||
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
{
|
||||
char buffer[256]; /* line buffer reading file */
|
||||
char *p, *q; /* 1st + 2nd words in line */
|
||||
int in, on; /* the same, as numbers */
|
||||
int tmp_is_unicode; /* tmp for is_unicode calculation */
|
||||
int i; /* loop index - result holder */
|
||||
int ret_code = 0; /* return code */
|
||||
sigset_t sigset, old_sigset;
|
||||
|
||||
assert(is_unicode);
|
||||
|
||||
*is_unicode = 0;
|
||||
|
||||
/* first 128 codes defaults to ASCII */
|
||||
for (i = 0; i < 128; i++)
|
||||
buf[i] = i;
|
||||
/* remaining defaults to replacement char (usually E_TABSZ = 256) */
|
||||
for (; i < E_TABSZ; i++)
|
||||
buf[i] = 0xfffd;
|
||||
|
||||
/* block SIGCHLD */
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
|
||||
|
||||
do {
|
||||
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
|
||||
if (feof(fp))
|
||||
break;
|
||||
else
|
||||
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
p = strtok(buffer, " \t\n");
|
||||
|
||||
/* skip empty lines and comments */
|
||||
if (!p || *p == '#')
|
||||
continue;
|
||||
|
||||
/* get unicode mapping */
|
||||
q = strtok(NULL, " \t\n");
|
||||
if (q) {
|
||||
in = ctoi(p, NULL);
|
||||
if (in < 0 || in > 255) {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
on = ctoi(q, &tmp_is_unicode);
|
||||
if (in < 0 && on > 65535) {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
*is_unicode |= tmp_is_unicode;
|
||||
buf[in] = on;
|
||||
} else {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (1); /* terminated by break on feof() */
|
||||
|
||||
/* restore sig mask */
|
||||
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
|
||||
{
|
||||
char buffer[256];
|
||||
int in, on;
|
||||
char *p, *q;
|
||||
|
||||
for (in = 0; in < 256; in++)
|
||||
buf[in] = in;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer) - 1, fp)) {
|
||||
p = strtok(buffer, " \t\n");
|
||||
|
||||
if (!p || *p == '#')
|
||||
continue;
|
||||
|
||||
q = strtok(NULL, " \t\n#");
|
||||
if (q) {
|
||||
in = ctoi(p, NULL);
|
||||
if (in < 0 || in > 255)
|
||||
return -1;
|
||||
|
||||
on = ctoi(q, NULL);
|
||||
if (in < 0 && on > 255)
|
||||
return -1;
|
||||
|
||||
buf[in] = on;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* - converts a string into an int.
|
||||
* - supports dec and hex bytes, hex UCS2, single-quoted byte and UTF8 chars.
|
||||
* - returns the converted value
|
||||
* - if `is_unicode != NULL', use it to tell whether it was unicode
|
||||
*
|
||||
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
|
||||
*/
|
||||
long int ctoi(unsigned char *s, int *is_unicode)
|
||||
{
|
||||
int i;
|
||||
size_t ls;
|
||||
|
||||
ls = strlen(s);
|
||||
if (is_unicode)
|
||||
*is_unicode = 0;
|
||||
|
||||
/* hex-specified UCS2 */
|
||||
if ((strncmp(s, "U+", 2) == 0) &&
|
||||
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2)) {
|
||||
sscanf(s + 2, "%x", &i);
|
||||
if (is_unicode)
|
||||
*is_unicode = 1;
|
||||
}
|
||||
|
||||
/* hex-specified byte */
|
||||
else if ((ls <= 4) && (strncmp(s, "0x", 2) == 0) &&
|
||||
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2))
|
||||
sscanf(s + 2, "%x", &i);
|
||||
|
||||
/* oct-specified number (byte) */
|
||||
else if ((*s == '0') && (strspn(s, "01234567") == ls))
|
||||
sscanf(s, "%o", &i);
|
||||
|
||||
/* dec-specified number (byte) */
|
||||
else if (strspn(s, "0123456789") == ls)
|
||||
sscanf(s, "%d", &i);
|
||||
|
||||
/* single-byte quoted char */
|
||||
else if ((strlen(s) == 3) && (s[0] == '\'') && (s[2] == '\''))
|
||||
i = s[1];
|
||||
|
||||
/* multi-byte UTF8 quoted char */
|
||||
else if ((s[0] == '\'') && (s[ls - 1] == '\'')) {
|
||||
s[ls - 1] = 0; /* ensure we'll not "parse UTF too far" */
|
||||
i = utf8_to_ucs2(s + 1);
|
||||
if (is_unicode)
|
||||
*is_unicode = 1;
|
||||
} else
|
||||
return (-1);
|
||||
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
void saveoldmap(int fd, char *omfil)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[E_TABSZ];
|
||||
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
unicode xbuf[E_TABSZ];
|
||||
int is_old_map = 0;
|
||||
|
||||
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
|
||||
perror_msg("GIO_UNISCRNMAP ioctl error");
|
||||
#endif
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("GIO_SCRNMAP ioctl error");
|
||||
else
|
||||
is_old_map = 1;
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
}
|
||||
#endif
|
||||
|
||||
fp = xfopen(omfil, "w");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
if (is_old_map) {
|
||||
#endif
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
}
|
||||
#endif
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
unicode utf8_to_ucs2(char *buf)
|
||||
{
|
||||
int utf_count = 0;
|
||||
long utf_char = 0;
|
||||
unicode tc = 0;
|
||||
unsigned char c;
|
||||
|
||||
do {
|
||||
c = *buf;
|
||||
buf++;
|
||||
|
||||
/* if byte should be part of multi-byte sequence */
|
||||
if (c & 0x80) {
|
||||
/* if we have already started to parse a UTF8 sequence */
|
||||
if (utf_count > 0 && (c & 0xc0) == 0x80) {
|
||||
utf_char = (utf_char << 6) | (c & 0x3f);
|
||||
utf_count--;
|
||||
if (utf_count == 0)
|
||||
tc = utf_char;
|
||||
else
|
||||
continue;
|
||||
} else { /* Possibly 1st char of a UTF8 sequence */
|
||||
|
||||
if ((c & 0xe0) == 0xc0) {
|
||||
utf_count = 1;
|
||||
utf_char = (c & 0x1f);
|
||||
} else if ((c & 0xf0) == 0xe0) {
|
||||
utf_count = 2;
|
||||
utf_char = (c & 0x0f);
|
||||
} else if ((c & 0xf8) == 0xf0) {
|
||||
utf_count = 3;
|
||||
utf_char = (c & 0x07);
|
||||
} else if ((c & 0xfc) == 0xf8) {
|
||||
utf_count = 4;
|
||||
utf_char = (c & 0x03);
|
||||
} else if ((c & 0xfe) == 0xfc) {
|
||||
utf_count = 5;
|
||||
utf_char = (c & 0x01);
|
||||
} else
|
||||
utf_count = 0;
|
||||
continue;
|
||||
}
|
||||
} else { /* not part of multi-byte sequence - treat as ASCII
|
||||
* this makes incomplete sequences to be ignored
|
||||
*/
|
||||
tc = c;
|
||||
utf_count = 0;
|
||||
}
|
||||
}
|
||||
while (utf_count);
|
||||
|
||||
return tc;
|
||||
}
|
||||
+102
-127
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* loadfont.c - Eugene Crosser & Andries Brouwer
|
||||
*
|
||||
@@ -6,7 +7,6 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -14,88 +14,79 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define PSF_MAGIC1 0x36
|
||||
#define PSF_MAGIC2 0x04
|
||||
static const int PSF_MAGIC1 = 0x36;
|
||||
static const int PSF_MAGIC2 = 0x04;
|
||||
|
||||
#define PSF_MODE512 0x01
|
||||
#define PSF_MODEHASTAB 0x02
|
||||
#define PSF_MAXMODE 0x03
|
||||
#define PSF_SEPARATOR 0xFFFF
|
||||
static const int PSF_MODE512 = 0x01;
|
||||
static const int PSF_MODEHASTAB = 0x02;
|
||||
static const int PSF_MAXMODE = 0x03;
|
||||
static const int PSF_SEPARATOR = 0xFFFF;
|
||||
|
||||
static const char loadfont_usage[] = "loadfont\n"
|
||||
"\n"
|
||||
"\tLoad a console font from standard input.\n"
|
||||
"\n";
|
||||
|
||||
struct psf_header
|
||||
{
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
};
|
||||
|
||||
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
|
||||
|
||||
static void loadnewfont(int fd);
|
||||
|
||||
extern int
|
||||
loadfont_main(int argc, char **argv)
|
||||
extern int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
loadnewfont(fd);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
do_loadfont(int fd, char *inbuf, int unit, int fontsize) {
|
||||
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
{
|
||||
char buf[16384];
|
||||
int i;
|
||||
|
||||
memset(buf,0,sizeof(buf));
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32) {
|
||||
fprintf(stderr, "Bad character size %d\n", unit);
|
||||
exit(1);
|
||||
}
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf+(32*i), inbuf+(unit*i), unit);
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
|
||||
#if defined( PIO_FONTX ) && !defined( __sparc__ )
|
||||
{
|
||||
struct consolefontdesc cfd;
|
||||
struct consolefontdesc cfd;
|
||||
|
||||
cfd.charcount = fontsize;
|
||||
cfd.charheight = unit;
|
||||
cfd.chardata = buf;
|
||||
cfd.charcount = fontsize;
|
||||
cfd.charheight = unit;
|
||||
cfd.chardata = buf;
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf)) {
|
||||
perror("PIO_FONT ioctl error");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
perror_msg_and_die("PIO_FONT ioctl error");
|
||||
}
|
||||
|
||||
static void
|
||||
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) {
|
||||
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
{
|
||||
struct unimapinit advice;
|
||||
struct unimapdesc ud;
|
||||
struct unipair *up;
|
||||
@@ -103,23 +94,20 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) {
|
||||
int glyph;
|
||||
u_short unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
|
||||
if (!up) {
|
||||
fprintf(stderr, "Out of memory?\n");
|
||||
exit(1);
|
||||
}
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
|
||||
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF_SEPARATOR)
|
||||
break;
|
||||
up[ct].unicode = unicode;
|
||||
up[ct].fontpos = glyph;
|
||||
ct++;
|
||||
}
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF_SEPARATOR)
|
||||
break;
|
||||
up[ct].unicode = unicode;
|
||||
up[ct].fontpos = glyph;
|
||||
ct++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
|
||||
@@ -128,34 +116,32 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) {
|
||||
advice.advised_hashsize = 0;
|
||||
advice.advised_hashstep = 0;
|
||||
advice.advised_hashlevel = 0;
|
||||
if(ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
|
||||
fprintf(stderr, "No Unicode mapping table loaded.\n");
|
||||
} else
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
error_msg("It seems this kernel is older than 1.1.92");
|
||||
error_msg_and_die("No Unicode mapping table loaded.");
|
||||
} else
|
||||
#endif
|
||||
perror("PIO_UNIMAPCLR");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
}
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
if(ioctl(fd, PIO_UNIMAP, &ud)) {
|
||||
if (ioctl(fd, PIO_UNIMAP, &ud)) {
|
||||
#if 0
|
||||
if (errno == ENOMEM) {
|
||||
/* change advice parameters */
|
||||
}
|
||||
if (errno == ENOMEM) {
|
||||
/* change advice parameters */
|
||||
}
|
||||
#endif
|
||||
perror("PIO_UNIMAP");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
loadnewfont(int fd) {
|
||||
static void loadnewfont(int fd)
|
||||
{
|
||||
int unit;
|
||||
char inbuf[32768]; /* primitive */
|
||||
int inputlth, offset;
|
||||
char inbuf[32768]; /* primitive */
|
||||
unsigned int inputlth, offset;
|
||||
|
||||
/*
|
||||
* We used to look at the length of the input file
|
||||
@@ -163,72 +149,61 @@ loadnewfont(int fd) {
|
||||
* just read the entire file.
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin)) {
|
||||
perror("Error reading input font");
|
||||
exit(1);
|
||||
}
|
||||
if (ferror(stdin))
|
||||
perror_msg_and_die("Error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin)) {
|
||||
perror("Font too large");
|
||||
exit(1);
|
||||
}
|
||||
if (!feof(stdin))
|
||||
perror_msg_and_die("Font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
struct psf_header psfhdr;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
int head0, head;
|
||||
struct psf_header psfhdr;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
unsigned int head0, head;
|
||||
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
|
||||
psfhdr = * (struct psf_header *) &inbuf[0];
|
||||
psfhdr = *(struct psf_header *) &inbuf[0];
|
||||
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE) {
|
||||
fprintf(stderr, "Unsupported psf file mode\n");
|
||||
exit(1);
|
||||
}
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256) {
|
||||
fprintf(stderr, "Only fontsize 256 supported\n");
|
||||
exit(1);
|
||||
}
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
head = head0 + fontsize*unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth)) {
|
||||
fprintf(stderr, "Input file: bad length\n");
|
||||
exit(1);
|
||||
}
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth-head, fontsize);
|
||||
return;
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
return;
|
||||
}
|
||||
no_psf:
|
||||
no_psf:
|
||||
|
||||
/* file with three code pages? */
|
||||
if (inputlth == 9780) {
|
||||
offset = 40;
|
||||
unit = 16;
|
||||
offset = 40;
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377) {
|
||||
fprintf(stderr, "Bad input file size\n");
|
||||
exit(1);
|
||||
}
|
||||
offset = 0;
|
||||
unit = inputlth/256;
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
do_loadfont(fd, inbuf+offset, unit, 256);
|
||||
do_loadfont(fd, inbuf + offset, unit, 256);
|
||||
}
|
||||
+54
-54
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini loadkmap implementation for busybox
|
||||
*
|
||||
@@ -19,71 +20,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
static const char loadkmap_usage[] = "loadkmap\n"
|
||||
"\n"
|
||||
"\tLoad a binary keyboard translation table from standard input.\n"
|
||||
"\n";
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int
|
||||
loadkmap_main(int argc, char * * argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i,j,fd,readsz,pos,ibuffsz=NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS],magic[]="bkeymap",buff[7];
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
read(0,buff,7);
|
||||
if (0 != strncmp(buff,magic,7)) {
|
||||
fprintf(stderr, "This is not a valid binary keymap.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( MAX_NR_KEYMAPS != read(0,flags,MAX_NR_KEYMAPS) ) {
|
||||
fprintf(stderr, "Error reading keymap flags: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
|
||||
ibuff=(u_short *) malloc(ibuffsz);
|
||||
if (!ibuff) {
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
return 1;
|
||||
}
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.");
|
||||
|
||||
for(i=0; i<MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i]==1){
|
||||
pos=0;
|
||||
while (pos < ibuffsz) {
|
||||
if ( (readsz = read(0,(char *)ibuff+pos,ibuffsz-pos)) < 0 ) {
|
||||
fprintf(stderr, "Error reading keymap: %s\n",
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
pos += readsz;
|
||||
}
|
||||
for(j=0; j<NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
ibuff = (u_short *) xmalloc(ibuffsz);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
pos = 0;
|
||||
while (pos < ibuffsz) {
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
|
||||
perror_msg_and_die("Error reading keymap");
|
||||
pos += readsz;
|
||||
}
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close (fd);
|
||||
return 0;
|
||||
/* Don't bother to close files. Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* close(fd); */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033c");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* setkeycodes
|
||||
*
|
||||
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
|
||||
*
|
||||
* Adjusted for BusyBox by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
{
|
||||
char *ep;
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+26
-35
@@ -1,7 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,43 +21,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static void print_file( FILE *file)
|
||||
{
|
||||
int c;
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc==1) {
|
||||
print_file( stdin);
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
if ( **(argv+1) == '-' ) {
|
||||
usage ("cat [file ...]\n");
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc-- > 0) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
}
|
||||
print_file( file);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit(TRUE);
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+41
-35
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,46 +22,51 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
|
||||
"Run COMMAND with root directory set to NEWROOT.\n";
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
if ( (argc < 2) || (**(argv+1) == '-') ) {
|
||||
usage( chroot_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot (*argv) || (chdir ("/"))) {
|
||||
fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
fprintf(stderr, "command: %s\n", *argv);
|
||||
execvp (*argv, argv);
|
||||
}
|
||||
else {
|
||||
char *prog;
|
||||
prog = getenv ("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp (prog, prog, NULL);
|
||||
}
|
||||
fprintf(stderr, "chroot: cannot execute %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
exit( FALSE);
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,66 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
show_usage();
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Mini cp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
|
||||
static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n"
|
||||
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
|
||||
"Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
|
||||
"\n"
|
||||
"\t-a\tsame as -dpR\n"
|
||||
"\t-d\tpreserve links\n"
|
||||
"\t-p\tpreserve file attributes if possable\n"
|
||||
"\t-R\tcopy directories recursively\n";
|
||||
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int followLinks = FALSE;
|
||||
static int preserveFlag = FALSE;
|
||||
static const char *srcName;
|
||||
static const char *destName;
|
||||
static const char *skipName;
|
||||
static int dirFlag = FALSE;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||
{
|
||||
char newdestName[NAME_MAX];
|
||||
strcpy(newdestName, destName);
|
||||
if (dirFlag==TRUE) {
|
||||
strcat(newdestName, "/");
|
||||
if ( skipName != NULL)
|
||||
strcat(newdestName, strstr(fileName, skipName));
|
||||
}
|
||||
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
||||
}
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
if (argc < 3) {
|
||||
usage (cp_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 'a':
|
||||
followLinks = TRUE;
|
||||
preserveFlag = TRUE;
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
followLinks = TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
preserveFlag = TRUE;
|
||||
break;
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage (cp_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
destName = argv[argc - 1];
|
||||
dirFlag = isDirectory(destName);
|
||||
|
||||
if ((argc > 3) && dirFlag==FALSE) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- > 1) {
|
||||
srcName = *(argv++);
|
||||
skipName = strrchr(srcName, '/');
|
||||
if (skipName)
|
||||
skipName++;
|
||||
if (recursiveAction(srcName, recursiveFlag, followLinks, FALSE,
|
||||
fileAction, fileAction) == FALSE) {
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
/* globals in this file only */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static int startpos = 1;
|
||||
static int endpos = -1;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
|
||||
|
||||
/*
|
||||
* decompose_list() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
*/
|
||||
static void decompose_list(const char *list)
|
||||
{
|
||||
unsigned int nminus = 0;
|
||||
char *ptr;
|
||||
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle single value 'N' case */
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
/* handle multi-value cases */
|
||||
else if (nminus == 1) {
|
||||
/* handle 'N-' case */
|
||||
if (list[strlen(list) - 1] == '-') {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
}
|
||||
/* handle '-M' case */
|
||||
else if (list[0] == '-') {
|
||||
endpos = strtol(&list[1], NULL, 10);
|
||||
}
|
||||
/* handle 'N-M' case */
|
||||
else {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
endpos = strtol(ptr+1, &ptr, 10);
|
||||
}
|
||||
|
||||
/* a sanity check */
|
||||
if (startpos == 0) {
|
||||
startpos = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* snippy-snip
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
/* a valid end position has been specified */
|
||||
if (endpos > 0) {
|
||||
for (i = startpos-1; i < endpos; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* otherwise, just go to the end of the line */
|
||||
else {
|
||||
for (i = startpos-1; line[i]; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
char *ptr;
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields");
|
||||
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
* files were specified or '-' was specified, take input from stdin.
|
||||
* Otherwise, we process all the files specified. */
|
||||
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
|
||||
cut_file(stdin);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+197
-233
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini date implementation for busybox
|
||||
*
|
||||
@@ -19,13 +20,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -34,254 +41,211 @@
|
||||
an RFC 822 complient date output for shell scripting
|
||||
mail commands */
|
||||
|
||||
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
|
||||
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
|
||||
"Display the current time in the given FORMAT, or set the system date.\n"
|
||||
"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
|
||||
"\t-s\t\tset time described by STRING\n"
|
||||
"\t-u\t\tprint or set Coordinated Universal Time\n";
|
||||
|
||||
|
||||
/* Input parsing code is always bulky - used heavy duty libc stuff as
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
|
||||
struct tm *
|
||||
date_conv_time(struct tm *tm_time, const char *t_string) {
|
||||
int nr;
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
|
||||
&(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday),
|
||||
&(tm_time->tm_hour),
|
||||
&(tm_time->tm_min),
|
||||
&(tm_time->tm_year));
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
|
||||
&(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday),
|
||||
&(tm_time->tm_hour),
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if(nr < 4 || nr > 5) {
|
||||
fprintf(stderr, "date: invalid date `%s'\n", t_string);
|
||||
exit( FALSE);
|
||||
}
|
||||
if (nr < 4 || nr > 5) {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if(tm_time->tm_year >= 1900)
|
||||
tm_time->tm_year -= 1900;
|
||||
/* adjust date */
|
||||
tm_time->tm_mon -= 1;
|
||||
|
||||
return(tm_time);
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time->tm_year >= 1900)
|
||||
tm_time->tm_year -= 1900;
|
||||
/* adjust date */
|
||||
tm_time->tm_mon -= 1;
|
||||
|
||||
return (tm_time);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* The new stuff for LRP */
|
||||
|
||||
struct tm *
|
||||
date_conv_ftime(struct tm *tm_time, const char *t_string) {
|
||||
struct tm itm_time, jtm_time, ktm_time, \
|
||||
ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if(sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour,
|
||||
&itm_time.tm_min,
|
||||
&itm_time.tm_sec) == 3 ) {
|
||||
|
||||
*tm_time = itm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour,
|
||||
&jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min,
|
||||
&ktm_time.tm_sec) == 5) {
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour,
|
||||
<m_time.tm_min) == 4) {
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min,
|
||||
&mtm_time.tm_sec) == 6) {
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour,
|
||||
&ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return(tm_time);
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "date: invalid date `%s'\n", t_string);
|
||||
|
||||
exit( FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
date_main(int argc, char * * argv)
|
||||
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int i;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
int use_arg = 0;
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
i = --argc;
|
||||
argv++;
|
||||
while (i > 0 && **argv) {
|
||||
if (**argv == '-') {
|
||||
while (i>0 && *++(*argv)) switch (**argv) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if(date_str != NULL) usage ( date_usage);
|
||||
date_str = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv ("TZ=UTC0") != 0) {
|
||||
fprintf(stderr,"date: memory exhausted\n");
|
||||
exit( FALSE);
|
||||
}
|
||||
/* Look ma, no break. Don't fix it either. */
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if(date_str != NULL) usage ( date_usage);
|
||||
date_str = optarg;
|
||||
break;
|
||||
case '-':
|
||||
usage ( date_usage);
|
||||
}
|
||||
struct tm t;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
|
||||
date_fmt=*argv;
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str=*argv;
|
||||
} else {
|
||||
usage ( date_usage);
|
||||
}
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
i--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight!*/
|
||||
if(date_str != NULL) {
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
}
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if(date_str != NULL) {
|
||||
|
||||
if(strchr(date_str, ':') != NULL) {
|
||||
date_conv_ftime(&tm_time, date_str);
|
||||
} else {
|
||||
date_conv_time(&tm_time, date_str);
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0 ) {
|
||||
fprintf(stderr, "date: invalid date `%s'\n", date_str);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if(set_time) {
|
||||
if( stime(&tm) < 0) {
|
||||
fprintf(stderr, "date: can't set date.\n");
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
if(date_fmt == NULL) {
|
||||
date_fmt = (rfc822
|
||||
? (utc
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
} else if ( *date_fmt == '\0' ) {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf ("\n");
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
|
||||
if( strncmp( date_fmt, "%f", 2) == 0 ) {
|
||||
date_fmt = "%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = malloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
exit( TRUE);
|
||||
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
int date_main(int argc, char **argv)
|
||||
{
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int c;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
int use_arg = 0;
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
if (date_str != NULL) {
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
}
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if (date_str != NULL) {
|
||||
|
||||
if (strchr(date_str, ':') != NULL) {
|
||||
date_conv_ftime(&tm_time, date_str);
|
||||
} else {
|
||||
date_conv_time(&tm_time, date_str);
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
if (date_fmt == NULL) {
|
||||
date_fmt = (rfc822
|
||||
? (utc
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
|
||||
if (strncmp(date_fmt, "%f", 2) == 0) {
|
||||
date_fmt = "%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = xmalloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+120
-196
@@ -1,15 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* based in part on code taken from sash.
|
||||
*
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,208 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char dd_usage[] =
|
||||
"dd [if=name] [of=name] [bs=n] [count=n]\n"
|
||||
"Copy a file, converting and formatting according to options\n\n"
|
||||
"\tif=FILE\tread from FILE instead of stdin\n"
|
||||
"\tof=FILE\twrite to FILE instead of stout\n"
|
||||
"\tbs=n\tread and write N BYTES at a time\n"
|
||||
"\tcount=n\tcopy only n input blocks\n"
|
||||
//"\tskip=n\tskip n input blocks\n"
|
||||
"\n"
|
||||
"BYTES may be suffixed: by k for x1024, b for x512, and w for x2.\n";
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Read a number with a possible multiplier.
|
||||
* Returns -1 if the number format is illegal.
|
||||
*/
|
||||
static long getNum (const char *cp)
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
long value;
|
||||
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
if (!isDecimal (*cp))
|
||||
return -1;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
show_usage();
|
||||
}
|
||||
|
||||
value = 0;
|
||||
buf = xmalloc(bs);
|
||||
|
||||
while (isDecimal (*cp))
|
||||
value = value * 10 + *cp++ - '0';
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
switch (*cp++) {
|
||||
case 'k':
|
||||
value *= 1024;
|
||||
break;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
case 'b':
|
||||
value *= 512;
|
||||
break;
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
case 'w':
|
||||
value *= 2;
|
||||
break;
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
case '\0':
|
||||
return value;
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (*cp)
|
||||
return -1;
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
return value;
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
|
||||
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
|
||||
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
extern int dd_main (int argc, char **argv)
|
||||
{
|
||||
const char *inFile;
|
||||
const char *outFile;
|
||||
char *cp;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int skipBlocks;
|
||||
int blockSize;
|
||||
long count;
|
||||
long intotal;
|
||||
long outTotal;
|
||||
unsigned char *buf;
|
||||
|
||||
inFile = NULL;
|
||||
outFile = NULL;
|
||||
blockSize = 512;
|
||||
skipBlocks = 0;
|
||||
count = 1;
|
||||
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile=((strchr(*argv, '='))+1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile=((strchr(*argv, '='))+1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = getNum ((strchr(*argv, '='))+1);
|
||||
if (count <= 0) {
|
||||
fprintf (stderr, "Bad count value %ld\n", count);
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = getNum ((strchr(*argv, '='))+1);
|
||||
if (blockSize <= 0) {
|
||||
fprintf (stderr, "Bad block size value %d\n", blockSize);
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = atoi( *argv);
|
||||
if (skipBlocks <= 0) {
|
||||
fprintf (stderr, "Bad skip value %d\n", skipBlocks);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
goto usage;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if ( inFile == NULL || outFile == NULL)
|
||||
goto usage;
|
||||
|
||||
buf = malloc (blockSize);
|
||||
if (buf == NULL) {
|
||||
fprintf (stderr, "Cannot allocate buffer\n");
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
intotal = 0;
|
||||
outTotal = 0;
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = STDIN;
|
||||
else
|
||||
inFd = open (inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
perror (inFile);
|
||||
free (buf);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = STDOUT;
|
||||
else
|
||||
outFd = creat (outFile, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
perror (outFile);
|
||||
close (inFd);
|
||||
free (buf);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
//lseek(inFd, skipBlocks*blockSize, SEEK_SET);
|
||||
while (outTotal < count * blockSize) {
|
||||
inCc = read (inFd, buf, blockSize);
|
||||
if (inCc < 0) {
|
||||
perror (inFile);
|
||||
goto cleanup;
|
||||
}
|
||||
intotal += inCc;
|
||||
cp = buf;
|
||||
|
||||
while (intotal > outTotal) {
|
||||
if (outTotal + inCc > count * blockSize)
|
||||
inCc = count * blockSize - outTotal;
|
||||
outCc = write (outFd, cp, inCc);
|
||||
if (outCc < 0) {
|
||||
perror (outFile);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
inCc -= outCc;
|
||||
cp += outCc;
|
||||
outTotal += outCc;
|
||||
}
|
||||
}
|
||||
|
||||
if (inCc < 0)
|
||||
perror (inFile);
|
||||
|
||||
cleanup:
|
||||
close (inFd);
|
||||
close (outFd);
|
||||
free (buf);
|
||||
|
||||
printf ("%ld+%d records in\n", intotal / blockSize,
|
||||
(intotal % blockSize) != 0);
|
||||
printf ("%ld+%d records out\n", outTotal / blockSize,
|
||||
(outTotal % blockSize) != 0);
|
||||
exit( TRUE);
|
||||
usage:
|
||||
|
||||
fprintf (stderr, "%s", dd_usage);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
|
||||
+131
-108
@@ -1,7 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
@@ -21,128 +22,150 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <fstab.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const char df_usage[] = "df [filesystem ...]\n"
|
||||
"\n" "\tPrint the filesystem space used and space available.\n";
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
|
||||
static int df(char *device, const char *mountPoint)
|
||||
static int do_df(char *device, const char *mount_point)
|
||||
{
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
long base;
|
||||
#endif
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
return 1;
|
||||
}
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
perror_msg("%s", mount_point);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if (strcmp(device, "/dev/root") == 0)
|
||||
device = (getfsfile("/"))->fs_spec;
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
if(blocks_used == 0)
|
||||
blocks_percent_used = 0;
|
||||
else {
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
}
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
find_real_root_device_name( device);
|
||||
}
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
switch (df_disp_hr) {
|
||||
case MEGABYTE:
|
||||
base = KILOBYTE;
|
||||
break;
|
||||
case KILOBYTE:
|
||||
base = 1;
|
||||
break;
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
printf("%-20s %9s ", device,
|
||||
make_human_readable_str((unsigned long)(s.f_blocks *
|
||||
(s.f_bsize/(double)KILOBYTE)), base));
|
||||
printf("%9s ",
|
||||
make_human_readable_str((unsigned long)(
|
||||
(s.f_blocks - s.f_bfree) *
|
||||
(s.f_bsize/(double)KILOBYTE)), base));
|
||||
printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str((unsigned long)(s.f_bavail *
|
||||
(s.f_bsize/(double)KILOBYTE)), base),
|
||||
blocks_percent_used, mount_point);
|
||||
#else
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
|
||||
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
|
||||
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
|
||||
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
|
||||
blocks_percent_used, mountPoint);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a block device, find the mount table entry if that block device
|
||||
* is mounted.
|
||||
*
|
||||
* Given any other file (or directory), find the mount table entry for its
|
||||
* filesystem.
|
||||
*/
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table)
|
||||
{
|
||||
struct stat s;
|
||||
dev_t mountDevice;
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (stat(name, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if ((s.st_mode & S_IFMT) == S_IFBLK)
|
||||
mountDevice = s.st_rdev;
|
||||
else
|
||||
mountDevice = s.st_dev;
|
||||
|
||||
|
||||
if ((mountTable = setmntent(table, "r")) == 0)
|
||||
return 0;
|
||||
|
||||
while ((mountEntry = getmntent(mountTable)) != 0) {
|
||||
if (strcmp(name, mountEntry->mnt_dir) == 0
|
||||
|| strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
|
||||
break;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
return mountEntry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
int status = EXIT_SUCCESS;
|
||||
int opt = 0;
|
||||
int i = 0;
|
||||
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
|
||||
0) {
|
||||
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (status != 0)
|
||||
return status;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
perror(mtab_file);
|
||||
exit(FALSE);
|
||||
while ((opt = getopt(argc, argv, "k"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h':
|
||||
df_disp_hr = 0;
|
||||
strcpy(disp_units_hdr, " Size");
|
||||
break;
|
||||
case 'm':
|
||||
df_disp_hr = MEGABYTE;
|
||||
strcpy(disp_units_hdr, "1M-blocks");
|
||||
break;
|
||||
#endif
|
||||
case 'k':
|
||||
/* default display is kilobytes */
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (status)
|
||||
return status;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
|
||||
"Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
return 0;
|
||||
if(optind < argc) {
|
||||
struct mntent *mount_entry;
|
||||
for(i = optind; i < argc; i++)
|
||||
{
|
||||
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
|
||||
mount_table = setmntent(mtab_file, "r");
|
||||
if (mount_table == 0) {
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mount_entry = getmntent(mount_table))) {
|
||||
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mount_table);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,50 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s != *argv && *s == '/') {
|
||||
*s-- = '\0';
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s != NULL && s == *argv)
|
||||
s[1] = '\0';
|
||||
else if (s != NULL)
|
||||
*s = '\0';
|
||||
puts(s ? *argv : ".");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* dos2unix for BusyBox
|
||||
*
|
||||
* dos2unix '\n' convertor 0.5.0
|
||||
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
|
||||
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* dos2unix filters reading input from stdin and writing output to stdout.
|
||||
* Without arguments it reverts the format (e.i. if source is in UNIX format,
|
||||
* output is in DOS format and vice versa).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* See the COPYING file for license information.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define CT_AUTO 0
|
||||
#define CT_UNIX2DOS 1
|
||||
#define CT_DOS2UNIX 2
|
||||
|
||||
int convert(char *fn, int ConvType);
|
||||
|
||||
int dos2unix_main(int argc, char *argv[]) {
|
||||
int ConvType = CT_AUTO;
|
||||
int o;
|
||||
|
||||
// process parameters
|
||||
while ((o = getopt(argc, argv, "du")) != EOF) {
|
||||
switch (o) {
|
||||
case 'd':
|
||||
ConvType = CT_UNIX2DOS;
|
||||
break;
|
||||
case 'u':
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
while(optind < argc)
|
||||
if ((o = convert(argv[optind++], ConvType)) < 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
o = convert(NULL, ConvType);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
// if fn is NULL then input is stdin and output is stdout
|
||||
int convert(char *fn, int ConvType) {
|
||||
char c;
|
||||
char *tempFn = NULL;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
|
||||
if (fn != NULL) {
|
||||
if ((in = fopen(fn, "r")) == NULL) {
|
||||
perror_msg(fn);
|
||||
return -1;
|
||||
}
|
||||
tempFn = tmpnam(NULL);
|
||||
if (tempFn == NULL || (out = fopen(tempFn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r') {
|
||||
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
|
||||
// file is alredy in DOS format so it is not necessery to touch it
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType)
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
|
||||
// file is alredy in UNIX format so it is not necessery to touch it
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType)
|
||||
ConvType = CT_UNIX2DOS;
|
||||
if (ConvType == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
break;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
if (c != EOF)
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r')
|
||||
continue;
|
||||
if (c == '\n') {
|
||||
if (ConvType == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
continue;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0 ||
|
||||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF)
|
||||
fputc(c, out);
|
||||
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
static int du_depth = 0;
|
||||
static int count_hardlinks = 0;
|
||||
|
||||
static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
unsigned long base;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
switch (disp_hr) {
|
||||
case MEGABYTE:
|
||||
base = KILOBYTE;
|
||||
break;
|
||||
case KILOBYTE:
|
||||
base = 1;
|
||||
break;
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
printf("%s\t%s\n", make_human_readable_str(size, base), filename);
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_summary(long size, char *filename)
|
||||
{
|
||||
if (du_depth == 1) {
|
||||
printf("summary\n");
|
||||
print_normal(size, filename);
|
||||
}
|
||||
}
|
||||
|
||||
/* tiny recursive du */
|
||||
static long du(char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
long sum;
|
||||
int len;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
perror_msg_and_die("%s", filename);
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
sum = (statbuf.st_blocks >> 1);
|
||||
|
||||
/* Don't add in stuff pointed to by symbolic links */
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1)
|
||||
print(sum, filename);
|
||||
}
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
|
||||
dir = opendir(filename);
|
||||
if (!dir) {
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = strlen(filename);
|
||||
if (filename[len - 1] == '/')
|
||||
filename[--len] = '\0';
|
||||
|
||||
while ((entry = readdir(dir))) {
|
||||
char newfile[BUFSIZ + 1];
|
||||
char *name = entry->d_name;
|
||||
|
||||
if ((strcmp(name, "..") == 0)
|
||||
|| (strcmp(name, ".") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len + strlen(name) + 1 > BUFSIZ) {
|
||||
error_msg(name_too_long);
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
sprintf(newfile, "%s/%s", filename, name);
|
||||
|
||||
sum += du(newfile);
|
||||
}
|
||||
closedir(dir);
|
||||
print(sum, filename);
|
||||
}
|
||||
else if (statbuf.st_nlink > 1 && !count_hardlinks) {
|
||||
/* Add files with hard links only once */
|
||||
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1)
|
||||
print(sum, filename);
|
||||
}
|
||||
else {
|
||||
add_to_ino_dev_hashtable(&statbuf, NULL);
|
||||
}
|
||||
}
|
||||
du_depth--;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int du_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int i;
|
||||
int c;
|
||||
|
||||
/* default behaviour */
|
||||
print = print_normal;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
break;
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* go through remaining args (if any) */
|
||||
if (optind >= argc) {
|
||||
if (du(".") == 0)
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
long sum;
|
||||
|
||||
for (i=optind; i < argc; i++) {
|
||||
if ((sum = du(argv[i])) == 0)
|
||||
status = EXIT_FAILURE;
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.43 2001/03/09 14:36:42 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,152 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* echo implementation for busybox
|
||||
*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
{
|
||||
int nflag = 0;
|
||||
int eflag = 0;
|
||||
|
||||
/* Skip argv[0]. */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int index;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (index = 0; temp[index]; index++)
|
||||
{
|
||||
if (strrchr("neE", temp[index]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
if (!*temp)
|
||||
goto just_echo;
|
||||
|
||||
/*
|
||||
* All of the options in temp are valid options to echo.
|
||||
* Handle them.
|
||||
*/
|
||||
while (*temp)
|
||||
{
|
||||
if (*temp == 'n')
|
||||
nflag = 1;
|
||||
else if (*temp == 'e')
|
||||
eflag = 1;
|
||||
else if (*temp == 'E')
|
||||
eflag = 0;
|
||||
else
|
||||
goto just_echo;
|
||||
|
||||
temp++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
char *arg = argv[0];
|
||||
register int c;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
|
||||
/* Check for escape sequence. */
|
||||
if (c == '\\' && eflag && *arg) {
|
||||
if (*arg == 'c') {
|
||||
/* '\c' means cancel newline. */
|
||||
nflag = 1;
|
||||
arg++;
|
||||
continue;
|
||||
} else {
|
||||
c = process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc > 0)
|
||||
putchar(' ');
|
||||
}
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Kenneth Almquist.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)echo.c 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
@@ -0,0 +1,535 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini expr implementation for busybox
|
||||
*
|
||||
* based on GNU expr Mike Parker.
|
||||
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Busybox modifications
|
||||
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* this program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the gnu general public license as published by
|
||||
* the free software foundation; either version 2 of the license, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the gnu
|
||||
* general public license for more details.
|
||||
*
|
||||
* you should have received a copy of the gnu general public license
|
||||
* along with this program; if not, write to the free software
|
||||
* foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
|
||||
*
|
||||
*/
|
||||
|
||||
/* This program evaluates expressions. Each token (operator, operand,
|
||||
* parenthesis) of the expression must be a seperate argument. The
|
||||
* parser used is a reasonably general one, though any incarnation of
|
||||
* it is language-specific. It is especially nice for expressions.
|
||||
*
|
||||
* No parse tree is needed; a new node is evaluated immediately.
|
||||
* One function can handle multiple operators all of equal precedence,
|
||||
* provided they all associate ((x op x) op x). */
|
||||
|
||||
/* no getopt needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
|
||||
/* A value is.... */
|
||||
struct valinfo {
|
||||
TYPE type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
int i;
|
||||
char *s;
|
||||
} u;
|
||||
};
|
||||
typedef struct valinfo VALUE;
|
||||
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
static char **args;
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv);
|
||||
static VALUE *eval (void);
|
||||
static VALUE *int_value (int i);
|
||||
static VALUE *str_value (char *s);
|
||||
static int nextarg (char *str);
|
||||
static int null (VALUE *v);
|
||||
static int toarith (VALUE *v);
|
||||
static void freev (VALUE *v);
|
||||
static void tostring (VALUE *v);
|
||||
|
||||
int expr_main (int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
error_msg_and_die ("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
else
|
||||
printf ("%s\n", v->u.s);
|
||||
|
||||
exit (null (v));
|
||||
}
|
||||
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *int_value (int i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = integer;
|
||||
v->u.i = i;
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Return a VALUE for S. */
|
||||
|
||||
static VALUE *str_value (char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strdup (s);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void freev (VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
free (v->u.s);
|
||||
free (v);
|
||||
}
|
||||
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int null (VALUE *v)
|
||||
{
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return v->u.i == 0;
|
||||
case string:
|
||||
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
|
||||
static void tostring (VALUE *v)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (v->type == integer) {
|
||||
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
|
||||
sprintf (temp, "%d", v->u.i);
|
||||
v->u.s = temp;
|
||||
v->type = string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static int toarith (VALUE *v)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return 1;
|
||||
case string:
|
||||
i = 0;
|
||||
/* Don't interpret the empty string as an integer. */
|
||||
if (v->u.s == 0)
|
||||
return 0;
|
||||
i = atoi(v->u.s);
|
||||
free (v->u.s);
|
||||
v->u.i = i;
|
||||
v->type = integer;
|
||||
return 1;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static int
|
||||
nextarg (char *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
return 0;
|
||||
return strcmp (*args, str) == 0;
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
#define cmpf(name, rel) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (l->type == string || r->type == string) { \
|
||||
tostring (l); \
|
||||
tostring (r); \
|
||||
return strcmp (l->u.s, r->u.s) rel 0; \
|
||||
} \
|
||||
else \
|
||||
return l->u.i rel r->u.i; \
|
||||
}
|
||||
cmpf (less_than, <)
|
||||
cmpf (less_equal, <=)
|
||||
cmpf (equal, ==)
|
||||
cmpf (not_equal, !=)
|
||||
cmpf (greater_equal, >=)
|
||||
cmpf (greater_than, >)
|
||||
|
||||
#undef cmpf
|
||||
|
||||
/* The arithmetic operator handling functions. */
|
||||
|
||||
#define arithf(name, op) \
|
||||
static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
#define arithdivf(name, op) \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument"); \
|
||||
if (r->u.i == 0) \
|
||||
error_msg_and_die ( "division by zero"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
arithf (plus, +)
|
||||
arithf (minus, -)
|
||||
arithf (multiply, *)
|
||||
arithdivf (divide, /)
|
||||
arithdivf (mod, %)
|
||||
|
||||
#undef arithf
|
||||
#undef arithdivf
|
||||
|
||||
/* Do the : operator.
|
||||
SV is the VALUE for the lhs (the string),
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
const char *errmsg;
|
||||
struct re_pattern_buffer re_buffer;
|
||||
struct re_registers re_regs;
|
||||
int len;
|
||||
|
||||
tostring (sv);
|
||||
tostring (pv);
|
||||
|
||||
if (pv->u.s[0] == '^') {
|
||||
fprintf (stderr, "\
|
||||
warning: unportable BRE: `%s': using `^' as the first character\n\
|
||||
of a basic regular expression is not portable; it is being ignored",
|
||||
pv->u.s);
|
||||
}
|
||||
|
||||
len = strlen (pv->u.s);
|
||||
memset (&re_buffer, 0, sizeof (re_buffer));
|
||||
memset (&re_regs, 0, sizeof (re_regs));
|
||||
re_buffer.allocated = 2 * len;
|
||||
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
|
||||
re_buffer.translate = 0;
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
error_msg_and_die("%s", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
if (len >= 0) {
|
||||
/* Were \(...\) used? */
|
||||
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
|
||||
sv->u.s[re_regs.end[1]] = '\0';
|
||||
v = str_value (sv->u.s + re_regs.start[1]);
|
||||
}
|
||||
else
|
||||
v = int_value (len);
|
||||
}
|
||||
else {
|
||||
/* Match failed -- return the right kind of null. */
|
||||
if (re_buffer.re_nsub > 0)
|
||||
v = str_value ("");
|
||||
else
|
||||
v = int_value (0);
|
||||
}
|
||||
free (re_buffer.buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Handle bare operands and ( expr ) syntax. */
|
||||
|
||||
static VALUE *eval7 (void)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
error_msg_and_die ( "syntax error");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
|
||||
/* Handle match, substr, index, length, and quote keywords. */
|
||||
|
||||
static VALUE *eval6 (void)
|
||||
{
|
||||
VALUE *l, *r, *v, *i1, *i2;
|
||||
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
tostring (r);
|
||||
v = int_value (strlen (r->u.s));
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("match")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("index")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
v = int_value (strcspn (l->u.s, r->u.s) + 1);
|
||||
if (v->u.i == (int) strlen (l->u.s) + 1)
|
||||
v->u.i = 0;
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("substr")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
i1 = eval6 ();
|
||||
i2 = eval6 ();
|
||||
tostring (l);
|
||||
if (!toarith (i1) || !toarith (i2)
|
||||
|| i1->u.i > (int) strlen (l->u.s)
|
||||
|| i1->u.i <= 0 || i2->u.i <= 0)
|
||||
v = str_value ("");
|
||||
else {
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
|
||||
l->u.s + i1->u.i - 1, i2->u.i);
|
||||
v->u.s[i2->u.i] = 0;
|
||||
}
|
||||
freev (l);
|
||||
freev (i1);
|
||||
freev (i2);
|
||||
return v;
|
||||
}
|
||||
else
|
||||
return eval7 ();
|
||||
}
|
||||
|
||||
/* Handle : operator (pattern matching).
|
||||
Calls docolon to do the real work. */
|
||||
|
||||
static VALUE *eval5 (void)
|
||||
{
|
||||
VALUE *l, *r, *v;
|
||||
|
||||
l = eval6 ();
|
||||
while (nextarg (":")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = v;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle *, /, % operators. */
|
||||
|
||||
static VALUE *eval4 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval5 ();
|
||||
while (1) {
|
||||
if (nextarg ("*"))
|
||||
fxn = multiply;
|
||||
else if (nextarg ("/"))
|
||||
fxn = divide;
|
||||
else if (nextarg ("%"))
|
||||
fxn = mod;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval5 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle +, - operators. */
|
||||
|
||||
static VALUE *eval3 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval4 ();
|
||||
while (1) {
|
||||
if (nextarg ("+"))
|
||||
fxn = plus;
|
||||
else if (nextarg ("-"))
|
||||
fxn = minus;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval4 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle comparisons. */
|
||||
|
||||
static VALUE *eval2 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval3 ();
|
||||
while (1) {
|
||||
if (nextarg ("<"))
|
||||
fxn = less_than;
|
||||
else if (nextarg ("<="))
|
||||
fxn = less_equal;
|
||||
else if (nextarg ("=") || nextarg ("=="))
|
||||
fxn = equal;
|
||||
else if (nextarg ("!="))
|
||||
fxn = not_equal;
|
||||
else if (nextarg (">="))
|
||||
fxn = greater_equal;
|
||||
else if (nextarg (">"))
|
||||
fxn = greater_than;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval3 ();
|
||||
toarith (l);
|
||||
toarith (r);
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle &. */
|
||||
|
||||
static VALUE *eval1 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval2 ();
|
||||
while (nextarg ("&")) {
|
||||
args++;
|
||||
r = eval2 ();
|
||||
if (null (l) || null (r)) {
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (0);
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle |. */
|
||||
|
||||
static VALUE *eval (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval1 ();
|
||||
while (nextarg ("|")) {
|
||||
args++;
|
||||
r = eval1 ();
|
||||
if (null (l)) {
|
||||
freev (l);
|
||||
l = r;
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char *input;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if ((input = get_line_from_file(fp)) == NULL)
|
||||
break;
|
||||
fputs(input, stdout);
|
||||
free(input);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BusyBoxed head(1) */
|
||||
int head_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((opt = getopt(argc, argv, "n:")) > 0) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
len = atoi(optarg);
|
||||
if (len >= 1)
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* get rest of argv[] or stdin if nothing's left */
|
||||
if (argv[optind] == NULL) {
|
||||
head(len, stdin);
|
||||
return status;
|
||||
}
|
||||
|
||||
need_headers = optind != (argc - 1);
|
||||
while (argv[optind]) {
|
||||
if (strcmp(argv[optind], "-") == 0) {
|
||||
fp = stdin;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
if ((fp = wfopen(argv[optind], "r")) == NULL)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
putchar('\n');
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini hostid implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
printf("%lx\n", gethostid());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini id implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern int id_main(int argc, char **argv)
|
||||
{
|
||||
int no_user = 0, no_group = 0, print_real = 0;
|
||||
int name_not_number = 0;
|
||||
char user[9], group[9];
|
||||
long gid;
|
||||
long pwnam, grnam;
|
||||
int opt;
|
||||
|
||||
gid = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
no_group++;
|
||||
break;
|
||||
case 'g':
|
||||
no_user++;
|
||||
break;
|
||||
case 'r':
|
||||
print_real++;
|
||||
break;
|
||||
case 'n':
|
||||
name_not_number++;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (no_user && no_group) show_usage();
|
||||
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
my_getpwuid(user, getuid());
|
||||
my_getgrgid(group, getgid());
|
||||
} else {
|
||||
my_getpwuid(user, geteuid());
|
||||
my_getgrgid(group, getegid());
|
||||
}
|
||||
} else {
|
||||
strncpy(user, argv[optind], 8);
|
||||
user[8] = '\0';
|
||||
gid = my_getpwnamegid(user);
|
||||
my_getgrgid(group, gid);
|
||||
}
|
||||
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
|
||||
if (no_group) {
|
||||
if(name_not_number && user)
|
||||
printf("%s\n",user);
|
||||
else
|
||||
printf("%ld\n", pwnam);
|
||||
} else if (no_user) {
|
||||
if(name_not_number && group)
|
||||
printf("%s\n", group);
|
||||
else
|
||||
printf("%ld\n", grnam);
|
||||
} else {
|
||||
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
+7
-8
@@ -1,14 +1,13 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
length_main(int argc, char * * argv)
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if ( **(argv+1) == '-' ) {
|
||||
usage("length string\n");
|
||||
}
|
||||
printf("%d\n", strlen(argv[1]));
|
||||
return( TRUE);
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
show_usage();
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+98
-64
@@ -1,8 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ln implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,80 +21,114 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
static const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n"
|
||||
"\n"
|
||||
"\tAdd a new name that refers to the same file as \"original-name\"\n"
|
||||
"\n"
|
||||
"\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n"
|
||||
"\t-f:\tRemove existing destination files.\n";
|
||||
static const int LN_SYMLINK = 1;
|
||||
static const int LN_FORCE = 2;
|
||||
static const int LN_NODEREFERENCE = 4;
|
||||
|
||||
/*
|
||||
* linkDestName is where the link points to,
|
||||
* linkSrcName is the name of the link to be created.
|
||||
*/
|
||||
static int fs_link(const char *link_destname, const char *link_srcname,
|
||||
const int flag)
|
||||
{
|
||||
int status;
|
||||
int src_is_dir;
|
||||
char *src_name;
|
||||
|
||||
static int symlinkFlag = FALSE;
|
||||
static int removeoldFlag = FALSE;
|
||||
static const char *destName;
|
||||
if (link_destname==NULL)
|
||||
return(FALSE);
|
||||
|
||||
src_name = (char *) xmalloc(strlen(link_srcname)+strlen(link_destname)+1);
|
||||
|
||||
if (link_srcname==NULL)
|
||||
strcpy(src_name, link_destname);
|
||||
else
|
||||
strcpy(src_name, link_srcname);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
src_is_dir = is_directory(src_name, TRUE, NULL);
|
||||
else
|
||||
src_is_dir = is_directory(src_name, FALSE, NULL);
|
||||
|
||||
if ((src_is_dir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
char* srcdir_name;
|
||||
|
||||
srcdir_name = xstrdup(link_destname);
|
||||
strcat(src_name, "/");
|
||||
strcat(src_name, get_last_path_component(srcdir_name));
|
||||
free(srcdir_name);
|
||||
}
|
||||
|
||||
if (flag&LN_FORCE)
|
||||
unlink(src_name);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_destname, src_name);
|
||||
else
|
||||
status = link(link_destname, src_name);
|
||||
|
||||
if (status != 0) {
|
||||
perror_msg(src_name);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
int status;
|
||||
char newdestName[NAME_MAX];
|
||||
|
||||
if (argc < 3) {
|
||||
usage (ln_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 's':
|
||||
symlinkFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
removeoldFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage (ln_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
destName = argv[argc - 1];
|
||||
|
||||
if ((argc > 3) && !(isDirectory(destName))) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- >= 2) {
|
||||
strcpy(newdestName, destName);
|
||||
strcat(newdestName, (*argv)+(strlen(*(++argv))));
|
||||
int status = EXIT_SUCCESS;
|
||||
int flag = 0;
|
||||
int opt;
|
||||
|
||||
if (removeoldFlag==TRUE ) {
|
||||
status = ( unlink(newdestName) && errno != ENOENT );
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
exit( FALSE);
|
||||
}
|
||||
/* Parse any options */
|
||||
while ((opt=getopt(argc, argv, "sfn")) != -1) {
|
||||
switch(opt) {
|
||||
case 's':
|
||||
flag |= LN_SYMLINK;
|
||||
break;
|
||||
case 'f':
|
||||
flag |= LN_FORCE;
|
||||
break;
|
||||
case 'n':
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if ( symlinkFlag==TRUE)
|
||||
status = symlink(*argv, newdestName);
|
||||
else
|
||||
status = link(*argv, newdestName);
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
exit( FALSE);
|
||||
if (optind > (argc-1)) {
|
||||
show_usage();
|
||||
}
|
||||
if (optind == (argc-1)) {
|
||||
if (fs_link(argv[optind],
|
||||
get_last_path_component(argv[optind]), flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
exit( TRUE);
|
||||
while(optind<(argc-1)) {
|
||||
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
optind++;
|
||||
}
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,41 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini logname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("no login name");
|
||||
}
|
||||
+819
-427
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,957 @@
|
||||
/* md5sum.c - Compute MD5 checksum of files or strings according to the
|
||||
* definition of MD5 in RFC 1321 from April 1992.
|
||||
* Copyright (C) 1995-1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define FALSE ((int) 1)
|
||||
#define TRUE ((int) 0)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.c
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
|
||||
* according to the definition of MD5 in RFC 1321 from April 1992.
|
||||
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
*
|
||||
* NOTE: The canonical source of this file is maintained with the GNU C
|
||||
* Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include "busybox.h"
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.h
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/* md5.h - Declaration of functions and data types used for MD5 sum
|
||||
computing library functions.
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _MD5_H
|
||||
static const int _MD5_H = 1;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined HAVE_LIMITS_H || defined _LIBC
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
/* The following contortions are an attempt to use the C preprocessor
|
||||
to determine an unsigned integral type that is 32 bits wide. An
|
||||
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
|
||||
doing that would require that the configure script compile and *run*
|
||||
the resulting executable. Locally running cross-compiled executables
|
||||
is usually not possible. */
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef u_int32_t md5_uint32;
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct md5_ctx
|
||||
{
|
||||
md5_uint32 A;
|
||||
md5_uint32 B;
|
||||
md5_uint32 C;
|
||||
md5_uint32 D;
|
||||
|
||||
md5_uint32 total[2];
|
||||
md5_uint32 buflen;
|
||||
char buffer[128];
|
||||
};
|
||||
|
||||
/*
|
||||
* The following three functions are build up the low level used in
|
||||
* the functions `md5_stream' and `md5_buffer'.
|
||||
*/
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void md5_process_block __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void md5_process_bytes __P ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 16 bytes following RESBUF. The result is always in little
|
||||
endian byte order, so that a byte-wise output yields to the wanted
|
||||
ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int md5_stream __P ((FILE *stream, void *resblock));
|
||||
|
||||
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------end of md5.h
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define SWAP(n) (n)
|
||||
|
||||
/* This array contains the bytes used to pad the buffer to the next
|
||||
64-byte boundary. (RFC 1321, 3.1: Step 1) */
|
||||
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
void md5_init_ctx(struct md5_ctx *ctx)
|
||||
{
|
||||
ctx->A = 0x67452301;
|
||||
ctx->B = 0xefcdab89;
|
||||
ctx->C = 0x98badcfe;
|
||||
ctx->D = 0x10325476;
|
||||
|
||||
ctx->total[0] = ctx->total[1] = 0;
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result
|
||||
must be in little endian byte order.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
|
||||
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
|
||||
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
|
||||
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the internal buffer and the usual
|
||||
prolog according to the standard and write the result to RESBUF.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
/* Take yet unprocessed bytes into account. */
|
||||
md5_uint32 bytes = ctx->buflen;
|
||||
size_t pad;
|
||||
|
||||
/* Now count remaining bytes. */
|
||||
ctx->total[0] += bytes;
|
||||
if (ctx->total[0] < bytes)
|
||||
++ctx->total[1];
|
||||
|
||||
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
|
||||
memcpy(&ctx->buffer[bytes], fillbuf, pad);
|
||||
|
||||
/* Put the 64-bit file length in *bits* at the end of the buffer. */
|
||||
*(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP(ctx->total[0] << 3);
|
||||
*(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
|
||||
SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29));
|
||||
|
||||
/* Process last bytes. */
|
||||
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
|
||||
|
||||
return md5_read_ctx(ctx, resbuf);
|
||||
}
|
||||
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
int md5_stream(FILE *stream, void *resblock)
|
||||
{
|
||||
/* Important: BLOCKSIZE must be a multiple of 64. */
|
||||
static const int BLOCKSIZE = 4096;
|
||||
struct md5_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
md5_init_ctx(&ctx);
|
||||
|
||||
/* Iterate over full file contents. */
|
||||
while (1) {
|
||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
||||
computation function processes the whole buffer so that with the
|
||||
next round of the loop another block can be read. */
|
||||
size_t n;
|
||||
sum = 0;
|
||||
|
||||
/* Read block. Take care for partial reads. */
|
||||
do {
|
||||
n = fread(buffer + sum, 1, BLOCKSIZE - sum, stream);
|
||||
|
||||
sum += n;
|
||||
}
|
||||
while (sum < BLOCKSIZE && n != 0);
|
||||
if (n == 0 && ferror(stream))
|
||||
return 1;
|
||||
|
||||
/* If end of file is reached, end the loop. */
|
||||
if (n == 0)
|
||||
break;
|
||||
|
||||
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||
BLOCKSIZE % 64 == 0
|
||||
*/
|
||||
md5_process_block(buffer, BLOCKSIZE, &ctx);
|
||||
}
|
||||
|
||||
/* Add the last bytes if necessary. */
|
||||
if (sum > 0)
|
||||
md5_process_bytes(buffer, sum, &ctx);
|
||||
|
||||
/* Construct result in desired memory. */
|
||||
md5_finish_ctx(&ctx, resblock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
void *md5_buffer(const char *buffer, size_t len, void *resblock)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
|
||||
/* Initialize the computation context. */
|
||||
md5_init_ctx(&ctx);
|
||||
|
||||
/* Process whole buffer but last len % 64 bytes. */
|
||||
md5_process_bytes(buffer, len, &ctx);
|
||||
|
||||
/* Put result in desired memory area. */
|
||||
return md5_finish_ctx(&ctx, resblock);
|
||||
}
|
||||
|
||||
void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
{
|
||||
/* When we already have some bits in our internal buffer concatenate
|
||||
both inputs first. */
|
||||
if (ctx->buflen != 0) {
|
||||
size_t left_over = ctx->buflen;
|
||||
size_t add = 128 - left_over > len ? len : 128 - left_over;
|
||||
|
||||
memcpy(&ctx->buffer[left_over], buffer, add);
|
||||
ctx->buflen += add;
|
||||
|
||||
if (left_over + add > 64) {
|
||||
md5_process_block(ctx->buffer, (left_over + add) & ~63, ctx);
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
|
||||
(left_over + add) & 63);
|
||||
ctx->buflen = (left_over + add) & 63;
|
||||
}
|
||||
|
||||
buffer = (const char *) buffer + add;
|
||||
len -= add;
|
||||
}
|
||||
|
||||
/* Process available complete blocks. */
|
||||
if (len > 64) {
|
||||
md5_process_block(buffer, len & ~63, ctx);
|
||||
buffer = (const char *) buffer + (len & ~63);
|
||||
len &= 63;
|
||||
}
|
||||
|
||||
/* Move remaining bytes in internal buffer. */
|
||||
if (len > 0) {
|
||||
memcpy(ctx->buffer, buffer, len);
|
||||
ctx->buflen = len;
|
||||
}
|
||||
}
|
||||
|
||||
/* These are the four functions used in the four steps of the MD5 algorithm
|
||||
and defined in the RFC 1321. The first function is a little bit optimized
|
||||
(as found in Colin Plumbs public domain implementation). */
|
||||
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
|
||||
#define FF(b, c, d) (d ^ (b & (c ^ d)))
|
||||
#define FG(b, c, d) FF (d, b, c)
|
||||
#define FH(b, c, d) (b ^ c ^ d)
|
||||
#define FI(b, c, d) (c ^ (b | ~d))
|
||||
|
||||
/* Process LEN bytes of BUFFER, accumulating context into CTX.
|
||||
It is assumed that LEN % 64 == 0. */
|
||||
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
{
|
||||
md5_uint32 correct_words[16];
|
||||
const md5_uint32 *words = buffer;
|
||||
size_t nwords = len / sizeof(md5_uint32);
|
||||
const md5_uint32 *endp = words + nwords;
|
||||
md5_uint32 A = ctx->A;
|
||||
md5_uint32 B = ctx->B;
|
||||
md5_uint32 C = ctx->C;
|
||||
md5_uint32 D = ctx->D;
|
||||
|
||||
/* First increment the byte count. RFC 1321 specifies the possible
|
||||
length of the file up to 2^64 bits. Here we only compute the
|
||||
number of bytes. Do a double word increment. */
|
||||
ctx->total[0] += len;
|
||||
if (ctx->total[0] < len)
|
||||
++ctx->total[1];
|
||||
|
||||
/* Process all bytes in the buffer with 64 bytes in each round of
|
||||
the loop. */
|
||||
while (words < endp) {
|
||||
md5_uint32 *cwp = correct_words;
|
||||
md5_uint32 A_save = A;
|
||||
md5_uint32 B_save = B;
|
||||
md5_uint32 C_save = C;
|
||||
md5_uint32 D_save = D;
|
||||
|
||||
/* First round: using the given function, the context and a constant
|
||||
the next context is computed. Because the algorithms processing
|
||||
unit is a 32-bit word and it is determined to work on words in
|
||||
little endian byte order we perhaps have to change the byte order
|
||||
before the computation. To reduce the work for the next steps
|
||||
we store the swapped words in the array CORRECT_WORDS. */
|
||||
|
||||
#define OP(a, b, c, d, s, T) \
|
||||
do \
|
||||
{ \
|
||||
a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
|
||||
++words; \
|
||||
CYCLIC (a, s); \
|
||||
a += b; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* It is unfortunate that C does not provide an operator for
|
||||
cyclic rotation. Hope the C compiler is smart enough. */
|
||||
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
|
||||
|
||||
/* Before we start, one word to the strange constants.
|
||||
They are defined in RFC 1321 as
|
||||
|
||||
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
|
||||
*/
|
||||
|
||||
/* Round 1. */
|
||||
OP(A, B, C, D, 7, 0xd76aa478);
|
||||
OP(D, A, B, C, 12, 0xe8c7b756);
|
||||
OP(C, D, A, B, 17, 0x242070db);
|
||||
OP(B, C, D, A, 22, 0xc1bdceee);
|
||||
OP(A, B, C, D, 7, 0xf57c0faf);
|
||||
OP(D, A, B, C, 12, 0x4787c62a);
|
||||
OP(C, D, A, B, 17, 0xa8304613);
|
||||
OP(B, C, D, A, 22, 0xfd469501);
|
||||
OP(A, B, C, D, 7, 0x698098d8);
|
||||
OP(D, A, B, C, 12, 0x8b44f7af);
|
||||
OP(C, D, A, B, 17, 0xffff5bb1);
|
||||
OP(B, C, D, A, 22, 0x895cd7be);
|
||||
OP(A, B, C, D, 7, 0x6b901122);
|
||||
OP(D, A, B, C, 12, 0xfd987193);
|
||||
OP(C, D, A, B, 17, 0xa679438e);
|
||||
OP(B, C, D, A, 22, 0x49b40821);
|
||||
|
||||
/* For the second to fourth round we have the possibly swapped words
|
||||
in CORRECT_WORDS. Redefine the macro to take an additional first
|
||||
argument specifying the function to use. */
|
||||
#undef OP
|
||||
#define OP(f, a, b, c, d, k, s, T) \
|
||||
do \
|
||||
{ \
|
||||
a += f (b, c, d) + correct_words[k] + T; \
|
||||
CYCLIC (a, s); \
|
||||
a += b; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Round 2. */
|
||||
OP(FG, A, B, C, D, 1, 5, 0xf61e2562);
|
||||
OP(FG, D, A, B, C, 6, 9, 0xc040b340);
|
||||
OP(FG, C, D, A, B, 11, 14, 0x265e5a51);
|
||||
OP(FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
|
||||
OP(FG, A, B, C, D, 5, 5, 0xd62f105d);
|
||||
OP(FG, D, A, B, C, 10, 9, 0x02441453);
|
||||
OP(FG, C, D, A, B, 15, 14, 0xd8a1e681);
|
||||
OP(FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
|
||||
OP(FG, A, B, C, D, 9, 5, 0x21e1cde6);
|
||||
OP(FG, D, A, B, C, 14, 9, 0xc33707d6);
|
||||
OP(FG, C, D, A, B, 3, 14, 0xf4d50d87);
|
||||
OP(FG, B, C, D, A, 8, 20, 0x455a14ed);
|
||||
OP(FG, A, B, C, D, 13, 5, 0xa9e3e905);
|
||||
OP(FG, D, A, B, C, 2, 9, 0xfcefa3f8);
|
||||
OP(FG, C, D, A, B, 7, 14, 0x676f02d9);
|
||||
OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
|
||||
|
||||
/* Round 3. */
|
||||
OP(FH, A, B, C, D, 5, 4, 0xfffa3942);
|
||||
OP(FH, D, A, B, C, 8, 11, 0x8771f681);
|
||||
OP(FH, C, D, A, B, 11, 16, 0x6d9d6122);
|
||||
OP(FH, B, C, D, A, 14, 23, 0xfde5380c);
|
||||
OP(FH, A, B, C, D, 1, 4, 0xa4beea44);
|
||||
OP(FH, D, A, B, C, 4, 11, 0x4bdecfa9);
|
||||
OP(FH, C, D, A, B, 7, 16, 0xf6bb4b60);
|
||||
OP(FH, B, C, D, A, 10, 23, 0xbebfbc70);
|
||||
OP(FH, A, B, C, D, 13, 4, 0x289b7ec6);
|
||||
OP(FH, D, A, B, C, 0, 11, 0xeaa127fa);
|
||||
OP(FH, C, D, A, B, 3, 16, 0xd4ef3085);
|
||||
OP(FH, B, C, D, A, 6, 23, 0x04881d05);
|
||||
OP(FH, A, B, C, D, 9, 4, 0xd9d4d039);
|
||||
OP(FH, D, A, B, C, 12, 11, 0xe6db99e5);
|
||||
OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8);
|
||||
OP(FH, B, C, D, A, 2, 23, 0xc4ac5665);
|
||||
|
||||
/* Round 4. */
|
||||
OP(FI, A, B, C, D, 0, 6, 0xf4292244);
|
||||
OP(FI, D, A, B, C, 7, 10, 0x432aff97);
|
||||
OP(FI, C, D, A, B, 14, 15, 0xab9423a7);
|
||||
OP(FI, B, C, D, A, 5, 21, 0xfc93a039);
|
||||
OP(FI, A, B, C, D, 12, 6, 0x655b59c3);
|
||||
OP(FI, D, A, B, C, 3, 10, 0x8f0ccc92);
|
||||
OP(FI, C, D, A, B, 10, 15, 0xffeff47d);
|
||||
OP(FI, B, C, D, A, 1, 21, 0x85845dd1);
|
||||
OP(FI, A, B, C, D, 8, 6, 0x6fa87e4f);
|
||||
OP(FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
|
||||
OP(FI, C, D, A, B, 6, 15, 0xa3014314);
|
||||
OP(FI, B, C, D, A, 13, 21, 0x4e0811a1);
|
||||
OP(FI, A, B, C, D, 4, 6, 0xf7537e82);
|
||||
OP(FI, D, A, B, C, 11, 10, 0xbd3af235);
|
||||
OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
|
||||
OP(FI, B, C, D, A, 9, 21, 0xeb86d391);
|
||||
|
||||
/* Add the starting values of the context. */
|
||||
A += A_save;
|
||||
B += B_save;
|
||||
C += C_save;
|
||||
D += D_save;
|
||||
}
|
||||
|
||||
/* Put checksum in context given as argument. */
|
||||
ctx->A = A;
|
||||
ctx->B = B;
|
||||
ctx->C = C;
|
||||
ctx->D = D;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------end of md5.c
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
|
||||
#define IN_CTYPE_DOMAIN(c) 1
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
|
||||
#define TOLOWER(Ch) tolower (Ch)
|
||||
#define OPENOPTS(BINARY) "r"
|
||||
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum -c'. This length does
|
||||
not include any newline character at the end of a line. */
|
||||
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
|
||||
2 - blank and binary indicator
|
||||
1 - minimum filename length */
|
||||
|
||||
static int have_read_stdin; /* Nonzero if any of the files read were
|
||||
the standard input. */
|
||||
|
||||
static int status_only = 0; /* With -c, don't generate any output.
|
||||
The exit code indicates success or failure */
|
||||
static int warn = 0; /* With -w, print a message to standard error warning
|
||||
about each improperly formatted MD5 checksum line */
|
||||
|
||||
static int split_3(char *s,
|
||||
size_t s_len,
|
||||
unsigned char **u,
|
||||
int *binary,
|
||||
char **w)
|
||||
{
|
||||
size_t i = 0;
|
||||
int escaped_filename = 0;
|
||||
|
||||
while (ISWHITE(s[i]))
|
||||
++i;
|
||||
|
||||
/* The line must have at least 35 (36 if the first is a backslash)
|
||||
more characters to contain correct message digest information.
|
||||
Ignore this line if it is too short. */
|
||||
if (!(s_len - i >= MIN_DIGEST_LINE_LENGTH
|
||||
|| (s[i] == '\\' && s_len - i >= 1 + MIN_DIGEST_LINE_LENGTH)))
|
||||
return FALSE;
|
||||
|
||||
if (s[i] == '\\') {
|
||||
++i;
|
||||
escaped_filename = 1;
|
||||
}
|
||||
*u = (unsigned char *) &s[i];
|
||||
|
||||
/* The first field has to be the 32-character hexadecimal
|
||||
representation of the message digest. If it is not followed
|
||||
immediately by a white space it's an error. */
|
||||
i += 32;
|
||||
if (!ISWHITE(s[i]))
|
||||
return FALSE;
|
||||
|
||||
s[i++] = '\0';
|
||||
|
||||
if (s[i] != ' ' && s[i] != '*')
|
||||
return FALSE;
|
||||
*binary = (s[i++] == '*');
|
||||
|
||||
/* All characters between the type indicator and end of line are
|
||||
significant -- that includes leading and trailing white space. */
|
||||
*w = &s[i];
|
||||
|
||||
if (escaped_filename) {
|
||||
/* Translate each `\n' string in the file name to a NEWLINE,
|
||||
and each `\\' string to a backslash. */
|
||||
|
||||
char *dst = &s[i];
|
||||
|
||||
while (i < s_len) {
|
||||
switch (s[i]) {
|
||||
case '\\':
|
||||
if (i == s_len - 1) {
|
||||
/* A valid line does not end with a backslash. */
|
||||
return FALSE;
|
||||
}
|
||||
++i;
|
||||
switch (s[i++]) {
|
||||
case 'n':
|
||||
*dst++ = '\n';
|
||||
break;
|
||||
case '\\':
|
||||
*dst++ = '\\';
|
||||
break;
|
||||
default:
|
||||
/* Only `\' or `n' may follow a backslash. */
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
/* The file name may not contain a NUL. */
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
*dst++ = s[i++];
|
||||
break;
|
||||
}
|
||||
}
|
||||
*dst = '\0';
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hex_digits(unsigned char const *s)
|
||||
{
|
||||
while (*s) {
|
||||
if (!ISXDIGIT(*s))
|
||||
return TRUE;
|
||||
++s;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* An interface to md5_stream. Operate on FILENAME (it may be "-") and
|
||||
put the result in *MD5_RESULT. Return non-zero upon failure, zero
|
||||
to indicate success. */
|
||||
static int md5_file(const char *filename,
|
||||
int binary,
|
||||
unsigned char *md5_result)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if (STREQ(filename, "-")) {
|
||||
have_read_stdin = 1;
|
||||
fp = stdin;
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
perror_msg("%s", filename);
|
||||
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (fp != stdin && fclose(fp) == EOF) {
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int md5_check(const char *checkfile_name)
|
||||
{
|
||||
FILE *checkfile_stream;
|
||||
int n_properly_formated_lines = 0;
|
||||
int n_mismatched_checksums = 0;
|
||||
int n_open_or_read_failures = 0;
|
||||
unsigned char md5buffer[16];
|
||||
size_t line_number;
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (STREQ(checkfile_name, "-")) {
|
||||
have_read_stdin = 1;
|
||||
checkfile_stream = stdin;
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
perror_msg("%s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
|
||||
do {
|
||||
char *filename;
|
||||
int binary;
|
||||
unsigned char *md5num;
|
||||
int line_length;
|
||||
|
||||
++line_number;
|
||||
|
||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||
line_length = strlen(line);
|
||||
|
||||
if (line_length <= 0 || line==NULL)
|
||||
break;
|
||||
|
||||
/* Ignore comment lines, which begin with a '#' character. */
|
||||
if (line[0] == '#')
|
||||
continue;
|
||||
|
||||
/* Remove any trailing newline. */
|
||||
if (line[line_length - 1] == '\n')
|
||||
line[--line_length] = '\0';
|
||||
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line",
|
||||
checkfile_name, (unsigned long) line_number);
|
||||
}
|
||||
} else {
|
||||
static const char bin2hex[] = {
|
||||
'0', '1', '2', '3',
|
||||
'4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b',
|
||||
'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
++n_properly_formated_lines;
|
||||
|
||||
if (md5_file(filename, binary, md5buffer)) {
|
||||
++n_open_or_read_failures;
|
||||
if (!status_only) {
|
||||
printf("%s: FAILED open or read\n", filename);
|
||||
fflush(stdout);
|
||||
}
|
||||
} else {
|
||||
size_t cnt;
|
||||
/* Compare generated binary number with text representation
|
||||
in check file. Ignore case of hex digits. */
|
||||
for (cnt = 0; cnt < 16; ++cnt) {
|
||||
if (TOLOWER(md5num[2 * cnt])
|
||||
!= bin2hex[md5buffer[cnt] >> 4]
|
||||
|| (TOLOWER(md5num[2 * cnt + 1])
|
||||
!= (bin2hex[md5buffer[cnt] & 0xf])))
|
||||
break;
|
||||
}
|
||||
if (cnt != 16)
|
||||
++n_mismatched_checksums;
|
||||
|
||||
if (!status_only) {
|
||||
printf("%s: %s\n", filename,
|
||||
(cnt != 16 ? "FAILED" : "OK"));
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||
|
||||
if (ferror(checkfile_stream)) {
|
||||
error_msg("%s: read error", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
|
||||
perror_msg("md5sum: %s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_properly_formated_lines == 0) {
|
||||
/* Warn if no tests are found. */
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found",
|
||||
checkfile_name);
|
||||
return FALSE;
|
||||
} else {
|
||||
if (!status_only) {
|
||||
int n_computed_checkums = (n_properly_formated_lines
|
||||
- n_open_or_read_failures);
|
||||
|
||||
if (n_open_or_read_failures > 0) {
|
||||
error_msg("WARNING: %d of %d listed files could not be read",
|
||||
n_open_or_read_failures, n_properly_formated_lines);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0) {
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match",
|
||||
n_mismatched_checksums, n_computed_checkums);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ((n_properly_formated_lines > 0 && n_mismatched_checksums == 0
|
||||
&& n_open_or_read_failures == 0) ? 0 : 1);
|
||||
}
|
||||
|
||||
int md5sum_main(int argc,
|
||||
char **argv)
|
||||
{
|
||||
unsigned char md5buffer[16];
|
||||
int do_check = 0;
|
||||
int opt;
|
||||
char **string = NULL;
|
||||
size_t n_strings = 0;
|
||||
size_t err = 0;
|
||||
int file_type_specified = 0;
|
||||
int binary = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "g:bcstw")) != -1) {
|
||||
switch (opt) {
|
||||
case 'g': { /* read a string */
|
||||
if (string == NULL)
|
||||
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
|
||||
|
||||
string[n_strings++] = optarg;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'b': /* read files in binary mode */
|
||||
file_type_specified = 1;
|
||||
binary = 1;
|
||||
break;
|
||||
|
||||
case 'c': /* check MD5 sums against given list */
|
||||
do_check = 1;
|
||||
break;
|
||||
|
||||
case 's': /* don't output anything, status code shows success */
|
||||
status_only = 1;
|
||||
warn = 0;
|
||||
break;
|
||||
|
||||
case 't': /* read files in text mode (default) */
|
||||
file_type_specified = 1;
|
||||
binary = 0;
|
||||
break;
|
||||
|
||||
case 'w': /* warn about improperly formated MD5 checksum lines */
|
||||
status_only = 0;
|
||||
warn = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (file_type_specified && do_check) {
|
||||
error_msg_and_die("the -b and -t options are meaningless when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0 && do_check) {
|
||||
error_msg_and_die("the -g and -c options are mutually exclusive");
|
||||
}
|
||||
|
||||
if (status_only && !do_check) {
|
||||
error_msg_and_die("the -s option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (warn && !do_check) {
|
||||
error_msg_and_die("the -w option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0) {
|
||||
size_t i;
|
||||
|
||||
if (optind < argc) {
|
||||
error_msg_and_die("no files may be specified when using -g");
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i) {
|
||||
size_t cnt;
|
||||
md5_buffer (string[i], strlen (string[i]), md5buffer);
|
||||
|
||||
for (cnt = 0; cnt < 16; ++cnt)
|
||||
printf ("%02x", md5buffer[cnt]);
|
||||
|
||||
printf (" \"%s\"\n", string[i]);
|
||||
}
|
||||
} else if (do_check) {
|
||||
if (optind + 1 < argc) {
|
||||
error_msg("only one argument may be specified when using -c");
|
||||
}
|
||||
|
||||
err = md5_check ((optind == argc) ? "-" : argv[optind]);
|
||||
} else {
|
||||
if (optind == argc)
|
||||
argv[argc++] = "-";
|
||||
|
||||
for (; optind < argc; ++optind) {
|
||||
int fail;
|
||||
char *file = argv[optind];
|
||||
|
||||
fail = md5_file (file, binary, md5buffer);
|
||||
err |= fail;
|
||||
if (!fail && STREQ(file, "-")) {
|
||||
size_t i;
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
putchar ('\n');
|
||||
} else if (!fail) {
|
||||
size_t i;
|
||||
/* Output a leading backslash if the file name contains
|
||||
a newline or backslash. */
|
||||
if (strchr (file, '\n') || strchr (file, '\\'))
|
||||
putchar ('\\');
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
|
||||
putchar (' ');
|
||||
if (binary)
|
||||
putchar ('*');
|
||||
else
|
||||
putchar (' ');
|
||||
|
||||
/* Translate each NEWLINE byte to the string, "\\n",
|
||||
and each backslash to "\\\\". */
|
||||
for (i = 0; i < strlen (file); ++i) {
|
||||
switch (file[i]) {
|
||||
case '\n':
|
||||
fputs ("\\n", stdout);
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
fputs ("\\\\", stdout);
|
||||
break;
|
||||
|
||||
default:
|
||||
putchar (file[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF) {
|
||||
error_msg_and_die("write error");
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||
error_msg_and_die("standard input");
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+65
-64
@@ -1,8 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mkdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,81 +21,82 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n"
|
||||
"Create the DIRECTORY(ies), if they do not already exist\n\n"
|
||||
"-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
|
||||
"-p\tno error if existing, make parent directories as needed\n";
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#define bb_need_name_too_long
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
static int parentFlag = FALSE;
|
||||
static mode_t mode = 777;
|
||||
static mode_t mode = 0777;
|
||||
|
||||
|
||||
extern int mkdir_main(int argc, char **argv)
|
||||
{
|
||||
int i=FALSE;
|
||||
argc--;
|
||||
argv++;
|
||||
int i = FALSE;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && **argv == '-') {
|
||||
while (i==FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'm':
|
||||
if (--argc == 0)
|
||||
usage( mkdir_usage);
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if ( parse_mode(*(++argv), &mode) == FALSE ) {
|
||||
fprintf(stderr, "Unknown mode: %s\n", *argv);
|
||||
exit( FALSE);
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && **argv == '-') {
|
||||
while (i == FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'm':
|
||||
if (--argc == 0)
|
||||
show_usage();
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if (parse_mode(*(++argv), &mode) == FALSE) {
|
||||
error_msg_and_die("Unknown mode: %s", *argv);
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
umask(0);
|
||||
i = TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
parentFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
umask(0);
|
||||
i=TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
parentFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage( mkdir_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
if (argc < 1) {
|
||||
usage( mkdir_usage);
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
int status;
|
||||
struct stat statBuf;
|
||||
status=stat(*argv, &statBuf);
|
||||
if (status != -1 && status != ENOENT ) {
|
||||
fprintf(stderr, "%s: File exists\n", *argv);
|
||||
exit( FALSE);
|
||||
if (argc < 1) {
|
||||
show_usage();
|
||||
}
|
||||
if (parentFlag == TRUE)
|
||||
createPath(*argv, mode);
|
||||
else {
|
||||
if (mkdir (*argv, mode) != 0) {
|
||||
perror(*argv);
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
int status;
|
||||
struct stat statBuf;
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (strlen(*argv) > BUFSIZ - 1) {
|
||||
error_msg_and_die(name_too_long);
|
||||
}
|
||||
strcpy(buf, *argv);
|
||||
status = stat(buf, &statBuf);
|
||||
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
|
||||
error_msg_and_die("%s: File exists", buf);
|
||||
}
|
||||
if (parentFlag == TRUE) {
|
||||
strcat(buf, "/");
|
||||
create_path(buf, mode);
|
||||
} else {
|
||||
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
|
||||
perror_msg_and_die(buf);
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mkfifo implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int mkfifo_main(int argc, char **argv)
|
||||
{
|
||||
char *thisarg;
|
||||
mode_t mode = 0666;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
show_usage();
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
case 'm':
|
||||
argc--;
|
||||
argv++;
|
||||
parse_mode(*argv, &mode);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 1 || *argv[0] == '-')
|
||||
show_usage();
|
||||
if (mkfifo(*argv, mode) < 0)
|
||||
perror_msg_and_die("mkfifo");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+47
-27
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mknod implementation for busybox
|
||||
*
|
||||
@@ -19,28 +20,48 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
|
||||
"\tMake special files.\n"
|
||||
"\n"
|
||||
"\tb:\tMake a block (buffered) device.\n"
|
||||
"\tc or u:\tMake a character (un-buffered) device.\n"
|
||||
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
|
||||
|
||||
int
|
||||
mknod_main(int argc, char** argv)
|
||||
int mknod_main(int argc, char **argv)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
dev_t dev = 0;
|
||||
char *thisarg;
|
||||
mode_t mode = 0;
|
||||
mode_t perm = 0666;
|
||||
dev_t dev = 0;
|
||||
|
||||
switch(argv[2][0]) {
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
break;
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
case 'm':
|
||||
argc--;
|
||||
argv++;
|
||||
parse_mode(*argv, &perm);
|
||||
umask(0);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc != 4 && argc != 2) {
|
||||
show_usage();
|
||||
}
|
||||
switch (argv[1][0]) {
|
||||
case 'c':
|
||||
case 'u':
|
||||
mode = S_IFCHR;
|
||||
@@ -50,23 +71,22 @@ mknod_main(int argc, char** argv)
|
||||
break;
|
||||
case 'p':
|
||||
mode = S_IFIFO;
|
||||
if (argc!=2) {
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage (mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if ( mode == S_IFCHR || mode == S_IFBLK ) {
|
||||
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
|
||||
if ( argc != 5 ) {
|
||||
usage (mknod_usage);
|
||||
}
|
||||
if (mode == S_IFCHR || mode == S_IFBLK) {
|
||||
dev = (atoi(argv[2]) << 8) | atoi(argv[3]);
|
||||
}
|
||||
|
||||
mode |= 0666;
|
||||
mode |= perm;
|
||||
|
||||
if ( mknod(argv[1], mode, dev) != 0 ) {
|
||||
perror(argv[1]);
|
||||
return( FALSE);
|
||||
}
|
||||
return( TRUE);
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
perror_msg_and_die("%s", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Mini mv implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
static const char mv_usage[] = "mv SOURCE DEST\n"
|
||||
" or: mv SOURCE... DIRECTORY\n"
|
||||
"Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n";
|
||||
|
||||
|
||||
static const char *srcName;
|
||||
static const char *destName;
|
||||
static const char *skipName;
|
||||
static int dirFlag = FALSE;
|
||||
|
||||
|
||||
extern int mv_main(int argc, char **argv)
|
||||
{
|
||||
char newdestName[NAME_MAX];
|
||||
|
||||
if (argc < 3) {
|
||||
usage (mv_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
destName = argv[argc - 1];
|
||||
dirFlag = isDirectory(destName);
|
||||
|
||||
if ((argc > 3) && dirFlag==FALSE) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- > 1) {
|
||||
srcName = *(argv++);
|
||||
skipName = strrchr(srcName, '/');
|
||||
if (skipName)
|
||||
skipName++;
|
||||
strcpy(newdestName, destName);
|
||||
if (dirFlag==TRUE) {
|
||||
strcat(newdestName, "/");
|
||||
if ( skipName != NULL)
|
||||
strcat(newdestName, strstr(srcName, skipName));
|
||||
}
|
||||
if (copyFile(srcName, newdestName, FALSE, FALSE) == FALSE) {
|
||||
exit( FALSE);
|
||||
}
|
||||
if (unlink (srcName) < 0) {
|
||||
perror (srcName);
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
+280
-335
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* printf - format and print data
|
||||
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
@@ -42,26 +43,23 @@
|
||||
to convert all of the given arguments.
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
|
||||
|
||||
// 19990508 Busy Boxed! Dave Cinege
|
||||
|
||||
#include "internal.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <libintl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
static const int S_IFMT = 0170000;
|
||||
#endif
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
@@ -84,11 +82,11 @@
|
||||
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
#endif
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
#endif
|
||||
|
||||
@@ -121,409 +119,356 @@
|
||||
#define hextobin(c) ((c)>='a'&&(c)<='f' ? (c)-'a'+10 : (c)>='A'&&(c)<='F' ? (c)-'A'+10 : (c)-'0')
|
||||
#define octtobin(c) ((c) - '0')
|
||||
|
||||
char *xmalloc ();
|
||||
static double xstrtod __P((char *s));
|
||||
static int print_esc __P((char *escstart));
|
||||
static int print_formatted __P((char *format, int argc, char **argv));
|
||||
static long xstrtol __P((char *s));
|
||||
static unsigned long xstrtoul __P((char *s));
|
||||
static void print_direc
|
||||
__P(
|
||||
|
||||
static double xstrtod __P ((char *s));
|
||||
static int print_esc __P ((char *escstart));
|
||||
static int print_formatted __P ((char *format, int argc, char **argv));
|
||||
static long xstrtol __P ((char *s));
|
||||
static unsigned long xstrtoul __P ((char *s));
|
||||
static void print_direc __P ((char *start, size_t length, int field_width, int precision, char *argument));
|
||||
static void print_esc_char __P ((int c));
|
||||
static void print_esc_string __P ((char *str));
|
||||
static void verify __P ((char *s, char *end));
|
||||
(char *start, size_t length, int field_width, int precision,
|
||||
char *argument));
|
||||
static void print_esc_char __P((int c));
|
||||
static void print_esc_string __P((char *str));
|
||||
static void verify __P((char *s, char *end));
|
||||
|
||||
/* The value to return to the calling program. */
|
||||
static int exit_status;
|
||||
|
||||
static const char printf_usage[] = "printf format [argument...]\n";
|
||||
|
||||
int
|
||||
printf_main(int argc, char** argv)
|
||||
int printf_main(int argc, char **argv)
|
||||
{
|
||||
char *format;
|
||||
int args_used;
|
||||
char *format;
|
||||
int args_used;
|
||||
|
||||
exit_status = 0;
|
||||
if ( **(argv+1) == '-' ) {
|
||||
usage (printf_usage);
|
||||
}
|
||||
exit_status = 0;
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
format = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
format = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
do
|
||||
{
|
||||
args_used = print_formatted (format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
}
|
||||
while (args_used > 0 && argc > 0);
|
||||
do {
|
||||
args_used = print_formatted(format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
}
|
||||
while (args_used > 0 && argc > 0);
|
||||
|
||||
/*
|
||||
if (argc > 0)
|
||||
fprintf(stderr, "excess args ignored");
|
||||
*/
|
||||
|
||||
exit (exit_status);
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
|
||||
arguments to any `%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
|
||||
static int
|
||||
print_formatted (char *format, int argc, char **argv)
|
||||
static int print_formatted(char *format, int argc, char **argv)
|
||||
{
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
char *f; /* Pointer into `format'. */
|
||||
char *direc_start; /* Start of % directive. */
|
||||
size_t direc_length; /* Length of % directive. */
|
||||
int field_width; /* Arg to first '*', or -1 if none. */
|
||||
int precision; /* Arg to second '*', or -1 if none. */
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
char *f; /* Pointer into `format'. */
|
||||
char *direc_start; /* Start of % directive. */
|
||||
size_t direc_length; /* Length of % directive. */
|
||||
int field_width; /* Arg to first '*', or -1 if none. */
|
||||
int precision; /* Arg to second '*', or -1 if none. */
|
||||
|
||||
for (f = format; *f; ++f)
|
||||
{
|
||||
switch (*f)
|
||||
{
|
||||
case '%':
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
field_width = precision = -1;
|
||||
if (*f == '%')
|
||||
{
|
||||
putchar ('%');
|
||||
break;
|
||||
}
|
||||
if (*f == 'b')
|
||||
{
|
||||
if (argc > 0)
|
||||
{
|
||||
print_esc_string (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strchr ("-+ #", *f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
field_width = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
field_width = 0;
|
||||
}
|
||||
else
|
||||
while (ISDIGIT (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '.')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (*f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
precision = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
precision = 0;
|
||||
}
|
||||
else
|
||||
while (ISDIGIT (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == 'l' || *f == 'L' || *f == 'h')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
/*
|
||||
if (!strchr ("diouxXfeEgGcs", *f))
|
||||
fprintf(stderr, "%%%c: invalid directive", *f);
|
||||
*/
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
print_direc (direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
print_direc (direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
break;
|
||||
for (f = format; *f; ++f) {
|
||||
switch (*f) {
|
||||
case '%':
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
field_width = precision = -1;
|
||||
if (*f == '%') {
|
||||
putchar('%');
|
||||
break;
|
||||
}
|
||||
if (*f == 'b') {
|
||||
if (argc > 0) {
|
||||
print_esc_string(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strchr("-+ #", *f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
field_width = xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
field_width = 0;
|
||||
} else
|
||||
while (ISDIGIT(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '.') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
precision = xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
precision = 0;
|
||||
} else
|
||||
while (ISDIGIT(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == 'l' || *f == 'L' || *f == 'h') {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
/*
|
||||
if (!strchr ("diouxXfeEgGcs", *f))
|
||||
fprintf(stderr, "%%%c: invalid directive", *f);
|
||||
*/
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
f += print_esc (f);
|
||||
break;
|
||||
case '\\':
|
||||
f += print_esc(f);
|
||||
break;
|
||||
|
||||
default:
|
||||
putchar (*f);
|
||||
default:
|
||||
putchar(*f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return save_argc - argc;
|
||||
return save_argc - argc;
|
||||
}
|
||||
|
||||
/* Print a \ escape sequence starting at ESCSTART.
|
||||
Return the number of characters in the escape sequence
|
||||
besides the backslash. */
|
||||
|
||||
static int
|
||||
print_esc (char *escstart)
|
||||
static int print_esc(char *escstart)
|
||||
{
|
||||
register char *p = escstart + 1;
|
||||
int esc_value = 0; /* Value of \nnn escape. */
|
||||
int esc_length; /* Length of \nnn escape. */
|
||||
register char *p = escstart + 1;
|
||||
int esc_value = 0; /* Value of \nnn escape. */
|
||||
int esc_length; /* Length of \nnn escape. */
|
||||
|
||||
/* \0ooo and \xhhh escapes have maximum length of 3 chars. */
|
||||
if (*p == 'x')
|
||||
{
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && ISXDIGIT (*p);
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin (*p);
|
||||
/* \0ooo and \xhhh escapes have maximum length of 3 chars. */
|
||||
if (*p == 'x') {
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && ISXDIGIT(*p); ++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin(*p);
|
||||
/* if (esc_length == 0)
|
||||
fprintf(stderr, "missing hex in esc");
|
||||
*/
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if (*p == '0')
|
||||
{
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && isodigit (*p);
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octtobin (*p);
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if (strchr ("\"\\abcfnrtv", *p))
|
||||
print_esc_char (*p++);
|
||||
putchar(esc_value);
|
||||
} else if (*p == '0') {
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && isodigit(*p); ++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octtobin(*p);
|
||||
putchar(esc_value);
|
||||
} else if (strchr("\"\\abcfnrtv", *p))
|
||||
print_esc_char(*p++);
|
||||
/* else
|
||||
fprintf(stderr, "\\%c: invalid esc", *p);
|
||||
*/
|
||||
return p - escstart - 1;
|
||||
return p - escstart - 1;
|
||||
}
|
||||
|
||||
/* Output a single-character \ escape. */
|
||||
|
||||
static void
|
||||
print_esc_char (int c)
|
||||
static void print_esc_char(int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a': /* Alert. */
|
||||
putchar (7);
|
||||
break;
|
||||
case 'b': /* Backspace. */
|
||||
putchar (8);
|
||||
break;
|
||||
case 'c': /* Cancel the rest of the output. */
|
||||
exit (0);
|
||||
break;
|
||||
case 'f': /* Form feed. */
|
||||
putchar (12);
|
||||
break;
|
||||
case 'n': /* New line. */
|
||||
putchar (10);
|
||||
break;
|
||||
case 'r': /* Carriage return. */
|
||||
putchar (13);
|
||||
break;
|
||||
case 't': /* Horizontal tab. */
|
||||
putchar (9);
|
||||
break;
|
||||
case 'v': /* Vertical tab. */
|
||||
putchar (11);
|
||||
break;
|
||||
default:
|
||||
putchar (c);
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'a': /* Alert. */
|
||||
putchar(7);
|
||||
break;
|
||||
case 'b': /* Backspace. */
|
||||
putchar(8);
|
||||
break;
|
||||
case 'c': /* Cancel the rest of the output. */
|
||||
exit(0);
|
||||
break;
|
||||
case 'f': /* Form feed. */
|
||||
putchar(12);
|
||||
break;
|
||||
case 'n': /* New line. */
|
||||
putchar(10);
|
||||
break;
|
||||
case 'r': /* Carriage return. */
|
||||
putchar(13);
|
||||
break;
|
||||
case 't': /* Horizontal tab. */
|
||||
putchar(9);
|
||||
break;
|
||||
case 'v': /* Vertical tab. */
|
||||
putchar(11);
|
||||
break;
|
||||
default:
|
||||
putchar(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print string STR, evaluating \ escapes. */
|
||||
|
||||
static void
|
||||
print_esc_string (char *str)
|
||||
static void print_esc_string(char *str)
|
||||
{
|
||||
for (; *str; str++)
|
||||
if (*str == '\\')
|
||||
str += print_esc (str);
|
||||
else
|
||||
putchar (*str);
|
||||
for (; *str; str++)
|
||||
if (*str == '\\')
|
||||
str += print_esc(str);
|
||||
else
|
||||
putchar(*str);
|
||||
}
|
||||
|
||||
static void
|
||||
print_direc (char *start, size_t length, int field_width, int precision, char *argument)
|
||||
print_direc(char *start, size_t length, int field_width, int precision,
|
||||
char *argument)
|
||||
{
|
||||
char *p; /* Null-terminated copy of % directive. */
|
||||
char *p; /* Null-terminated copy of % directive. */
|
||||
|
||||
p = xmalloc ((unsigned) (length + 1));
|
||||
strncpy (p, start, length);
|
||||
p[length] = 0;
|
||||
p = xmalloc((unsigned) (length + 1));
|
||||
strncpy(p, start, length);
|
||||
p[length] = 0;
|
||||
|
||||
switch (p[length - 1])
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtol (argument));
|
||||
else
|
||||
printf (p, precision, xstrtol (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtol (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtol (argument));
|
||||
}
|
||||
break;
|
||||
switch (p[length - 1]) {
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtol(argument));
|
||||
else
|
||||
printf(p, precision, xstrtol(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtol(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtol(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtoul (argument));
|
||||
else
|
||||
printf (p, precision, xstrtoul (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtoul (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtoul (argument));
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtoul(argument));
|
||||
else
|
||||
printf(p, precision, xstrtoul(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtoul(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtoul(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtod (argument));
|
||||
else
|
||||
printf (p, precision, xstrtod (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtod (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtod (argument));
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtod(argument));
|
||||
else
|
||||
printf(p, precision, xstrtod(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtod(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtod(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf (p, *argument);
|
||||
break;
|
||||
case 'c':
|
||||
printf(p, *argument);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, argument);
|
||||
else
|
||||
printf (p, precision, argument);
|
||||
case 's':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, argument);
|
||||
else
|
||||
printf(p, precision, argument);
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, argument);
|
||||
else
|
||||
printf(p, field_width, precision, argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, argument);
|
||||
else
|
||||
printf (p, field_width, precision, argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
free (p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
xstrtoul (char *s)
|
||||
static unsigned long xstrtoul(char *s)
|
||||
{
|
||||
char *end;
|
||||
unsigned long val;
|
||||
char *end;
|
||||
unsigned long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul (s, &end, 0);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtoul(s, &end, 0);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static long
|
||||
xstrtol (char *s)
|
||||
static long xstrtol(char *s)
|
||||
{
|
||||
char *end;
|
||||
long val;
|
||||
char *end;
|
||||
long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtol (s, &end, 0);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtol(s, &end, 0);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static double
|
||||
xstrtod (char *s)
|
||||
static double xstrtod(char *s)
|
||||
{
|
||||
char *end;
|
||||
double val;
|
||||
char *end;
|
||||
double val;
|
||||
|
||||
errno = 0;
|
||||
val = strtod (s, &end);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtod(s, &end);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
verify (char *s, char *end)
|
||||
static void verify(char *s, char *end)
|
||||
{
|
||||
if (errno)
|
||||
{
|
||||
fprintf(stderr, "%s", s);
|
||||
exit_status = 1;
|
||||
}
|
||||
else if (*end)
|
||||
{
|
||||
/*
|
||||
if (s == end)
|
||||
fprintf(stderr, "%s: expected numeric", s);
|
||||
else
|
||||
fprintf(stderr, "%s: not completely converted", s);
|
||||
*/
|
||||
exit_status = 1;
|
||||
}
|
||||
if (errno) {
|
||||
fprintf(stderr, "%s", s);
|
||||
exit_status = 1;
|
||||
} else if (*end) {
|
||||
/*
|
||||
if (s == end)
|
||||
fprintf(stderr, "%s: expected numeric", s);
|
||||
else
|
||||
fprintf(stderr, "%s: not completely converted", s);
|
||||
*/
|
||||
exit_status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-10
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini pwd implementation for busybox
|
||||
*
|
||||
@@ -20,20 +21,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
pwd_main(int argc, char * * argv)
|
||||
extern int pwd_main(int argc, char **argv)
|
||||
{
|
||||
char buf[NAME_MAX];
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if ( getcwd(buf, sizeof(buf)) == NULL ) {
|
||||
perror("get working directory");
|
||||
exit( FALSE);
|
||||
}
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
perror_msg_and_die("getcwd");
|
||||
|
||||
printf("%s\n", buf);
|
||||
exit( TRUE);
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+96
-47
@@ -1,10 +1,15 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rm implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* INTERACTIVE feature Copyright (C) 2001 by Alcove
|
||||
* written by Christophe Boyanique <Christophe.Boyanique@fr.alcove.com>
|
||||
* for Ipanema Technologies
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -21,73 +26,117 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
|
||||
static const char* rm_usage = "rm [OPTION]... FILE...\n"
|
||||
"Remove (unlink) the FILE(s).\n\n"
|
||||
"\t-f\tremove existing destinations, never prompt\n"
|
||||
"\t-r\tremove the contents of directories recursively\n";
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int forceFlag = FALSE;
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
static int interactiveFlag = FALSE;
|
||||
#endif
|
||||
static const char *srcName;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (unlink( fileName) < 0 ) {
|
||||
perror( fileName);
|
||||
return ( FALSE);
|
||||
}
|
||||
return ( TRUE);
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
if (interactiveFlag == TRUE) {
|
||||
printf("rm: remove `%s'? ", fileName);
|
||||
if (ask_confirmation() == 0)
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
if (unlink(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static int dirAction(const char *fileName, struct stat* statbuf)
|
||||
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (rmdir( fileName) < 0 ) {
|
||||
perror( fileName);
|
||||
return ( FALSE);
|
||||
}
|
||||
return ( TRUE);
|
||||
if (recursiveFlag == FALSE) {
|
||||
errno = EISDIR;
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
if (interactiveFlag == TRUE) {
|
||||
printf("rm: remove directory `%s'? ", fileName);
|
||||
if (ask_confirmation() == 0)
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
extern int rm_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int stopIt=FALSE;
|
||||
struct stat statbuf;
|
||||
|
||||
if (argc < 2) {
|
||||
usage( rm_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 'r':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
forceFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage( rm_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
srcName = *(argv++);
|
||||
if (recursiveAction( srcName, recursiveFlag, TRUE, TRUE,
|
||||
fileAction, dirAction) == FALSE) {
|
||||
exit( FALSE);
|
||||
/* Parse any options */
|
||||
while (argc > 0 && stopIt == FALSE) {
|
||||
if (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
forceFlag = TRUE;
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
interactiveFlag = FALSE;
|
||||
#endif
|
||||
break;
|
||||
case 'i':
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
interactiveFlag = TRUE;
|
||||
#endif
|
||||
break;
|
||||
case '-':
|
||||
stopIt = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit( TRUE);
|
||||
|
||||
if (argc < 1 && forceFlag == FALSE) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
srcName = *(argv++);
|
||||
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
|
||||
&& errno == ENOENT) {
|
||||
/* do not reports errors for non-existent files if -f, just skip them */
|
||||
} else {
|
||||
if (recursive_action(srcName, recursiveFlag, FALSE,
|
||||
TRUE, fileAction, dirAction, NULL) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
+15
-12
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rmdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,22 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
if ( argc==1 || **(argv+1) == '-' ) {
|
||||
usage( "rmdir [OPTION]... DIRECTORY...\nRemove the DIRECTORY(ies), if they are empty.");
|
||||
}
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
while (--argc > 0) {
|
||||
if ( rmdir(*(++argv)) == -1 ) {
|
||||
fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
|
||||
exit(FALSE);
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
show_usage();
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
perror_msg("%s", *argv);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(TRUE);
|
||||
return status;
|
||||
}
|
||||
+10
-13
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sleep implementation for busybox
|
||||
*
|
||||
@@ -20,22 +21,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char sleep_usage[] = " NUMBER\n"
|
||||
"Pause for NUMBER seconds.\n";
|
||||
|
||||
extern int
|
||||
sleep_main(int argc, char * * argv)
|
||||
extern int sleep_main(int argc, char **argv)
|
||||
{
|
||||
if ( (argc < 2) || (**(argv+1) == '-') ) {
|
||||
usage( sleep_usage );
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if ( sleep(atoi(*(++argv))) != 0 ) {
|
||||
perror( "sleep");
|
||||
exit (FALSE);
|
||||
} else
|
||||
exit (TRUE);
|
||||
if (sleep(atoi(*(++argv))) != 0)
|
||||
perror_msg_and_die("sleep");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sort implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int compare_ascii(const void *x, const void *y)
|
||||
{
|
||||
return strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
static int compare_numeric(const void *x, const void *y)
|
||||
{
|
||||
return atoi(*(char **)x) - atoi(*(char **)y);
|
||||
}
|
||||
|
||||
int sort_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line, **lines = NULL;
|
||||
int i, opt, nlines = 0;
|
||||
int (*compare)(const void *, const void *) = compare_ascii;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
int reverse = FALSE;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "nr")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* read the input */
|
||||
for (i = optind; i == optind || i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = xfopen(argv[i], "r");
|
||||
|
||||
while ((line = get_line_from_file(fp)) != NULL) {
|
||||
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
|
||||
lines[nlines++] = line;
|
||||
}
|
||||
}
|
||||
|
||||
/* sort it */
|
||||
qsort(lines, nlines, sizeof(char *), compare);
|
||||
|
||||
/* print it */
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
if (reverse)
|
||||
for (i = nlines - 1; 0 <= i; i--)
|
||||
fputs(lines[i], stdout);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < nlines; i++)
|
||||
fputs(lines[i], stdout);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+1443
File diff suppressed because it is too large.
Load diff
+9
-8
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sync implementation for busybox
|
||||
*
|
||||
@@ -20,15 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
sync_main(int argc, char * * argv)
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if ( argc>1 && **(argv+1) == '-' ) {
|
||||
usage( "sync\nWrite all buffered filesystem blocks to disk.\n");
|
||||
}
|
||||
exit( sync());
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
show_usage();
|
||||
sync();
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tail implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const struct suffix_mult tail_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1048576 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const int BYTES = 0;
|
||||
static const int LINES = 1;
|
||||
|
||||
static char *tailbuf;
|
||||
static int taillen;
|
||||
static int newline;
|
||||
|
||||
static void tailbuf_append(char *buf, int len)
|
||||
{
|
||||
tailbuf = xrealloc(tailbuf, taillen + len);
|
||||
memcpy(tailbuf + taillen, buf, len);
|
||||
taillen += len;
|
||||
}
|
||||
|
||||
static void tailbuf_trunc()
|
||||
{
|
||||
char *s;
|
||||
s = memchr(tailbuf, '\n', taillen);
|
||||
memmove(tailbuf, s + 1, taillen - ((s + 1) - tailbuf));
|
||||
taillen -= (s + 1) - tailbuf;
|
||||
newline = 0;
|
||||
}
|
||||
|
||||
int tail_main(int argc, char **argv)
|
||||
{
|
||||
int from_top = 0, units = LINES, count = 10, sleep_period = 1;
|
||||
int show_headers = 0, hide_headers = 0, follow = 0;
|
||||
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
|
||||
char *s, *start, *end, buf[BUFSIZ];
|
||||
int i, opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
case 'c':
|
||||
units = BYTES;
|
||||
/* FALLS THROUGH */
|
||||
#endif
|
||||
case 'n':
|
||||
count = parse_number(optarg, tail_suffixes);
|
||||
if (count < 0)
|
||||
count = -count;
|
||||
if (optarg[0] == '+')
|
||||
from_top = 1;
|
||||
break;
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
case 'q':
|
||||
hide_headers = 1;
|
||||
break;
|
||||
case 's':
|
||||
sleep_period = parse_number(optarg, 0);
|
||||
break;
|
||||
case 'v':
|
||||
show_headers = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* open all the files */
|
||||
fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
|
||||
if (argc == optind) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-") == 0) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[i] = "standard input";
|
||||
} else if ((fds[nfiles++] = open(argv[i], O_RDONLY)) < 0) {
|
||||
perror_msg("%s", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
/* tail the files */
|
||||
if (!from_top && units == BYTES)
|
||||
tailbuf = xmalloc(count);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
seen = 0;
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
|
||||
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (from_top) {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (units == BYTES) {
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else if (count - 1 <= seen + nread)
|
||||
nwrite = nread + seen - (count - 1);
|
||||
else
|
||||
nwrite = 0;
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else {
|
||||
nwrite = 0;
|
||||
for (s = memchr(buf, '\n', nread); s != NULL;
|
||||
s = memchr(s+1, '\n', nread - (s + 1 - buf))) {
|
||||
if (count - 1 <= ++seen) {
|
||||
nwrite = nread - (s + 1 - buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (full_write(STDOUT_FILENO, buf + nread - nwrite,
|
||||
nwrite) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (units == BYTES) {
|
||||
if (nread < count) {
|
||||
memmove(tailbuf, tailbuf + nread, count - nread);
|
||||
memcpy(tailbuf + count - nread, buf, nread);
|
||||
} else {
|
||||
memcpy(tailbuf, buf + nread - count, count);
|
||||
}
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
for (start = buf, end = memchr(buf, '\n', nread);
|
||||
end != NULL; start = end+1,
|
||||
end = memchr(start, '\n', nread - (start - buf))) {
|
||||
if (newline && count <= seen)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, end - start + 1);
|
||||
seen++;
|
||||
newline = 1;
|
||||
}
|
||||
if (newline && count <= seen && nread - (start - buf) > 0)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, nread - (start - buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (!from_top && units == BYTES) {
|
||||
if (count < seen)
|
||||
seen = count;
|
||||
if (full_write(STDOUT_FILENO, tailbuf + count - seen, seen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!from_top && units == LINES) {
|
||||
if (full_write(STDOUT_FILENO, tailbuf, taillen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
taillen = 0;
|
||||
}
|
||||
|
||||
while (follow) {
|
||||
sleep(sleep_period);
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
|
||||
if ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("\n==> %s <==\n", argv[optind + i]);
|
||||
|
||||
do {
|
||||
full_write(STDOUT_FILENO, buf, nread);
|
||||
} while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0);
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
tee_main(int argc, char **argv)
|
||||
{
|
||||
char *mode = "w";
|
||||
int c, i, status = 0, nfiles = 0;
|
||||
FILE **files;
|
||||
|
||||
while ((c = getopt(argc, argv, "a")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
mode = "a";
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
|
||||
files[nfiles++] = stdout;
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = getchar()) != EOF)
|
||||
for (i = 0; i < nfiles; i++)
|
||||
putc(c, files[i]);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,582 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* test implementation for busybox
|
||||
*
|
||||
* Copyright (c) by a whole pile of folks:
|
||||
*
|
||||
* test(1); version 7-like -- author Erik Baalbergen
|
||||
* modified by Eric Gisin to be used as built-in.
|
||||
* modified by Arnold Robbins to add SVR3 compatibility
|
||||
* (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
|
||||
* modified by J.T. Conklin for NetBSD.
|
||||
* modified by Herbert Xu to be used as built-in in ash.
|
||||
* modified by Erik Andersen <andersee@debian.org> to be used
|
||||
* in busybox.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice states:
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_help
|
||||
#include "messages.c"
|
||||
|
||||
/* test(1) accepts the following grammar:
|
||||
oexpr ::= aexpr | aexpr "-o" oexpr ;
|
||||
aexpr ::= nexpr | nexpr "-a" aexpr ;
|
||||
nexpr ::= primary | "!" primary
|
||||
primary ::= unary-operator operand
|
||||
| operand binary-operator operand
|
||||
| operand
|
||||
| "(" oexpr ")"
|
||||
;
|
||||
unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
|
||||
"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
|
||||
|
||||
binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
|
||||
"-nt"|"-ot"|"-ef";
|
||||
operand ::= <any legal UNIX file name>
|
||||
*/
|
||||
|
||||
enum token {
|
||||
EOI,
|
||||
FILRD,
|
||||
FILWR,
|
||||
FILEX,
|
||||
FILEXIST,
|
||||
FILREG,
|
||||
FILDIR,
|
||||
FILCDEV,
|
||||
FILBDEV,
|
||||
FILFIFO,
|
||||
FILSOCK,
|
||||
FILSYM,
|
||||
FILGZ,
|
||||
FILTT,
|
||||
FILSUID,
|
||||
FILSGID,
|
||||
FILSTCK,
|
||||
FILNT,
|
||||
FILOT,
|
||||
FILEQ,
|
||||
FILUID,
|
||||
FILGID,
|
||||
STREZ,
|
||||
STRNZ,
|
||||
STREQ,
|
||||
STRNE,
|
||||
STRLT,
|
||||
STRGT,
|
||||
INTEQ,
|
||||
INTNE,
|
||||
INTGE,
|
||||
INTGT,
|
||||
INTLE,
|
||||
INTLT,
|
||||
UNOT,
|
||||
BAND,
|
||||
BOR,
|
||||
LPAREN,
|
||||
RPAREN,
|
||||
OPERAND
|
||||
};
|
||||
|
||||
enum token_types {
|
||||
UNOP,
|
||||
BINOP,
|
||||
BUNOP,
|
||||
BBINOP,
|
||||
PAREN
|
||||
};
|
||||
|
||||
struct t_op {
|
||||
const char *op_text;
|
||||
short op_num, op_type;
|
||||
} const ops [] = {
|
||||
{"-r", FILRD, UNOP},
|
||||
{"-w", FILWR, UNOP},
|
||||
{"-x", FILEX, UNOP},
|
||||
{"-e", FILEXIST,UNOP},
|
||||
{"-f", FILREG, UNOP},
|
||||
{"-d", FILDIR, UNOP},
|
||||
{"-c", FILCDEV,UNOP},
|
||||
{"-b", FILBDEV,UNOP},
|
||||
{"-p", FILFIFO,UNOP},
|
||||
{"-u", FILSUID,UNOP},
|
||||
{"-g", FILSGID,UNOP},
|
||||
{"-k", FILSTCK,UNOP},
|
||||
{"-s", FILGZ, UNOP},
|
||||
{"-t", FILTT, UNOP},
|
||||
{"-z", STREZ, UNOP},
|
||||
{"-n", STRNZ, UNOP},
|
||||
{"-h", FILSYM, UNOP}, /* for backwards compat */
|
||||
{"-O", FILUID, UNOP},
|
||||
{"-G", FILGID, UNOP},
|
||||
{"-L", FILSYM, UNOP},
|
||||
{"-S", FILSOCK,UNOP},
|
||||
{"=", STREQ, BINOP},
|
||||
{"!=", STRNE, BINOP},
|
||||
{"<", STRLT, BINOP},
|
||||
{">", STRGT, BINOP},
|
||||
{"-eq", INTEQ, BINOP},
|
||||
{"-ne", INTNE, BINOP},
|
||||
{"-ge", INTGE, BINOP},
|
||||
{"-gt", INTGT, BINOP},
|
||||
{"-le", INTLE, BINOP},
|
||||
{"-lt", INTLT, BINOP},
|
||||
{"-nt", FILNT, BINOP},
|
||||
{"-ot", FILOT, BINOP},
|
||||
{"-ef", FILEQ, BINOP},
|
||||
{"!", UNOT, BUNOP},
|
||||
{"-a", BAND, BBINOP},
|
||||
{"-o", BOR, BBINOP},
|
||||
{"(", LPAREN, PAREN},
|
||||
{")", RPAREN, PAREN},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
static char **t_wp;
|
||||
static struct t_op const *t_wp_op;
|
||||
static gid_t *group_array = NULL;
|
||||
static int ngroups;
|
||||
|
||||
static enum token t_lex();
|
||||
static int oexpr();
|
||||
static int aexpr();
|
||||
static int nexpr();
|
||||
static int binop();
|
||||
static int primary();
|
||||
static int filstat();
|
||||
static int getn();
|
||||
static int newerf();
|
||||
static int olderf();
|
||||
static int equalf();
|
||||
static void syntax();
|
||||
static int test_eaccess();
|
||||
static int is_a_group_member();
|
||||
static void initialize_group_array();
|
||||
|
||||
extern int
|
||||
test_main(int argc, char** argv)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (strcmp(applet_name, "[") == 0) {
|
||||
if (strcmp(argv[--argc], "]"))
|
||||
error_msg_and_die("missing ]");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
switch (argc) {
|
||||
case 1:
|
||||
exit( 1);
|
||||
case 2:
|
||||
exit (*argv[1] == '\0');
|
||||
case 3:
|
||||
if (argv[1][0] == '!' && argv[1][1] == '\0') {
|
||||
exit (!(*argv[2] == '\0'));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (argv[1][0] != '!' || argv[1][1] != '\0') {
|
||||
if (t_lex(argv[2]),
|
||||
t_wp_op && t_wp_op->op_type == BINOP) {
|
||||
t_wp = &argv[1];
|
||||
exit (binop() == 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (argv[1][0] == '!' && argv[1][1] == '\0') {
|
||||
if (t_lex(argv[3]),
|
||||
t_wp_op && t_wp_op->op_type == BINOP) {
|
||||
t_wp = &argv[2];
|
||||
exit (!(binop() == 0));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
t_wp = &argv[1];
|
||||
res = !oexpr(t_lex(*t_wp));
|
||||
|
||||
if (*t_wp != NULL && *++t_wp != NULL)
|
||||
syntax(*t_wp, "unknown operand");
|
||||
|
||||
return( res);
|
||||
}
|
||||
|
||||
static void
|
||||
syntax(op, msg)
|
||||
char *op;
|
||||
char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
error_msg_and_die("%s: %s", op, msg);
|
||||
else
|
||||
error_msg_and_die("%s", msg);
|
||||
}
|
||||
|
||||
static int
|
||||
oexpr(n)
|
||||
enum token n;
|
||||
{
|
||||
int res;
|
||||
|
||||
res = aexpr(n);
|
||||
if (t_lex(*++t_wp) == BOR)
|
||||
return oexpr(t_lex(*++t_wp)) || res;
|
||||
t_wp--;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
aexpr(n)
|
||||
enum token n;
|
||||
{
|
||||
int res;
|
||||
|
||||
res = nexpr(n);
|
||||
if (t_lex(*++t_wp) == BAND)
|
||||
return aexpr(t_lex(*++t_wp)) && res;
|
||||
t_wp--;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
nexpr(n)
|
||||
enum token n; /* token */
|
||||
{
|
||||
if (n == UNOT)
|
||||
return !nexpr(t_lex(*++t_wp));
|
||||
return primary(n);
|
||||
}
|
||||
|
||||
static int
|
||||
primary(n)
|
||||
enum token n;
|
||||
{
|
||||
int res;
|
||||
|
||||
if (n == EOI)
|
||||
syntax(NULL, "argument expected");
|
||||
if (n == LPAREN) {
|
||||
res = oexpr(t_lex(*++t_wp));
|
||||
if (t_lex(*++t_wp) != RPAREN)
|
||||
syntax(NULL, "closing paren expected");
|
||||
return res;
|
||||
}
|
||||
if (t_wp_op && t_wp_op->op_type == UNOP) {
|
||||
/* unary expression */
|
||||
if (*++t_wp == NULL)
|
||||
syntax(t_wp_op->op_text, "argument expected");
|
||||
switch (n) {
|
||||
case STREZ:
|
||||
return strlen(*t_wp) == 0;
|
||||
case STRNZ:
|
||||
return strlen(*t_wp) != 0;
|
||||
case FILTT:
|
||||
return isatty(getn(*t_wp));
|
||||
default:
|
||||
return filstat(*t_wp, n);
|
||||
}
|
||||
}
|
||||
|
||||
if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) {
|
||||
return binop();
|
||||
}
|
||||
|
||||
return strlen(*t_wp) > 0;
|
||||
}
|
||||
|
||||
static int
|
||||
binop()
|
||||
{
|
||||
const char *opnd1, *opnd2;
|
||||
struct t_op const *op;
|
||||
|
||||
opnd1 = *t_wp;
|
||||
(void) t_lex(*++t_wp);
|
||||
op = t_wp_op;
|
||||
|
||||
if ((opnd2 = *++t_wp) == (char *)0)
|
||||
syntax(op->op_text, "argument expected");
|
||||
|
||||
switch (op->op_num) {
|
||||
case STREQ:
|
||||
return strcmp(opnd1, opnd2) == 0;
|
||||
case STRNE:
|
||||
return strcmp(opnd1, opnd2) != 0;
|
||||
case STRLT:
|
||||
return strcmp(opnd1, opnd2) < 0;
|
||||
case STRGT:
|
||||
return strcmp(opnd1, opnd2) > 0;
|
||||
case INTEQ:
|
||||
return getn(opnd1) == getn(opnd2);
|
||||
case INTNE:
|
||||
return getn(opnd1) != getn(opnd2);
|
||||
case INTGE:
|
||||
return getn(opnd1) >= getn(opnd2);
|
||||
case INTGT:
|
||||
return getn(opnd1) > getn(opnd2);
|
||||
case INTLE:
|
||||
return getn(opnd1) <= getn(opnd2);
|
||||
case INTLT:
|
||||
return getn(opnd1) < getn(opnd2);
|
||||
case FILNT:
|
||||
return newerf (opnd1, opnd2);
|
||||
case FILOT:
|
||||
return olderf (opnd1, opnd2);
|
||||
case FILEQ:
|
||||
return equalf (opnd1, opnd2);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
filstat(nm, mode)
|
||||
char *nm;
|
||||
enum token mode;
|
||||
{
|
||||
struct stat s;
|
||||
unsigned int i;
|
||||
|
||||
if (mode == FILSYM) {
|
||||
#ifdef S_IFLNK
|
||||
if (lstat(nm, &s) == 0) {
|
||||
i = S_IFLNK;
|
||||
goto filetype;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (stat(nm, &s) != 0)
|
||||
return 0;
|
||||
|
||||
switch (mode) {
|
||||
case FILRD:
|
||||
return test_eaccess(nm, R_OK) == 0;
|
||||
case FILWR:
|
||||
return test_eaccess(nm, W_OK) == 0;
|
||||
case FILEX:
|
||||
return test_eaccess(nm, X_OK) == 0;
|
||||
case FILEXIST:
|
||||
return 1;
|
||||
case FILREG:
|
||||
i = S_IFREG;
|
||||
goto filetype;
|
||||
case FILDIR:
|
||||
i = S_IFDIR;
|
||||
goto filetype;
|
||||
case FILCDEV:
|
||||
i = S_IFCHR;
|
||||
goto filetype;
|
||||
case FILBDEV:
|
||||
i = S_IFBLK;
|
||||
goto filetype;
|
||||
case FILFIFO:
|
||||
#ifdef S_IFIFO
|
||||
i = S_IFIFO;
|
||||
goto filetype;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case FILSOCK:
|
||||
#ifdef S_IFSOCK
|
||||
i = S_IFSOCK;
|
||||
goto filetype;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case FILSUID:
|
||||
i = S_ISUID;
|
||||
goto filebit;
|
||||
case FILSGID:
|
||||
i = S_ISGID;
|
||||
goto filebit;
|
||||
case FILSTCK:
|
||||
i = S_ISVTX;
|
||||
goto filebit;
|
||||
case FILGZ:
|
||||
return s.st_size > 0L;
|
||||
case FILUID:
|
||||
return s.st_uid == geteuid();
|
||||
case FILGID:
|
||||
return s.st_gid == getegid();
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
filetype:
|
||||
return ((s.st_mode & S_IFMT) == i);
|
||||
|
||||
filebit:
|
||||
return ((s.st_mode & i) != 0);
|
||||
}
|
||||
|
||||
static enum token
|
||||
t_lex(s)
|
||||
char *s;
|
||||
{
|
||||
struct t_op const *op = ops;
|
||||
|
||||
if (s == 0) {
|
||||
t_wp_op = (struct t_op *)0;
|
||||
return EOI;
|
||||
}
|
||||
while (op->op_text) {
|
||||
if (strcmp(s, op->op_text) == 0) {
|
||||
t_wp_op = op;
|
||||
return op->op_num;
|
||||
}
|
||||
op++;
|
||||
}
|
||||
t_wp_op = (struct t_op *)0;
|
||||
return OPERAND;
|
||||
}
|
||||
|
||||
/* atoi with error detection */
|
||||
static int
|
||||
getn(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
long r;
|
||||
|
||||
errno = 0;
|
||||
r = strtol(s, &p, 10);
|
||||
|
||||
if (errno != 0)
|
||||
error_msg_and_die("%s: out of range", s);
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p)
|
||||
error_msg_and_die("%s: bad number", s);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
static int
|
||||
newerf (f1, f2)
|
||||
char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
return (stat (f1, &b1) == 0 &&
|
||||
stat (f2, &b2) == 0 &&
|
||||
b1.st_mtime > b2.st_mtime);
|
||||
}
|
||||
|
||||
static int
|
||||
olderf (f1, f2)
|
||||
char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
return (stat (f1, &b1) == 0 &&
|
||||
stat (f2, &b2) == 0 &&
|
||||
b1.st_mtime < b2.st_mtime);
|
||||
}
|
||||
|
||||
static int
|
||||
equalf (f1, f2)
|
||||
char *f1, *f2;
|
||||
{
|
||||
struct stat b1, b2;
|
||||
|
||||
return (stat (f1, &b1) == 0 &&
|
||||
stat (f2, &b2) == 0 &&
|
||||
b1.st_dev == b2.st_dev &&
|
||||
b1.st_ino == b2.st_ino);
|
||||
}
|
||||
|
||||
/* Do the same thing access(2) does, but use the effective uid and gid,
|
||||
and don't make the mistake of telling root that any file is
|
||||
executable. */
|
||||
static int
|
||||
test_eaccess (path, mode)
|
||||
char *path;
|
||||
int mode;
|
||||
{
|
||||
struct stat st;
|
||||
unsigned int euid = geteuid();
|
||||
|
||||
if (stat (path, &st) < 0)
|
||||
return (-1);
|
||||
|
||||
if (euid == 0) {
|
||||
/* Root can read or write any file. */
|
||||
if (mode != X_OK)
|
||||
return (0);
|
||||
|
||||
/* Root can execute any file that has any one of the execute
|
||||
bits set. */
|
||||
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (st.st_uid == euid) /* owner */
|
||||
mode <<= 6;
|
||||
else if (is_a_group_member (st.st_gid))
|
||||
mode <<= 3;
|
||||
|
||||
if (st.st_mode & mode)
|
||||
return (0);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_group_array ()
|
||||
{
|
||||
ngroups = getgroups(0, NULL);
|
||||
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
|
||||
getgroups(ngroups, group_array);
|
||||
}
|
||||
|
||||
/* Return non-zero if GID is one that we have in our groups list. */
|
||||
static int
|
||||
is_a_group_member (gid)
|
||||
gid_t gid;
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* Short-circuit if possible, maybe saving a call to getgroups(). */
|
||||
if (gid == getgid() || gid == getegid())
|
||||
return (1);
|
||||
|
||||
if (ngroups == 0)
|
||||
initialize_group_array ();
|
||||
|
||||
/* Search through the list looking for GID. */
|
||||
for (i = 0; i < ngroups; i++)
|
||||
if (gid == group_array[i])
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
+41
-52
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini touch implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,66 +22,54 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
|
||||
"\tUpdate the last-modified date on the given file[s].\n";
|
||||
|
||||
|
||||
|
||||
extern int
|
||||
touch_main(int argc, char **argv)
|
||||
extern int touch_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int create=TRUE;
|
||||
int fd;
|
||||
int create = TRUE;
|
||||
|
||||
if (argc < 2) {
|
||||
usage( touch_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv)) switch (**argv) {
|
||||
case 'c':
|
||||
create = FALSE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown option: %c\n", **argv);
|
||||
exit( FALSE);
|
||||
/* Parse options */
|
||||
while (--argc > 0 && **(++argv) == '-') {
|
||||
while (*(++(*argv))) {
|
||||
switch (**argv) {
|
||||
case 'c':
|
||||
create = FALSE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
fd = open (*argv, (create==FALSE)? O_RDWR : O_RDWR | O_CREAT, 0644);
|
||||
if (fd < 0 ) {
|
||||
if (create==FALSE && errno == ENOENT)
|
||||
exit( TRUE);
|
||||
else {
|
||||
perror("touch");
|
||||
exit( FALSE);
|
||||
if (argc < 1) {
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
close( fd);
|
||||
if (utime (*argv, NULL)) {
|
||||
perror("touch");
|
||||
exit( FALSE);
|
||||
}
|
||||
else
|
||||
exit( TRUE);
|
||||
|
||||
while (argc > 0) {
|
||||
fd = open(*argv, (create == FALSE) ? O_RDWR : O_RDWR | O_CREAT,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd < 0) {
|
||||
if (create == FALSE && errno == ENOENT)
|
||||
return EXIT_SUCCESS;
|
||||
else {
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (utime(*argv, NULL)) {
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tr implementation for busybox
|
||||
*
|
||||
* Copyright (c) Michiel Huisjes
|
||||
*
|
||||
* This version of tr is adapted from Minix tr and was modified
|
||||
* by Erik Andersen <andersee@debian.org> to be used in busybox.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_write_error
|
||||
#include "messages.c"
|
||||
|
||||
static const int ASCII = 0377;
|
||||
|
||||
/* some glabals shared across this file */
|
||||
static char com_fl, del_fl, sq_fl;
|
||||
static short in_index, out_index;
|
||||
/* these last are pointers to static buffers declared in tr_main */
|
||||
static unsigned char *poutput, *pinput;
|
||||
static unsigned char *pvector;
|
||||
static char *pinvec, *poutvec;
|
||||
|
||||
|
||||
static void convert()
|
||||
{
|
||||
short read_chars = 0;
|
||||
short c, coded;
|
||||
short last = -1;
|
||||
|
||||
for (;;) {
|
||||
if (in_index == read_chars) {
|
||||
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index)
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(0);
|
||||
}
|
||||
in_index = 0;
|
||||
}
|
||||
c = pinput[in_index++];
|
||||
coded = pvector[c];
|
||||
if (del_fl && pinvec[c])
|
||||
continue;
|
||||
if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
|
||||
continue;
|
||||
poutput[out_index++] = last = coded;
|
||||
if (out_index == BUFSIZ) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index) {
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(1);
|
||||
}
|
||||
out_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static void map(register unsigned char *string1, unsigned int string1_len,
|
||||
register unsigned char *string2, unsigned int string2_len)
|
||||
{
|
||||
unsigned char last = '0';
|
||||
unsigned int i, j;
|
||||
|
||||
for (j = 0, i = 0; i < string1_len; i++) {
|
||||
if (string2_len <= j)
|
||||
pvector[string1[i]] = last;
|
||||
else
|
||||
pvector[string1[i]] = last = string2[j++];
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int expand(char *arg, register unsigned char *buffer)
|
||||
{
|
||||
unsigned char *buffer_start = buffer;
|
||||
int i, ac;
|
||||
|
||||
while (*arg) {
|
||||
if (*arg == '\\') {
|
||||
arg++;
|
||||
*buffer++ = process_escape_sequence(&arg);
|
||||
} else if (*arg == '[') {
|
||||
arg++;
|
||||
i = *arg++;
|
||||
if (*arg++ != '-') {
|
||||
*buffer++ = '[';
|
||||
arg -= 2;
|
||||
continue;
|
||||
}
|
||||
ac = *arg++;
|
||||
while (i <= ac)
|
||||
*buffer++ = i++;
|
||||
arg++; /* Skip ']' */
|
||||
} else
|
||||
*buffer++ = *arg++;
|
||||
}
|
||||
|
||||
return (buffer - buffer_start);
|
||||
}
|
||||
|
||||
static int complement(unsigned char *buffer, int buffer_len)
|
||||
{
|
||||
register short i, j, index;
|
||||
char conv[ASCII + 2];
|
||||
|
||||
index = 0;
|
||||
for (i = 0; i <= ASCII; i++) {
|
||||
for (j = 0; j < buffer_len; j++)
|
||||
if (buffer[j] == i)
|
||||
break;
|
||||
if (j == buffer_len)
|
||||
conv[index++] = i & ASCII;
|
||||
}
|
||||
memcpy(buffer, conv, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
extern int tr_main(int argc, char **argv)
|
||||
{
|
||||
register unsigned char *ptr;
|
||||
int output_length=0, input_length;
|
||||
int index = 1;
|
||||
int i;
|
||||
RESERVE_BB_BUFFER(output, BUFSIZ);
|
||||
RESERVE_BB_BUFFER(input, BUFSIZ);
|
||||
RESERVE_BB_UBUFFER(vector, ASCII+1);
|
||||
RESERVE_BB_BUFFER(invec, ASCII+1);
|
||||
RESERVE_BB_BUFFER(outvec, ASCII+1);
|
||||
|
||||
/* ... but make them available globally */
|
||||
poutput = output;
|
||||
pinput = input;
|
||||
pvector = vector;
|
||||
pinvec = invec;
|
||||
poutvec = outvec;
|
||||
|
||||
if (argc > 1 && argv[index][0] == '-') {
|
||||
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
|
||||
switch (*ptr) {
|
||||
case 'c':
|
||||
com_fl = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
del_fl = TRUE;
|
||||
break;
|
||||
case 's':
|
||||
sq_fl = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
for (i = 0; i <= ASCII; i++) {
|
||||
vector[i] = i;
|
||||
invec[i] = outvec[i] = FALSE;
|
||||
}
|
||||
|
||||
if (argv[index] != NULL) {
|
||||
input_length = expand(argv[index++], input);
|
||||
if (com_fl)
|
||||
input_length = complement(input, input_length);
|
||||
if (argv[index] != NULL) {
|
||||
if (*argv[index] == '\0')
|
||||
error_msg_and_die("STRING2 cannot be empty");
|
||||
output_length = expand(argv[index], output);
|
||||
map(input, input_length, output, output_length);
|
||||
}
|
||||
for (i = 0; i < input_length; i++)
|
||||
invec[(int)input[i]] = TRUE;
|
||||
for (i = 0; i < output_length; i++)
|
||||
outvec[(int)output[i]] = TRUE;
|
||||
}
|
||||
convert();
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987,1997, Prentice Hall
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use of the MINIX operating system in source and
|
||||
* binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* Neither the name of Prentice Hall nor the names of the software
|
||||
* authors or contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tty implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int tty_main(int argc, char **argv)
|
||||
{
|
||||
char *tty;
|
||||
|
||||
if (argc > 1) {
|
||||
if (argv[1][0] != '-' || argv[1][1] != 's')
|
||||
show_usage();
|
||||
} else {
|
||||
tty = ttyname(0);
|
||||
if (tty)
|
||||
puts(tty);
|
||||
else
|
||||
puts("not a tty");
|
||||
}
|
||||
return(isatty(0) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
+68
-77
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* uname -- print system information
|
||||
Copyright (C) 1989-1999 Free Software Foundation, Inc.
|
||||
|
||||
@@ -30,48 +31,37 @@
|
||||
|
||||
/* Busyboxed by Erik Andersen */
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#if defined (HAVE_SYSINFO) && defined (HAVE_SYS_SYSTEMINFO_H)
|
||||
# include <sys/systeminfo.h>
|
||||
#endif
|
||||
|
||||
|
||||
static const char uname_usage[] =
|
||||
"uname [OPTION]...\n"
|
||||
"Print certain system information. With no OPTION, same as -s.\n"
|
||||
"\t-a\tprint all information\n"
|
||||
"\t-m\tthe machine (hardware) type\n"
|
||||
"\t-n\tprint the machine's network node hostname\n"
|
||||
"\t-r\tprint the operating system release\n"
|
||||
"\t-s\tprint the operating system name\n"
|
||||
"\t-p\tprint the host processor type\n"
|
||||
"\t-v\tprint the operating system version\n";
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
static void print_element(unsigned int mask, char *element);
|
||||
|
||||
/* Values that are bitwise or'd into `toprint'. */
|
||||
/* Operating system name. */
|
||||
#define PRINT_SYSNAME 1
|
||||
static const int PRINT_SYSNAME = 1;
|
||||
|
||||
/* Node name on a communications network. */
|
||||
#define PRINT_NODENAME 2
|
||||
static const int PRINT_NODENAME = 2;
|
||||
|
||||
/* Operating system release. */
|
||||
#define PRINT_RELEASE 4
|
||||
static const int PRINT_RELEASE = 4;
|
||||
|
||||
/* Operating system version. */
|
||||
#define PRINT_VERSION 8
|
||||
static const int PRINT_VERSION = 8;
|
||||
|
||||
/* Machine hardware name. */
|
||||
#define PRINT_MACHINE 16
|
||||
static const int PRINT_MACHINE = 16;
|
||||
|
||||
/* Host processor type. */
|
||||
#define PRINT_PROCESSOR 32
|
||||
static const int PRINT_PROCESSOR = 32;
|
||||
|
||||
/* Mask indicating which elements of the name to print. */
|
||||
static unsigned char toprint;
|
||||
@@ -79,77 +69,78 @@ static unsigned char toprint;
|
||||
|
||||
int uname_main(int argc, char **argv)
|
||||
{
|
||||
struct utsname name;
|
||||
char processor[256];
|
||||
struct utsname name;
|
||||
char processor[256];
|
||||
|
||||
#if defined(__sparc__) && defined(__linux__)
|
||||
char *fake_sparc = getenv("FAKE_SPARC");
|
||||
char *fake_sparc = getenv("FAKE_SPARC");
|
||||
#endif
|
||||
|
||||
toprint = 0;
|
||||
toprint = 0;
|
||||
|
||||
/* Parse any options */
|
||||
//fprintf(stderr, "argc=%d, argv=%s\n", argc, *argv);
|
||||
while (--argc > 0 && **(++argv) == '-') {
|
||||
while (*(++(*argv))) {
|
||||
switch (**argv) {
|
||||
case 's':
|
||||
toprint |= PRINT_SYSNAME;
|
||||
break;
|
||||
case 'n':
|
||||
toprint |= PRINT_NODENAME;
|
||||
break;
|
||||
case 'r':
|
||||
toprint |= PRINT_RELEASE;
|
||||
break;
|
||||
case 'v':
|
||||
toprint |= PRINT_VERSION;
|
||||
break;
|
||||
case 'm':
|
||||
toprint |= PRINT_MACHINE;
|
||||
break;
|
||||
case 'p':
|
||||
toprint |= PRINT_PROCESSOR;
|
||||
break;
|
||||
case 'a':
|
||||
toprint = (PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE |
|
||||
PRINT_PROCESSOR | PRINT_VERSION |
|
||||
PRINT_MACHINE);
|
||||
break;
|
||||
default:
|
||||
usage(uname_usage);
|
||||
}
|
||||
/* Parse any options */
|
||||
//fprintf(stderr, "argc=%d, argv=%s\n", argc, *argv);
|
||||
while (--argc > 0 && **(++argv) == '-') {
|
||||
while (*(++(*argv))) {
|
||||
switch (**argv) {
|
||||
case 's':
|
||||
toprint |= PRINT_SYSNAME;
|
||||
break;
|
||||
case 'n':
|
||||
toprint |= PRINT_NODENAME;
|
||||
break;
|
||||
case 'r':
|
||||
toprint |= PRINT_RELEASE;
|
||||
break;
|
||||
case 'v':
|
||||
toprint |= PRINT_VERSION;
|
||||
break;
|
||||
case 'm':
|
||||
toprint |= PRINT_MACHINE;
|
||||
break;
|
||||
case 'p':
|
||||
toprint |= PRINT_PROCESSOR;
|
||||
break;
|
||||
case 'a':
|
||||
toprint = (PRINT_SYSNAME | PRINT_NODENAME | PRINT_RELEASE |
|
||||
PRINT_PROCESSOR | PRINT_VERSION |
|
||||
PRINT_MACHINE);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toprint == 0)
|
||||
toprint = PRINT_SYSNAME;
|
||||
if (toprint == 0)
|
||||
toprint = PRINT_SYSNAME;
|
||||
|
||||
if (uname(&name) == -1)
|
||||
perror("cannot get system name");
|
||||
if (uname(&name) == -1)
|
||||
perror_msg("cannot get system name");
|
||||
|
||||
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
|
||||
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
|
||||
perror("cannot get processor type");
|
||||
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
|
||||
perror_msg("cannot get processor type");
|
||||
}
|
||||
|
||||
#else
|
||||
strcpy(processor, "unknown");
|
||||
strcpy(processor, "unknown");
|
||||
#endif
|
||||
|
||||
#if defined(__sparc__) && defined(__linux__)
|
||||
if (fake_sparc != NULL
|
||||
&& (fake_sparc[0] == 'y'
|
||||
|| fake_sparc[0] == 'Y')) strcpy(name.machine, "sparc");
|
||||
if (fake_sparc != NULL
|
||||
&& (fake_sparc[0] == 'y'
|
||||
|| fake_sparc[0] == 'Y')) strcpy(name.machine, "sparc");
|
||||
#endif
|
||||
|
||||
print_element(PRINT_SYSNAME, name.sysname);
|
||||
print_element(PRINT_NODENAME, name.nodename);
|
||||
print_element(PRINT_RELEASE, name.release);
|
||||
print_element(PRINT_VERSION, name.version);
|
||||
print_element(PRINT_MACHINE, name.machine);
|
||||
print_element(PRINT_PROCESSOR, processor);
|
||||
print_element(PRINT_SYSNAME, name.sysname);
|
||||
print_element(PRINT_NODENAME, name.nodename);
|
||||
print_element(PRINT_RELEASE, name.release);
|
||||
print_element(PRINT_VERSION, name.version);
|
||||
print_element(PRINT_MACHINE, name.machine);
|
||||
print_element(PRINT_PROCESSOR, processor);
|
||||
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* If the name element set in MASK is selected for printing in `toprint',
|
||||
@@ -158,8 +149,8 @@ int uname_main(int argc, char **argv)
|
||||
|
||||
static void print_element(unsigned int mask, char *element)
|
||||
{
|
||||
if (toprint & mask) {
|
||||
toprint &= ~mask;
|
||||
printf("%s%c", element, toprint ? ' ' : '\n');
|
||||
}
|
||||
if (toprint & mask) {
|
||||
toprint &= ~mask;
|
||||
printf("%s%c", element, toprint ? ' ' : '\n');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini uniq implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int print_count;
|
||||
static int print_uniq = 1;
|
||||
static int print_duplicates = 1;
|
||||
|
||||
static void print_line(char *line, int count, FILE *fp)
|
||||
{
|
||||
if ((print_duplicates && count > 1) || (print_uniq && count == 1)) {
|
||||
if (print_count)
|
||||
fprintf(fp, "%7d\t%s", count, line);
|
||||
else
|
||||
fputs(line, fp);
|
||||
}
|
||||
}
|
||||
|
||||
int uniq_main(int argc, char **argv)
|
||||
{
|
||||
FILE *in = stdin, *out = stdout;
|
||||
char *lastline = NULL, *input;
|
||||
int opt, count = 0;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((opt = getopt(argc, argv, "cdu")) > 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
print_count = 1;
|
||||
break;
|
||||
case 'd':
|
||||
print_duplicates = 1;
|
||||
print_uniq = 0;
|
||||
break;
|
||||
case 'u':
|
||||
print_duplicates = 0;
|
||||
print_uniq = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argv[optind] != NULL) {
|
||||
in = xfopen(argv[optind], "r");
|
||||
if (argv[optind+1] != NULL)
|
||||
out = xfopen(argv[optind+1], "w");
|
||||
}
|
||||
|
||||
while ((input = get_line_from_file(in)) != NULL) {
|
||||
if (lastline == NULL || strcmp(input, lastline) != 0) {
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
lastline = input;
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini usleep implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int usleep_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
usleep(atoi(*(++argv))); /* return void */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
/* uudecode.c -- uudecode utility.
|
||||
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
*
|
||||
* This product is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This product is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93.
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "pwd_grp/pwd.h"
|
||||
#include "pwd_grp/grp.h"
|
||||
|
||||
/*struct passwd *getpwnam();*/
|
||||
|
||||
/* Single character decode. */
|
||||
#define DEC(Char) (((Char) - ' ') & 077)
|
||||
|
||||
static int read_stduu (const char *inname)
|
||||
{
|
||||
char buf[2 * BUFSIZ];
|
||||
|
||||
while (1) {
|
||||
int n;
|
||||
char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
error_msg("%s: Short file", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
|
||||
/* N is used to avoid writing out all the characters at the end of
|
||||
the file. */
|
||||
n = DEC (*p);
|
||||
if (n <= 0)
|
||||
break;
|
||||
for (++p; n > 0; p += 4, n -= 3) {
|
||||
char ch;
|
||||
|
||||
if (n >= 3) {
|
||||
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
|
||||
putchar (ch);
|
||||
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
|
||||
putchar (ch);
|
||||
ch = DEC (p[2]) << 6 | DEC (p[3]);
|
||||
putchar (ch);
|
||||
} else {
|
||||
if (n >= 1) {
|
||||
ch = DEC (p[0]) << 2 | DEC (p[1]) >> 4;
|
||||
putchar (ch);
|
||||
}
|
||||
if (n >= 2) {
|
||||
ch = DEC (p[1]) << 4 | DEC (p[2]) >> 2;
|
||||
putchar (ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL
|
||||
|| strcmp (buf, "end\n")) {
|
||||
error_msg("%s: No `end' line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int read_base64 (const char *inname)
|
||||
{
|
||||
static const char b64_tab[256] = {
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*000-007*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*010-017*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*020-027*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*030-037*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*040-047*/
|
||||
'\177', '\177', '\177', '\76', '\177', '\177', '\177', '\77', /*050-057*/
|
||||
'\64', '\65', '\66', '\67', '\70', '\71', '\72', '\73', /*060-067*/
|
||||
'\74', '\75', '\177', '\177', '\177', '\100', '\177', '\177', /*070-077*/
|
||||
'\177', '\0', '\1', '\2', '\3', '\4', '\5', '\6', /*100-107*/
|
||||
'\7', '\10', '\11', '\12', '\13', '\14', '\15', '\16', /*110-117*/
|
||||
'\17', '\20', '\21', '\22', '\23', '\24', '\25', '\26', /*120-127*/
|
||||
'\27', '\30', '\31', '\177', '\177', '\177', '\177', '\177', /*130-137*/
|
||||
'\177', '\32', '\33', '\34', '\35', '\36', '\37', '\40', /*140-147*/
|
||||
'\41', '\42', '\43', '\44', '\45', '\46', '\47', '\50', /*150-157*/
|
||||
'\51', '\52', '\53', '\54', '\55', '\56', '\57', '\60', /*160-167*/
|
||||
'\61', '\62', '\63', '\177', '\177', '\177', '\177', '\177', /*170-177*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*200-207*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*210-217*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*220-227*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*230-237*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*240-247*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*250-257*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*260-267*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*270-277*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*300-307*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*310-317*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*320-327*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*330-337*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*340-347*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*350-357*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*360-367*/
|
||||
'\177', '\177', '\177', '\177', '\177', '\177', '\177', '\177', /*370-377*/
|
||||
};
|
||||
unsigned char buf[2 * BUFSIZ];
|
||||
|
||||
while (1) {
|
||||
int last_data = 0;
|
||||
unsigned char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
error_msg("%s: Short file", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
|
||||
if (memcmp (buf, "====", 4) == 0)
|
||||
break;
|
||||
if (last_data != 0) {
|
||||
error_msg("%s: data following `=' padding character", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The following implementation of the base64 decoding might look
|
||||
a bit clumsy but I only try to follow the POSIX standard:
|
||||
``All line breaks or other characters not found in the table
|
||||
[with base64 characters] shall be ignored by decoding
|
||||
software.'' */
|
||||
while (*p != '\n') {
|
||||
char c1, c2, c3;
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (*p == '\n' || *p++ == '=')
|
||||
break;
|
||||
if (*p == '\n')
|
||||
/* This leaves the loop. */
|
||||
continue;
|
||||
c1 = b64_tab[*p++];
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (*p == '\n' || *p++ == '=') {
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
c2 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
if (*p == '=') {
|
||||
putchar (c1 << 2 | c2 >> 4);
|
||||
last_data = 1;
|
||||
break;
|
||||
}
|
||||
c3 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
putchar (c1 << 2 | c2 >> 4);
|
||||
putchar (c2 << 4 | c3 >> 2);
|
||||
if (*p == '=') {
|
||||
last_data = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
putchar (c3 << 6 | b64_tab[*p++]);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int decode (const char *inname,
|
||||
const char *forced_outname)
|
||||
{
|
||||
struct passwd *pw;
|
||||
register int n;
|
||||
register char *p;
|
||||
int mode, n1;
|
||||
char buf[2 * BUFSIZ];
|
||||
char *outname;
|
||||
int do_base64 = 0;
|
||||
|
||||
/* Search for header line. */
|
||||
|
||||
while (1) {
|
||||
if (fgets (buf, sizeof (buf), stdin) == NULL) {
|
||||
error_msg("%s: No `begin' line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strncmp (buf, "begin", 5) == 0) {
|
||||
if (sscanf (buf, "begin-base64 %o %s", &mode, buf) == 2) {
|
||||
do_base64 = 1;
|
||||
break;
|
||||
} else if (sscanf (buf, "begin %o %s", &mode, buf) == 2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the output file name is given on the command line this rules. */
|
||||
if (forced_outname != NULL)
|
||||
outname = (char *) forced_outname;
|
||||
else {
|
||||
/* Handle ~user/file format. */
|
||||
if (buf[0] != '~')
|
||||
outname = buf;
|
||||
else {
|
||||
p = buf + 1;
|
||||
while (*p != '/')
|
||||
++p;
|
||||
if (*p == '\0') {
|
||||
error_msg("%s: Illegal ~user", inname);
|
||||
return FALSE;
|
||||
}
|
||||
*p++ = '\0';
|
||||
pw = getpwnam (buf + 1);
|
||||
if (pw == NULL) {
|
||||
error_msg("%s: No user `%s'", inname, buf + 1);
|
||||
return FALSE;
|
||||
}
|
||||
n = strlen (pw->pw_dir);
|
||||
n1 = strlen (p);
|
||||
outname = (char *) alloca ((size_t) (n + n1 + 2));
|
||||
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
|
||||
memcpy (outname, pw->pw_dir, (size_t) n);
|
||||
outname[n] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
/* Create output file and set mode. */
|
||||
if (strcmp (outname, "/dev/stdout") != 0 && strcmp (outname, "-") != 0
|
||||
&& (freopen (outname, "w", stdout) == NULL
|
||||
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
|
||||
)) {
|
||||
perror_msg("%s", outname); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* We differenciate decoding standard UU encoding and base64. A
|
||||
common function would only slow down the program. */
|
||||
|
||||
/* For each input line: */
|
||||
if (do_base64)
|
||||
return read_base64 (inname);
|
||||
else
|
||||
return read_stduu (inname);
|
||||
}
|
||||
|
||||
int uudecode_main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
int opt;
|
||||
int exit_status;
|
||||
const char *outname;
|
||||
outname = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "o:")) != EOF) {
|
||||
switch (opt) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
outname = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
exit_status = decode ("stdin", outname) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
else {
|
||||
exit_status = EXIT_SUCCESS;
|
||||
do {
|
||||
if (freopen (argv[optind], "r", stdin) != NULL) {
|
||||
if (decode (argv[optind], outname) != 0)
|
||||
exit_status = FALSE;
|
||||
} else {
|
||||
perror_msg("%s", argv[optind]);
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
while (optind < argc);
|
||||
}
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/* uuencode.c -- uuencode utility.
|
||||
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
*
|
||||
* This product is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This product is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt */
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||
|
||||
static void encode __P ((void));
|
||||
|
||||
/* Pointer to the translation table we currently use. */
|
||||
static const char *trans_ptr;
|
||||
|
||||
/* The two currently defined translation tables. The first is the
|
||||
standard uuencoding, the second is base64 encoding. */
|
||||
static const char uu_std[64] = {
|
||||
'`', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
|
||||
};
|
||||
|
||||
static const char uu_base64[64] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||
};
|
||||
|
||||
/* ENC is the basic 1 character encoding function to make a char printing. */
|
||||
#define ENC(Char) (trans_ptr[(Char) & 077])
|
||||
|
||||
/* Copy from IN to OUT, encoding as you go along. */
|
||||
static void encode()
|
||||
{
|
||||
register int ch, n;
|
||||
char *p = NULL;
|
||||
char buf[80];
|
||||
|
||||
while (1) {
|
||||
n = 0;
|
||||
do {
|
||||
register int m = fread (buf, 1, 45 - n, stdin);
|
||||
if (m == 0)
|
||||
break;
|
||||
n += m;
|
||||
}
|
||||
while (n < 45);
|
||||
|
||||
if (n == 0)
|
||||
break;
|
||||
|
||||
if (trans_ptr == uu_std)
|
||||
if (putchar (ENC (n)) == EOF)
|
||||
break;
|
||||
for (p = buf; n > 2; n -= 3, p += 3) {
|
||||
ch = *p >> 2;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = p[2] & 077;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
if (n != 0)
|
||||
break;
|
||||
|
||||
if (putchar ('\n') == EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
while (n != 0) {
|
||||
char c1 = *p;
|
||||
char c2 = n == 1 ? 0 : p[1];
|
||||
|
||||
ch = c1 >> 2;
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
|
||||
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
|
||||
ch = ENC (ch);
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
|
||||
if (n == 1)
|
||||
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
|
||||
else {
|
||||
ch = (c2 << 2) & 074;
|
||||
ch = ENC (ch);
|
||||
}
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
|
||||
if (putchar (ch) == EOF)
|
||||
break;
|
||||
putchar ('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
if (ferror (stdin))
|
||||
error_msg("Read error");
|
||||
|
||||
if (trans_ptr == uu_std) {
|
||||
putchar (ENC ('\0'));
|
||||
putchar ('\n');
|
||||
}
|
||||
}
|
||||
|
||||
int uuencode_main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
int opt;
|
||||
struct stat sb;
|
||||
int mode;
|
||||
|
||||
trans_ptr = uu_std; /* Standard encoding is old uu format */
|
||||
|
||||
/* Parse any options */
|
||||
while ((opt = getopt (argc, argv, "m")) > 0) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
trans_ptr = uu_base64;
|
||||
break;
|
||||
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
/* Optional first argument is input file. */
|
||||
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
optind++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
mode = RW & ~umask (RW);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
|
||||
mode, argv[optind]);
|
||||
encode();
|
||||
printf(trans_ptr == uu_std ? "end\n" : "====\n");
|
||||
if (ferror (stdout)) {
|
||||
error_msg("Write error");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini wc implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int total_lines, total_words, total_chars, max_length;
|
||||
static int print_lines, print_words, print_chars, print_length;
|
||||
|
||||
static void print_counts(int lines, int words, int chars, int length,
|
||||
const char *name)
|
||||
{
|
||||
char const *space = "";
|
||||
|
||||
if (print_lines) {
|
||||
printf("%7d", lines);
|
||||
space = " ";
|
||||
}
|
||||
if (print_words) {
|
||||
printf("%s%7d", space, words);
|
||||
space = " ";
|
||||
}
|
||||
if (print_chars) {
|
||||
printf("%s%7d", space, chars);
|
||||
space = " ";
|
||||
}
|
||||
if (print_length)
|
||||
printf("%s%7d", space, length);
|
||||
if (*name)
|
||||
printf(" %s", name);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
static void wc_file(FILE * file, const char *name)
|
||||
{
|
||||
int lines, words, chars, length;
|
||||
int in_word = 0, linepos = 0;
|
||||
int c;
|
||||
|
||||
lines = words = chars = length = 0;
|
||||
while ((c = getc(file)) != EOF) {
|
||||
chars++;
|
||||
switch (c) {
|
||||
case '\n':
|
||||
lines++;
|
||||
case '\r':
|
||||
case '\f':
|
||||
if (linepos > length)
|
||||
length = linepos;
|
||||
linepos = 0;
|
||||
goto word_separator;
|
||||
case '\t':
|
||||
linepos += 8 - (linepos % 8);
|
||||
goto word_separator;
|
||||
case ' ':
|
||||
linepos++;
|
||||
case '\v':
|
||||
word_separator:
|
||||
if (in_word) {
|
||||
in_word = 0;
|
||||
words++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
linepos++;
|
||||
in_word = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (linepos > length)
|
||||
length = linepos;
|
||||
if (in_word)
|
||||
words++;
|
||||
print_counts(lines, words, chars, length, name);
|
||||
total_lines += lines;
|
||||
total_words += words;
|
||||
total_chars += chars;
|
||||
if (length > max_length)
|
||||
max_length = length;
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int wc_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
unsigned int num_files_counted = 0;
|
||||
int opt, status = EXIT_SUCCESS;
|
||||
|
||||
total_lines = total_words = total_chars = max_length = 0;
|
||||
print_lines = print_words = print_chars = print_length = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "clLw")) > 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
print_chars = 1;
|
||||
break;
|
||||
case 'l':
|
||||
print_lines = 1;
|
||||
break;
|
||||
case 'L':
|
||||
print_length = 1;
|
||||
break;
|
||||
case 'w':
|
||||
print_words = 1;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (!print_lines && !print_words && !print_chars && !print_length)
|
||||
print_lines = print_words = print_chars = 1;
|
||||
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
wc_file(stdin, "");
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
while (optind < argc) {
|
||||
if ((file = wfopen(argv[optind], "r")) != NULL)
|
||||
wc_file(file, argv[optind]);
|
||||
else
|
||||
status = EXIT_FAILURE;
|
||||
num_files_counted++;
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_files_counted > 1)
|
||||
print_counts(total_lines, total_words, total_chars,
|
||||
max_length, "total");
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini whoami implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int whoami_main(int argc, char **argv)
|
||||
{
|
||||
char user[9];
|
||||
uid_t uid = geteuid();
|
||||
|
||||
if (argc > 1)
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, uid);
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("cannot find username for UID %u", (unsigned) uid);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini yes implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int yes_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-')
|
||||
show_usage();
|
||||
|
||||
if (argc == 1) {
|
||||
while (1)
|
||||
if (puts("y") == EOF) {
|
||||
perror("yes");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
for (i = 1; i < argc; i++)
|
||||
if (fputs(argv[i], stdout) == EOF
|
||||
|| putchar(i == argc - 1 ? '\n' : ' ') == EOF) {
|
||||
perror("yes");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Mini cp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
|
||||
static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n"
|
||||
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
|
||||
"Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
|
||||
"\n"
|
||||
"\t-a\tsame as -dpR\n"
|
||||
"\t-d\tpreserve links\n"
|
||||
"\t-p\tpreserve file attributes if possable\n"
|
||||
"\t-R\tcopy directories recursively\n";
|
||||
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int followLinks = FALSE;
|
||||
static int preserveFlag = FALSE;
|
||||
static const char *srcName;
|
||||
static const char *destName;
|
||||
static const char *skipName;
|
||||
static int dirFlag = FALSE;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat* statbuf)
|
||||
{
|
||||
char newdestName[NAME_MAX];
|
||||
strcpy(newdestName, destName);
|
||||
if (dirFlag==TRUE) {
|
||||
strcat(newdestName, "/");
|
||||
if ( skipName != NULL)
|
||||
strcat(newdestName, strstr(fileName, skipName));
|
||||
}
|
||||
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
||||
}
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
if (argc < 3) {
|
||||
usage (cp_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 'a':
|
||||
followLinks = TRUE;
|
||||
preserveFlag = TRUE;
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
followLinks = TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
preserveFlag = TRUE;
|
||||
break;
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage (cp_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
|
||||
destName = argv[argc - 1];
|
||||
dirFlag = isDirectory(destName);
|
||||
|
||||
if ((argc > 3) && dirFlag==FALSE) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- > 1) {
|
||||
srcName = *(argv++);
|
||||
skipName = strrchr(srcName, '/');
|
||||
if (skipName)
|
||||
skipName++;
|
||||
if (recursiveAction(srcName, recursiveFlag, followLinks, FALSE,
|
||||
fileAction, fileAction) == FALSE) {
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini `cp' and `mv' implementation for BusyBox.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
|
||||
* Extensively modified and rewritten by Karl M. Hegbloom <karlheg@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/param.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#define bb_need_omitting_directory
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
static const int is_cp = 0;
|
||||
static const int is_mv = 1;
|
||||
static int dz_i; /* index into cp_mv_usage */
|
||||
|
||||
|
||||
static int recursiveFlag;
|
||||
static int followLinks;
|
||||
static int preserveFlag;
|
||||
static int forceFlag;
|
||||
|
||||
static const char *baseSrcName;
|
||||
static int srcDirFlag;
|
||||
static struct stat srcStatBuf;
|
||||
|
||||
static char *pBaseDestName;
|
||||
static size_t baseDestLen;
|
||||
static int destDirFlag;
|
||||
static struct stat destStatBuf;
|
||||
|
||||
static jmp_buf catch;
|
||||
static volatile int mv_Action_first_time;
|
||||
|
||||
static void name_too_long__exit (void) __attribute__((noreturn));
|
||||
|
||||
static
|
||||
void name_too_long__exit (void)
|
||||
{
|
||||
error_msg_and_die(name_too_long);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_baseDest_buf(char *_buf, size_t * _buflen) {
|
||||
const char *srcBasename;
|
||||
if ((srcBasename = strrchr(baseSrcName, '/')) == NULL) {
|
||||
srcBasename = baseSrcName;
|
||||
if (_buf[*_buflen - 1] != '/') {
|
||||
if (++(*_buflen) > BUFSIZ)
|
||||
name_too_long__exit();
|
||||
strcat(_buf, "/");
|
||||
}
|
||||
}
|
||||
if (*_buflen + strlen(srcBasename) > BUFSIZ)
|
||||
name_too_long__exit();
|
||||
strcat(_buf, srcBasename);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
char destName[BUFSIZ + 1];
|
||||
size_t destLen;
|
||||
const char *srcBasename;
|
||||
char *name;
|
||||
|
||||
strcpy(destName, pBaseDestName);
|
||||
destLen = strlen(destName);
|
||||
|
||||
if (srcDirFlag == TRUE) {
|
||||
if (recursiveFlag == FALSE) {
|
||||
error_msg(omitting_directory, baseSrcName);
|
||||
return TRUE;
|
||||
}
|
||||
srcBasename = (strstr(fileName, baseSrcName)
|
||||
+ strlen(baseSrcName));
|
||||
|
||||
if (destLen + strlen(srcBasename) > BUFSIZ) {
|
||||
error_msg(name_too_long);
|
||||
return FALSE;
|
||||
}
|
||||
strcat(destName, srcBasename);
|
||||
}
|
||||
else if (destDirFlag == TRUE) {
|
||||
fill_baseDest_buf(&destName[0], &destLen);
|
||||
}
|
||||
else {
|
||||
srcBasename = baseSrcName;
|
||||
}
|
||||
if (mv_Action_first_time && (dz_i == is_mv)) {
|
||||
mv_Action_first_time = errno = 0;
|
||||
if (rename(fileName, destName) < 0 && errno != EXDEV) {
|
||||
perror_msg("rename(%s, %s)", fileName, destName);
|
||||
goto do_copyFile; /* Try anyway... */
|
||||
}
|
||||
else if (errno == EXDEV)
|
||||
goto do_copyFile;
|
||||
else
|
||||
longjmp(catch, 1); /* succeeded with rename() */
|
||||
}
|
||||
do_copyFile:
|
||||
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
|
||||
if (is_in_ino_dev_hashtable(statbuf, &name)) {
|
||||
if (link(name, destName) < 0) {
|
||||
perror_msg("link(%s, %s)", name, destName);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
add_to_ino_dev_hashtable(statbuf, destName);
|
||||
}
|
||||
}
|
||||
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
|
||||
}
|
||||
|
||||
static int
|
||||
rm_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
int status = TRUE;
|
||||
|
||||
if (S_ISDIR(statbuf->st_mode)) {
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror_msg("rmdir(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
} else if (unlink(fileName) < 0) {
|
||||
perror_msg("unlink(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
extern int cp_mv_main(int argc, char **argv)
|
||||
{
|
||||
volatile int i;
|
||||
int c;
|
||||
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
|
||||
pBaseDestName = baseDestName; /* available globally */
|
||||
|
||||
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
|
||||
dz_i = is_cp;
|
||||
else
|
||||
dz_i = is_mv;
|
||||
if (argc < 3)
|
||||
show_usage();
|
||||
|
||||
if (dz_i == is_cp) {
|
||||
recursiveFlag = preserveFlag = forceFlag = FALSE;
|
||||
followLinks = TRUE;
|
||||
while ((c = getopt(argc, argv, "adpRf")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
followLinks = FALSE;
|
||||
preserveFlag = TRUE;
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'd':
|
||||
followLinks = FALSE;
|
||||
break;
|
||||
case 'p':
|
||||
preserveFlag = TRUE;
|
||||
break;
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
forceFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if ((argc - optind) < 2) {
|
||||
show_usage();
|
||||
}
|
||||
} else { /* (dz_i == is_mv) */
|
||||
/* Initialize optind to 1, since in libc5 optind
|
||||
* is not initialized until getopt() is called
|
||||
* (or until sneaky programmers force it...). */
|
||||
optind = 1;
|
||||
recursiveFlag = preserveFlag = TRUE;
|
||||
followLinks = FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (strlen(argv[argc - 1]) > BUFSIZ) {
|
||||
error_msg(name_too_long);
|
||||
goto exit_false;
|
||||
}
|
||||
strcpy(baseDestName, argv[argc - 1]);
|
||||
baseDestLen = strlen(baseDestName);
|
||||
if (baseDestLen == 0)
|
||||
goto exit_false;
|
||||
|
||||
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
|
||||
if (argc - optind > 2 && destDirFlag == FALSE) {
|
||||
error_msg(not_a_directory, baseDestName);
|
||||
goto exit_false;
|
||||
}
|
||||
|
||||
for (i = optind; i < (argc-1); i++) {
|
||||
size_t srcLen;
|
||||
volatile int flags_memo;
|
||||
int status;
|
||||
|
||||
baseSrcName=argv[i];
|
||||
|
||||
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
|
||||
name_too_long__exit();
|
||||
|
||||
if (srcLen == 0) continue; /* "" */
|
||||
|
||||
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
|
||||
|
||||
if ((flags_memo = (recursiveFlag == TRUE &&
|
||||
srcDirFlag == TRUE && destDirFlag == TRUE))) {
|
||||
|
||||
struct stat sb;
|
||||
int state = 0;
|
||||
char *pushd, *d, *p;
|
||||
|
||||
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
if (chdir(baseDestName) < 0) {
|
||||
perror_msg("chdir(%s)", baseSrcName);
|
||||
continue;
|
||||
}
|
||||
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
while (!state && *d != '\0') {
|
||||
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
|
||||
perror_msg("stat(%s)", d);
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
if ((sb.st_ino == srcStatBuf.st_ino) &&
|
||||
(sb.st_dev == srcStatBuf.st_dev)) {
|
||||
error_msg("Cannot %s `%s' into a subdirectory of itself, "
|
||||
"`%s/%s'", applet_name, baseSrcName,
|
||||
baseDestName, baseSrcName);
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
if ((p = strrchr(d, '/')) != NULL) {
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
if (chdir(pushd) < 0) {
|
||||
perror_msg("chdir(%s)", pushd);
|
||||
free(pushd);
|
||||
free(d);
|
||||
continue;
|
||||
}
|
||||
free(pushd);
|
||||
free(d);
|
||||
if (state < 0)
|
||||
continue;
|
||||
else
|
||||
fill_baseDest_buf(baseDestName, &baseDestLen);
|
||||
}
|
||||
status = setjmp(catch);
|
||||
if (status == 0) {
|
||||
mv_Action_first_time = 1;
|
||||
if (recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, FALSE,
|
||||
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
|
||||
if (dz_i == is_mv &&
|
||||
recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, TRUE,
|
||||
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
|
||||
}
|
||||
if (flags_memo)
|
||||
*(baseDestName + baseDestLen) = '\0';
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
exit_false:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
/* globals in this file only */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static int startpos = 1;
|
||||
static int endpos = -1;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
|
||||
|
||||
/*
|
||||
* decompose_list() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
*/
|
||||
static void decompose_list(const char *list)
|
||||
{
|
||||
unsigned int nminus = 0;
|
||||
char *ptr;
|
||||
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle single value 'N' case */
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
/* handle multi-value cases */
|
||||
else if (nminus == 1) {
|
||||
/* handle 'N-' case */
|
||||
if (list[strlen(list) - 1] == '-') {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
}
|
||||
/* handle '-M' case */
|
||||
else if (list[0] == '-') {
|
||||
endpos = strtol(&list[1], NULL, 10);
|
||||
}
|
||||
/* handle 'N-M' case */
|
||||
else {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
endpos = strtol(ptr+1, &ptr, 10);
|
||||
}
|
||||
|
||||
/* a sanity check */
|
||||
if (startpos == 0) {
|
||||
startpos = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* snippy-snip
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
/* a valid end position has been specified */
|
||||
if (endpos > 0) {
|
||||
for (i = startpos-1; i < endpos; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* otherwise, just go to the end of the line */
|
||||
else {
|
||||
for (i = startpos-1; line[i]; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
char *ptr;
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields");
|
||||
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
* files were specified or '-' was specified, take input from stdin.
|
||||
* Otherwise, we process all the files specified. */
|
||||
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
|
||||
cut_file(stdin);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loaded 100 of 341 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user