mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc6c8473d6 | ||
|
|
815b0998c7 | ||
|
|
32fe1cc2a2 | ||
|
|
0f62bbab30 | ||
|
|
f5af57621e | ||
|
|
a58b26be52 | ||
|
|
6bdff04c53 | ||
|
|
6e0bf6461e | ||
|
|
22a852a834 | ||
|
|
4837d2aeda | ||
|
|
5388febb0d | ||
|
|
d8a85c658c | ||
|
|
7249a78449 | ||
|
|
4de19ff60d | ||
|
|
6cf1cd4875 | ||
|
|
7c9c58a074 | ||
|
|
3745b4498a | ||
|
|
70aa518b5b | ||
|
|
562bf06fac | ||
|
|
a823dba480 | ||
|
|
ad6f78a87a | ||
|
|
e8646f87f5 | ||
|
|
ea21a88cf5 | ||
|
|
f5253e8cd2 | ||
|
|
f0467745ce | ||
|
|
d7ab125adb | ||
|
|
1d402fd23b | ||
|
|
70308609be | ||
|
|
b4137a6590 | ||
|
|
b99f1dfa0b | ||
|
|
70b2f8cb22 | ||
|
|
05bc7718e1 | ||
|
|
58dc608f72 | ||
|
|
1b50e22003 | ||
|
|
75e221ebc0 | ||
|
|
18c931d4a4 | ||
|
|
8d979f1d63 | ||
|
|
811c42fb59 | ||
|
|
d193ac5650 | ||
|
|
ff27b5062d | ||
|
|
fea6edcaa6 | ||
|
|
10ca74767f | ||
|
|
7d059777c3 | ||
|
|
df1971778d | ||
|
|
edd1a2ed03 | ||
|
|
c9b36989e5 | ||
|
|
0ebd723f3d | ||
|
|
ba2c0d13f4 | ||
|
|
065c9875d8 | ||
|
|
23dc65d036 | ||
|
|
dc8fc64ad0 | ||
|
|
c91733841b | ||
|
|
26b0823111 | ||
|
|
b2102cdaae | ||
|
|
7d910decd1 | ||
|
|
1ed76d1bd6 | ||
|
|
d840117172 | ||
|
|
6701757fca | ||
|
|
394fcbfa43 | ||
|
|
1de5080573 | ||
|
|
8a84316e5f | ||
|
|
ef0cdbc087 | ||
|
|
e0dc4d545e | ||
|
|
46908626ab | ||
|
|
1e802f2552 | ||
|
|
f3609d9a4f | ||
|
|
5ea869194c | ||
|
|
8f389f0504 | ||
|
|
cb9e18ec9d | ||
|
|
b585e440d2 | ||
|
|
8ea6302fef | ||
|
|
c16696b4ac | ||
|
|
e2ec869918 | ||
|
|
b89e80ddd2 | ||
|
|
4f16b08e11 | ||
|
|
8428d51a90 | ||
|
|
1d71da917c | ||
|
|
7b9054aa4f | ||
|
|
b89975d19e | ||
|
|
0cc2a5b351 | ||
|
|
b837de481d | ||
|
|
cf3674f046 | ||
|
|
bba3d6b99d | ||
|
|
c5fad80d07 | ||
|
|
fd91897a61 | ||
|
|
a05736ef43 | ||
|
|
44d61c55f9 | ||
|
|
442bf03103 | ||
|
|
193d88d82e | ||
|
|
ec3b48576b | ||
|
|
f6a5fc26b6 | ||
|
|
5b0dbd3c3f | ||
|
|
307f7f0f90 | ||
|
|
8c246fd3c7 | ||
|
|
7efdf97a06 | ||
|
|
24bb51445f | ||
|
|
0230634cf9 | ||
|
|
3f3eaf781b | ||
|
|
a58d7e54e8 | ||
|
|
4db56925dc | ||
|
|
a69be26d7d | ||
|
|
78c4ae6e8e | ||
|
|
77c3b5453b | ||
|
|
0e27d1f07a | ||
|
|
a11e947126 | ||
|
|
1f51cf036a | ||
|
|
96e4254985 | ||
|
|
15e8f4607c | ||
|
|
8aeb1c2772 | ||
|
|
ef46767f99 | ||
|
|
7f67f25643 | ||
|
|
89a1c3131a | ||
|
|
280ba73ac7 | ||
|
|
3a14f3caf3 | ||
|
|
14fdc4cc45 | ||
|
|
87e33fb506 | ||
|
|
67f0439956 | ||
|
|
e84f2a9426 | ||
|
|
07f0b96bc0 | ||
|
|
21a8a1c413 | ||
|
|
6f0ebcd9a5 | ||
|
|
ca2024d4b8 | ||
|
|
d0ee41d86a | ||
|
|
ceb4b2a9b2 | ||
|
|
ae2aa396a8 | ||
|
|
42a1ccef13 | ||
|
|
d521b3e35c | ||
|
|
5e05883f3a | ||
|
|
638444081f | ||
|
|
fdda64a77a | ||
|
|
3420a036b9 | ||
|
|
86593032da | ||
|
|
054a3a3368 | ||
|
|
2342462642 | ||
|
|
1727ec736b | ||
|
|
66b156e640 | ||
|
|
f4575fd229 | ||
|
|
3eb9288a4c | ||
|
|
c6b2a68290 | ||
|
|
cc1640ad2a | ||
|
|
c4c409cc20 | ||
|
|
c15b0b5e01 | ||
|
|
b459bf6d1e | ||
|
|
875ad2454d | ||
|
|
d4182fdfac | ||
|
|
a89d081fef | ||
|
|
01a8a4e3cb | ||
|
|
18e37330b6 | ||
|
|
2d91f6724f | ||
|
|
edde6cf456 | ||
|
|
a2bdd1500f | ||
|
|
9e7d9a15bd | ||
|
|
ba55638ad6 | ||
|
|
4926072584 | ||
|
|
949c372713 | ||
|
|
37659d83e3 | ||
|
|
980892ae50 | ||
|
|
00d6b70cf6 | ||
|
|
5ea6e1b9fc | ||
|
|
c8ed8a5d53 | ||
|
|
946769ee24 | ||
|
|
3472c164c3 | ||
|
|
d036dd6f19 | ||
|
|
9b9cbe14c1 | ||
|
|
065279f2be | ||
|
|
aa392b5f39 | ||
|
|
5fc61b3a3b | ||
|
|
fbcf51142f | ||
|
|
53f7fd7b57 | ||
|
|
eb4a498e41 | ||
|
|
fd41207b81 | ||
|
|
6e9001f1e2 | ||
|
|
14f6bf0594 | ||
|
|
3ca2ba376e | ||
|
|
f4c01192b0 | ||
|
|
dd52b9a794 | ||
|
|
658b2bb4a2 | ||
|
|
dcc8dfb3af | ||
|
|
d670275678 | ||
|
|
0b975bbbb3 | ||
|
|
8df3cb190c | ||
|
|
f74ec6eee5 | ||
|
|
308a67b9c3 | ||
|
|
aacbfb8210 | ||
|
|
3ec6689a51 | ||
|
|
bb6ef3268f | ||
|
|
dc0812150d | ||
|
|
ad4821f26a | ||
|
|
eaf0aa7fbe | ||
|
|
89d747ea99 | ||
|
|
ca97f02e5c | ||
|
|
af43004774 | ||
|
|
6d9d8d4224 | ||
|
|
f8abecbb7f | ||
|
|
3786083fc6 | ||
|
|
a56a1a0f39 | ||
|
|
5844cd840c | ||
|
|
63f894376b | ||
|
|
d808f4cd2c | ||
|
|
47cbf3c66b | ||
|
|
6ff5c436a3 | ||
|
|
029b4e1fce | ||
|
|
047c999e9e | ||
|
|
6c729d5040 | ||
|
|
c836c2b8e7 | ||
|
|
e9adfe4a34 | ||
|
|
83591627cb | ||
|
|
b4d47f5448 | ||
|
|
7132e98736 | ||
|
|
260fcb6b93 | ||
|
|
191a65c1ec | ||
|
|
efb4caccc5 | ||
|
|
43d6c847f4 | ||
|
|
31f33f23a3 | ||
|
|
2dddb5bd02 | ||
|
|
a771ee1188 | ||
|
|
b2c2697cf8 | ||
|
|
bd922647f4 | ||
|
|
b80347938e | ||
|
|
a3df14a694 | ||
|
|
a3fda2d3f8 | ||
|
|
9984280aca | ||
|
|
b7f52847d5 | ||
|
|
12f5301d37 | ||
|
|
832b6c0b5e | ||
|
|
6d7b6e68dd | ||
|
|
99d0fb74a3 | ||
|
|
e97d71bc98 | ||
|
|
a74e0bd2c6 | ||
|
|
cbe579519f | ||
|
|
2ae1fd351e | ||
|
|
eba56b9643 | ||
|
|
1af72c5084 | ||
|
|
9f7b2c132a | ||
|
|
2fbf90ef01 | ||
|
|
3accd72948 | ||
|
|
d783a927f4 | ||
|
|
7217ade08e | ||
|
|
2ed502499e | ||
|
|
8b911be307 | ||
|
|
61b1685675 | ||
|
|
2352aa0cf1 | ||
|
|
f55ca996ab | ||
|
|
2c5bcddb86 | ||
|
|
f80ac8be85 | ||
|
|
db03364a32 | ||
|
|
5f12cfc8d7 | ||
|
|
07feaea8d0 | ||
|
|
6ca7b36d86 | ||
|
|
d4a29fe97a | ||
|
|
bf9ad10d34 | ||
|
|
f4ad42ac18 | ||
|
|
67ff9f4b28 | ||
|
|
e11a99439c | ||
|
|
e6522fa2d6 | ||
|
|
5694aa2301 | ||
|
|
8c0cd7c8bc | ||
|
|
4f056fd1c0 | ||
|
|
f58722a26e | ||
|
|
73cab5d584 | ||
|
|
6a0fb29045 | ||
|
|
8433f6ba46 | ||
|
|
da2c60f5b8 | ||
|
|
9ae50db590 | ||
|
|
d7e625fc8f | ||
|
|
8b65ff0319 | ||
|
|
f64332a418 | ||
|
|
8381e73ac4 | ||
|
|
fc50e037ad | ||
|
|
5f9d7602b5 | ||
|
|
ac6d4cbb65 | ||
|
|
3346309151 | ||
|
|
cd75d407a5 | ||
|
|
b31cffbf1f | ||
|
|
97a1dd514f | ||
|
|
aa46a5386a | ||
|
|
4d45418b34 | ||
|
|
186273f3ed | ||
|
|
42a2078151 | ||
|
|
41e28d2465 | ||
|
|
05843aee0c | ||
|
|
96aceda235 | ||
|
|
10ae2b144f | ||
|
|
ab47d60645 | ||
|
|
c015d3a3d7 | ||
|
|
a32e55fb66 | ||
|
|
b056e2889a | ||
|
|
dcdb15a41e | ||
|
|
ba9aa7713a | ||
|
|
d05bf9fbc2 | ||
|
|
961235859c | ||
|
|
03935d4b06 | ||
|
|
e038afb2a6 | ||
|
|
bd05db97e6 | ||
|
|
4aad18b2f3 | ||
|
|
1d65971a97 | ||
|
|
c81cda6e5c | ||
|
|
8e7f1191fb | ||
|
|
c4c3d949e9 | ||
|
|
0b7e7031c5 | ||
|
|
4b6f996569 | ||
|
|
5b604db708 | ||
|
|
d484fcef9b | ||
|
|
d9f8cc931d | ||
|
|
5884cfe9e6 | ||
|
|
c2fc4ec6c3 | ||
|
|
e63234c20f | ||
|
|
a525556b38 | ||
|
|
eeb6dc142d | ||
|
|
4022942513 | ||
|
|
677ca39c5b | ||
|
|
d4d4e18a45 | ||
|
|
fb6b37aaa6 | ||
|
|
aaaac0ba68 | ||
|
|
91f02c5320 | ||
|
|
e1eaf58f4b | ||
|
|
842cca7222 | ||
|
|
9aa0e78f63 | ||
|
|
524bab53fa | ||
|
|
027fda3a99 | ||
|
|
8cbfe36eab | ||
|
|
ba3d71a09e | ||
|
|
24d300a580 | ||
|
|
b309a721a2 | ||
|
|
f172b9782a | ||
|
|
852c8a4c09 | ||
|
|
b4d16bcbae | ||
|
|
cf02ffd0b0 | ||
|
|
311cbb1af3 | ||
|
|
476a6daeab | ||
|
|
b52cdf8dfa | ||
|
|
6a5eb47932 | ||
|
|
94a679522d | ||
|
|
28e6515ea5 | ||
|
|
24ec98a874 | ||
|
|
a3f2cdadc7 | ||
|
|
0b62244267 | ||
|
|
8267161d5e | ||
|
|
e1f80efa82 | ||
|
|
aab8ac62b5 | ||
|
|
9411f86182 | ||
|
|
5c113d5c22 | ||
|
|
353a8c5442 | ||
|
|
ad5dfadf0c | ||
|
|
8476e0b206 | ||
|
|
77dd78f6a2 | ||
|
|
0f06dfdd00 | ||
|
|
a30e285862 | ||
|
|
38efc26107 | ||
|
|
74a87fcfc7 | ||
|
|
e357665885 | ||
|
|
355327100c | ||
|
|
7738b02267 | ||
|
|
bbf13e603c | ||
|
|
277c94c8c3 | ||
|
|
ffd5f68616 | ||
|
|
6822d1d620 | ||
|
|
3f904f5033 | ||
|
|
81f0febea2 | ||
|
|
8b51478ae5 | ||
|
|
4a1fb62925 | ||
|
|
d89a7fb835 | ||
|
|
a9d3913a6c | ||
|
|
a405284d0e | ||
|
|
f0e7f36bad | ||
|
|
92dfad552e | ||
|
|
8a93fa7496 | ||
|
|
610816668b | ||
|
|
b65f8ff197 | ||
|
|
5c132ca21d | ||
|
|
f929ec50c4 | ||
|
|
c99ad0afa1 | ||
|
|
9304566e82 | ||
|
|
367bc2553f | ||
|
|
1d01e9761b | ||
|
|
65225813d4 | ||
|
|
7aa6feb8b4 | ||
|
|
06d6192295 | ||
|
|
20a2b89c9a | ||
|
|
e80a798592 | ||
|
|
2dc8d4a396 | ||
|
|
56cacad31a | ||
|
|
2e29242d2f | ||
|
|
45585130de | ||
|
|
a2815032ab | ||
|
|
20e4eb747e | ||
|
|
e9fe7d0fd2 | ||
|
|
4de81b55de | ||
|
|
6f09056d0d | ||
|
|
3e5a13b411 | ||
|
|
78c15f1e87 | ||
|
|
9ae5293e0f | ||
|
|
cbb31f44a7 | ||
|
|
cfbeb5ad01 | ||
|
|
c36260bab4 | ||
|
|
29657db467 | ||
|
|
fd621002ea | ||
|
|
a9e1f121ad | ||
|
|
5f7d8d9976 | ||
|
|
3035378a39 | ||
|
|
e3d6141747 | ||
|
|
3ef3b0d330 | ||
|
|
594b7c1434 | ||
|
|
4cc45d2981 | ||
|
|
dc7291f347 | ||
|
|
d735ab1a60 | ||
|
|
6a75e837b8 | ||
|
|
a3aee1c872 | ||
|
|
376031a3fd | ||
|
|
c6d5150769 | ||
|
|
b4aff94ab6 | ||
|
|
c945e6ce62 | ||
|
|
c5fd5f9344 | ||
|
|
032fcf581e | ||
|
|
a7a4e09ae6 | ||
|
|
9c96dc9de2 | ||
|
|
ca9e6be887 | ||
|
|
06533c0a67 | ||
|
|
5005bcfc48 | ||
|
|
45a8d661be | ||
|
|
729a1d22ba | ||
|
|
94fdd07e5d | ||
|
|
f7aaa744e4 | ||
|
|
dcd2278d3f | ||
|
|
186fc816f7 | ||
|
|
b64f5b2c6c | ||
|
|
192ac46f0a | ||
|
|
f369737334 | ||
|
|
d6c9704a79 | ||
|
|
85be35cf99 | ||
|
|
259fd130e0 | ||
|
|
91bb988c97 | ||
|
|
97879b91b7 | ||
|
|
f16558ea6d | ||
|
|
b96a55870b | ||
|
|
1a696d51e1 | ||
|
|
58ac3c61d1 | ||
|
|
022abadb2e | ||
|
|
41c0bf5de4 | ||
|
|
c1c8601025 | ||
|
|
0fb926e9ed | ||
|
|
db73cf5f48 | ||
|
|
4af8156695 | ||
|
|
494777747a | ||
|
|
beb936e904 | ||
|
|
16bc71e8f1 | ||
|
|
642da61401 | ||
|
|
1408deaa7d | ||
|
|
1f7a01ccfb | ||
|
|
d1ad4ea6b6 | ||
|
|
73e7d1d111 | ||
|
|
1d31585645 | ||
|
|
7a00fc77a5 | ||
|
|
cc86dade12 | ||
|
|
615abae8f1 | ||
|
|
81bfc0a71a | ||
|
|
6e13a2b089 | ||
|
|
88769b1c21 | ||
|
|
2c3354b5f5 | ||
|
|
53d588843b | ||
|
|
7378a8a117 | ||
|
|
4bf7143482 | ||
|
|
997acc630c | ||
|
|
6eccd57679 | ||
|
|
d723c925d2 | ||
|
|
f0991210c0 | ||
|
|
42357eaf9b | ||
|
|
27f43d377a | ||
|
|
10f6a0130b | ||
|
|
35dde25470 | ||
|
|
2bcd3194b5 | ||
|
|
10ddb8a2b3 | ||
|
|
dd0a3203e7 | ||
|
|
196c705599 | ||
|
|
c4866cde97 | ||
|
|
4655a0eea1 | ||
|
|
05d003c788 | ||
|
|
2aac73c7b6 | ||
|
|
3463119aa2 | ||
|
|
1256a14783 | ||
|
|
9d920cdfb1 | ||
|
|
20dbf7a0d0 | ||
|
|
860d92e3f0 | ||
|
|
844e5e95d4 | ||
|
|
e0e8de2d7d | ||
|
|
4b22b3f1f1 | ||
|
|
5befaff2da | ||
|
|
606a0ec287 | ||
|
|
d38aa4c0d6 | ||
|
|
30be3866c8 | ||
|
|
a6407800bb | ||
|
|
5873ac9570 | ||
|
|
72b6bb613d | ||
|
|
02c3f7b1cd | ||
|
|
077dfc02e2 | ||
|
|
e640c9f54b | ||
|
|
12b4209f80 | ||
|
|
dd7ba172ce | ||
|
|
3536718334 | ||
|
|
4cd75e5715 | ||
|
|
c559a7bf4d | ||
|
|
7b8690a93c | ||
|
|
dbb885b9a1 | ||
|
|
b44fb5e4e5 | ||
|
|
b56489551b | ||
|
|
a90a9d9f94 | ||
|
|
e419439f92 | ||
|
|
c84ac4051f | ||
|
|
c938c00ae6 | ||
|
|
940153a2d2 | ||
|
|
844c910324 | ||
|
|
d992488c00 | ||
|
|
c4d22ba10c | ||
|
|
3e1c65ce14 | ||
|
|
b85f0f2772 | ||
|
|
57718c3451 | ||
|
|
9b098982cf | ||
|
|
96f82806c5 | ||
|
|
fc0bd945c4 | ||
|
|
5ca8a55ee5 | ||
|
|
cb871c7c6d | ||
|
|
941d9a15f9 | ||
|
|
acf348e623 | ||
|
|
89e3f2a012 | ||
|
|
2168336c44 | ||
|
|
aeeeabdf24 | ||
|
|
70895c6935 | ||
|
|
0473fb6f61 | ||
|
|
1259587222 | ||
|
|
bc2ec9054b | ||
|
|
1db7027fe6 | ||
|
|
ebcbf2b2fc | ||
|
|
8702850b3f | ||
|
|
a81f50b5fe | ||
|
|
caf229d10d | ||
|
|
fd6ded786c | ||
|
|
2b55f54b9c | ||
|
|
c90b57ea8c | ||
|
|
0ec4055f30 | ||
|
|
9ccd53016b | ||
|
|
57af9803b7 | ||
|
|
980ac054de | ||
|
|
10e11ee302 | ||
|
|
97eba89dcb | ||
|
|
19bd9945fb | ||
|
|
216bec00c9 | ||
|
|
0dc11cea68 | ||
|
|
a7170ffd21 | ||
|
|
570d39cfa1 | ||
|
|
97a15c7691 | ||
|
|
f9a00324d8 | ||
|
|
1aa729a130 | ||
|
|
05ec8fde09 | ||
|
|
0b75828378 | ||
|
|
0a0e24256b | ||
|
|
fffbdd3bc4 | ||
|
|
9008b734ea | ||
|
|
be2288ded6 | ||
|
|
43ce1d515f | ||
|
|
70dfcc7dd8 | ||
|
|
1026d46505 | ||
|
|
97c1a96048 | ||
|
|
f77ae165ac | ||
|
|
cf36ecd09d | ||
|
|
6a3337c201 | ||
|
|
bc6b91f88c | ||
|
|
ea30af9f57 | ||
|
|
527221e06e | ||
|
|
0adef9c4cf | ||
|
|
d64fcfd51a | ||
|
|
3e9a3556fa | ||
|
|
8390bcaedd | ||
|
|
9bc3cff12a | ||
|
|
2a62fc4766 | ||
|
|
938050e712 | ||
|
|
8e4a2a5a2b | ||
|
|
bef12dc160 | ||
|
|
5214f2e39f | ||
|
|
12e57c40bc | ||
|
|
06c897e1b0 | ||
|
|
870fcd6bf8 | ||
|
|
12573167b7 | ||
|
|
5cc90d6524 | ||
|
|
9d1953a5b3 | ||
|
|
aa59cf428b | ||
|
|
240a8d1ee0 | ||
|
|
1ae4e1bd76 | ||
|
|
157b960076 | ||
|
|
6f8b5d6fd8 | ||
|
|
b40f0a5f2a | ||
|
|
eb7680eb5b | ||
|
|
3e51097a97 | ||
|
|
fb2ea3f479 | ||
|
|
6f5a39d6d8 | ||
|
|
6a35737bdb | ||
|
|
44f03173d5 | ||
|
|
b596330b38 | ||
|
|
237d5155be | ||
|
|
211962f587 | ||
|
|
79166a08c3 | ||
|
|
3d4938068e | ||
|
|
dfe7259c93 | ||
|
|
73e208ce0e | ||
|
|
1e4a818de7 | ||
|
|
9199a29155 | ||
|
|
84939c2ed6 | ||
|
|
f07ac8f82a | ||
|
|
86aa4c7948 | ||
|
|
f8f8ae2375 | ||
|
|
105cf53662 | ||
|
|
cfe745701c | ||
|
|
a98c2a96ae | ||
|
|
7d2d49e0bd | ||
|
|
eb94276bcf | ||
|
|
2c83a37602 | ||
|
|
eb4cea017d | ||
|
|
8088be6ff0 | ||
|
|
69ffe8cefc | ||
|
|
fef73a42b0 | ||
|
|
a948f85ee4 | ||
|
|
2224d09834 | ||
|
|
0acb6d0cdd | ||
|
|
008af337d4 | ||
|
|
4126638853 | ||
|
|
ffbcd0365b | ||
|
|
49f4b61e8b | ||
|
|
68fa8de87a | ||
|
|
a9b126bce5 | ||
|
|
e41b1cb367 | ||
|
|
322bd32b87 | ||
|
|
2d3c3404d4 | ||
|
|
de14fed65e | ||
|
|
66e393eccc | ||
|
|
77c0bce859 | ||
|
|
c992524d56 | ||
|
|
5c7845e91b | ||
|
|
4e6194346f | ||
|
|
5cd2a34764 | ||
|
|
5e535232a9 | ||
|
|
695fc75d04 | ||
|
|
e6cdf26e7f | ||
|
|
7f0fc6738e | ||
|
|
b2b47a6f96 | ||
|
|
0c2bd9442a | ||
|
|
af6ea1ed3b | ||
|
|
317c988f05 | ||
|
|
cbdaa40bed | ||
|
|
219db36825 | ||
|
|
1295049706 | ||
|
|
c22ccc6dd3 | ||
|
|
484f8bf14a | ||
|
|
14edfc4786 | ||
|
|
198b6ed56d | ||
|
|
21b28272b2 | ||
|
|
40697f117f | ||
|
|
95600d6b38 | ||
|
|
55abeb083e | ||
|
|
9c32c4e70a | ||
|
|
ca00eff4e6 | ||
|
|
761d18aaec | ||
|
|
98bebaf7c7 | ||
|
|
9552f4e872 | ||
|
|
701cbd7aa2 | ||
|
|
bd252fb987 | ||
|
|
3bdd57dd9d | ||
|
|
0da3eff54a | ||
|
|
e7da10fc99 | ||
|
|
641e7690af | ||
|
|
8b0ec138b9 | ||
|
|
5d2fb1e870 | ||
|
|
3097649a23 | ||
|
|
2763585afc | ||
|
|
d573355379 | ||
|
|
8776008885 | ||
|
|
ad00cf6570 | ||
|
|
36b567c8c9 | ||
|
|
92b40c85a4 | ||
|
|
13999b6e73 | ||
|
|
82aa8b04de | ||
|
|
509c971225 | ||
|
|
1fce1de9da | ||
|
|
bfae0b67e3 | ||
|
|
16151faef0 | ||
|
|
1fd1729bbd | ||
|
|
a386153efc | ||
|
|
40fd4c2e1b | ||
|
|
304a621cd5 | ||
|
|
98ef547a55 | ||
|
|
12d8f1b7c1 | ||
|
|
e19a2f4016 | ||
|
|
afdfb23005 | ||
|
|
fcc320c9f0 | ||
|
|
dbc3cd7b36 | ||
|
|
437c186e60 | ||
|
|
78f6ef1cce | ||
|
|
bd02468d72 | ||
|
|
40ab00b063 | ||
|
|
13103b826e | ||
|
|
0261aa4196 | ||
|
|
8b4eb21ba2 | ||
|
|
968326449f | ||
|
|
a02b43a1e8 | ||
|
|
47e29c2de0 | ||
|
|
84b1abff2e | ||
|
|
7d71cacbf6 | ||
|
|
9019e3ef4c | ||
|
|
1a9671a17d | ||
|
|
fe14fa4e67 | ||
|
|
8471f1a9c4 | ||
|
|
1a7bf72ecc | ||
|
|
543db8aa8b | ||
|
|
bb511d6f99 | ||
|
|
b611714b1a | ||
|
|
d3bb75b952 | ||
|
|
44a75306a6 | ||
|
|
79ed95c592 | ||
|
|
f13f62ef20 | ||
|
|
c60f8a4cd8 | ||
|
|
9d2fdc34b7 | ||
|
|
d68037daf4 | ||
|
|
14c8194db3 | ||
|
|
3f3317a3fa | ||
|
|
5d2b8cb11f | ||
|
|
f367581fc6 | ||
|
|
3a7c87f7ec | ||
|
|
fdc039e905 | ||
|
|
602b47f906 | ||
|
|
572fe3eb74 | ||
|
|
3f9d0cab18 | ||
|
|
7bbf9b93bf | ||
|
|
8f4c2fff01 | ||
|
|
1104e5742c | ||
|
|
adc6f48f54 | ||
|
|
7dd3e6254e | ||
|
|
e1a95712c4 | ||
|
|
53653fa9f7 | ||
|
|
fbba486d1b | ||
|
|
751a50cc8f | ||
|
|
b7312b9149 | ||
|
|
6980211f12 | ||
|
|
f423cb7491 | ||
|
|
f023ea9bdd | ||
|
|
a95e5d1b25 | ||
|
|
ca26c4d1e9 | ||
|
|
a5a0060d0a | ||
|
|
c835b2ebb3 | ||
|
|
5ef5d397e8 | ||
|
|
04a0ff9629 | ||
|
|
29039ab97c | ||
|
|
28045640e4 | ||
|
|
b8a42023ba | ||
|
|
94b77d4c86 | ||
|
|
de2c88c52b | ||
|
|
733b2baac6 | ||
|
|
1a0f25be2f | ||
|
|
a07c9658be | ||
|
|
afe496c9cd | ||
|
|
1a2726468d | ||
|
|
92f56eacf1 | ||
|
|
4ae27e4746 | ||
|
|
381cb28ed9 | ||
|
|
143f8f0b56 | ||
|
|
291693e4c2 | ||
|
|
28c52a2734 | ||
|
|
977debae0a | ||
|
|
ea5fdf9b78 | ||
|
|
f79cea3342 | ||
|
|
a910c16579 | ||
|
|
26b9f436da | ||
|
|
41d6cb2429 | ||
|
|
dc68c49234 | ||
|
|
7c9544a066 | ||
|
|
0aa568cbf4 | ||
|
|
83ece2d548 | ||
|
|
ecfe611a06 | ||
|
|
3d026cf5f0 | ||
|
|
96fb9d17c7 | ||
|
|
14994a5e46 | ||
|
|
ca8a4053d8 | ||
|
|
732cf985ac | ||
|
|
c373391049 | ||
|
|
740b00069e | ||
|
|
920df63be7 | ||
|
|
f69d6386e1 | ||
|
|
a48c6975d2 | ||
|
|
7da3e9a1bf | ||
|
|
d83b90fc3a | ||
|
|
da7de19756 | ||
|
|
dc6eea68df | ||
|
|
6ba0618bd1 | ||
|
|
8d034a2489 | ||
|
|
d0f3e118b6 | ||
|
|
da2c3a6148 | ||
|
|
a1f3ff1b3c | ||
|
|
4477135bd8 | ||
|
|
96e4a7df36 | ||
|
|
9119c83a15 | ||
|
|
3444afed80 | ||
|
|
56b1967181 | ||
|
|
0d9f92981e | ||
|
|
397438b8a3 | ||
|
|
b23544072e | ||
|
|
2edd8bd986 | ||
|
|
33ebce22dd | ||
|
|
fd98e6bc3a | ||
|
|
2addf865bd | ||
|
|
498b451aaa | ||
|
|
1316af00ea | ||
|
|
9e0c7f5d4a | ||
|
|
29f2c53ff9 | ||
|
|
09dfd131ee | ||
|
|
b2a88c3d96 | ||
|
|
f41b9f3b0d | ||
|
|
aac3846615 | ||
|
|
5d67a8951c | ||
|
|
a2adff0968 | ||
|
|
db2ea89c64 | ||
|
|
dc6a01e022 | ||
|
|
e6d2ec934b | ||
|
|
5923d0b7e2 | ||
|
|
41a116c1aa | ||
|
|
70f5e65794 | ||
|
|
439f02a687 | ||
|
|
51388d30b5 | ||
|
|
a439987511 | ||
|
|
c7a7abbd69 | ||
|
|
6b0ad0d55c | ||
|
|
1a82e8962d | ||
|
|
f9f4c98f73 | ||
|
|
85303f3dbe | ||
|
|
6f586f97a4 | ||
|
|
4db261914c | ||
|
|
13a1207724 | ||
|
|
f9e42fda70 | ||
|
|
31409415b5 | ||
|
|
873bdef67f | ||
|
|
0be5e85d0c | ||
|
|
1c316f3ee4 | ||
|
|
ba97f32797 | ||
|
|
9a8769f38a | ||
|
|
4629b55cc5 | ||
|
|
4a445db052 | ||
|
|
25e5ba719d | ||
|
|
bacc6ee527 | ||
|
|
68824329d4 | ||
|
|
a28e80290f | ||
|
|
7b788c2964 | ||
|
|
c2a5683b86 | ||
|
|
d26b7fb705 | ||
|
|
897df1464f | ||
|
|
06ca8bb8d6 | ||
|
|
cfb922eacc | ||
|
|
e00ab844ac | ||
|
|
a7684f9aaa | ||
|
|
bc532b2897 | ||
|
|
2b30798947 | ||
|
|
6a7d01ec61 | ||
|
|
aa92bc6044 | ||
|
|
febc5e8dfc | ||
|
|
7aed5ead71 | ||
|
|
151739af64 | ||
|
|
1add88c582 | ||
|
|
dca075e463 | ||
|
|
2f52562d4f | ||
|
|
0edc507181 | ||
|
|
cb03ca33c0 | ||
|
|
50b945fca5 | ||
|
|
2e8b8c7700 | ||
|
|
e2eb08af71 | ||
|
|
483cc1a41f | ||
|
|
adab27e955 | ||
|
|
6c3765168b | ||
|
|
e2ed296e94 | ||
|
|
43e5ee938a | ||
|
|
e69e98877a | ||
|
|
1cb652450e | ||
|
|
b88bea2774 | ||
|
|
f814e25cd8 | ||
|
|
d68cc2b8cd | ||
|
|
df3a04ff65 | ||
|
|
a6a6697c13 | ||
|
|
d2f39c830f | ||
|
|
34e032e567 | ||
|
|
af653b483b | ||
|
|
b621d08f4a | ||
|
|
91de9c3719 | ||
|
|
266a33fbe7 | ||
|
|
c0ea39b2d6 | ||
|
|
d7c5179cb2 | ||
|
|
dbe0577640 | ||
|
|
af70c73dcf | ||
|
|
5d77c9903f | ||
|
|
59af8f7ea8 | ||
|
|
be149e5918 | ||
|
|
fedbec797e | ||
|
|
9e3a398571 | ||
|
|
170f6075a1 | ||
|
|
f265becc38 | ||
|
|
ccc7255252 | ||
|
|
cd8981fa4b | ||
|
|
c1cf0c392a | ||
|
|
a8426777d4 | ||
|
|
4f3228c1cc | ||
|
|
2c425e442f | ||
|
|
2c09768a7c | ||
|
|
1efc648ec1 | ||
|
|
8599efdc84 | ||
|
|
8171eef6ce | ||
|
|
714d056936 | ||
|
|
b415a5dc91 | ||
|
|
f3138e4011 | ||
|
|
2962d0c78a | ||
|
|
500abbf531 | ||
|
|
9deca5ed3b | ||
|
|
28a0061cbf | ||
|
|
244f8f450a | ||
|
|
b7c320ab07 | ||
|
|
7d3b0290b8 | ||
|
|
6aca35f5ef | ||
|
|
2d337c0b86 | ||
|
|
ad3903d69f | ||
|
|
0fd2755b2d | ||
|
|
192e07c742 | ||
|
|
6195eddf66 | ||
|
|
400cc93483 | ||
|
|
d3db0f7d01 | ||
|
|
6958993879 | ||
|
|
f907e73a74 | ||
|
|
81918784ee | ||
|
|
05afe78770 | ||
|
|
6de48fe73b | ||
|
|
10b45d730e | ||
|
|
c472ce8fe7 | ||
|
|
e44e3d645e | ||
|
|
203a062db9 | ||
|
|
e9b60cc8ef | ||
|
|
67402210bd | ||
|
|
85ca6f7891 | ||
|
|
7cd4a73e4a | ||
|
|
c79a25d626 | ||
|
|
46fa64be6e | ||
|
|
c9866ad0aa | ||
|
|
bda714c5f4 | ||
|
|
866abd70e2 | ||
|
|
3921d48ab8 | ||
|
|
5aaa18a3ba | ||
|
|
856d3d578e | ||
|
|
ed204851f7 | ||
|
|
4b3e1fe6bf | ||
|
|
60976a8a9d | ||
|
|
77165fb514 | ||
|
|
c720502ac9 | ||
|
|
5c6fb36c72 | ||
|
|
c0c6bae9c8 | ||
|
|
09ee06aead | ||
|
|
ffb0cad5a6 | ||
|
|
4cda6b53b4 | ||
|
|
9c9225173b | ||
|
|
e36affda3a | ||
|
|
913fe3e70b | ||
|
|
28783cbcd0 | ||
|
|
44d2993bc3 | ||
|
|
6bcf280a36 | ||
|
|
726fef391c | ||
|
|
004900840b | ||
|
|
91ed885051 | ||
|
|
84b02c1a8f | ||
|
|
72ebbb608f | ||
|
|
6594be4e6d | ||
|
|
4e426ccecd | ||
|
|
2a6da5d6f1 | ||
|
|
339e5c416c | ||
|
|
a93abb929c | ||
|
|
b2ba55ae18 | ||
|
|
4adba32a0d | ||
|
|
bb95b6dced | ||
|
|
10b3252091 | ||
|
|
11c71516de | ||
|
|
fcccc24e23 | ||
|
|
876b85a756 | ||
|
|
8c6910d366 | ||
|
|
9e41b7ec74 | ||
|
|
aa7ae681b0 | ||
|
|
1dc5cb17b9 | ||
|
|
fb551ca201 | ||
|
|
b2cc52a35e | ||
|
|
33792aae6e | ||
|
|
e9a71ceeb4 | ||
|
|
2eb361050d | ||
|
|
98833b0ff9 | ||
|
|
93537be4a8 | ||
|
|
1b239ee0eb | ||
|
|
cdbd5a9c22 | ||
|
|
e8014227ca | ||
|
|
5195d4cfc0 | ||
|
|
72e6c4348f | ||
|
|
5ef88c7ac5 | ||
|
|
5c538ee58e | ||
|
|
75416f91c2 | ||
|
|
a26ebb5aa7 | ||
|
|
d04a876547 | ||
|
|
cf13915eb7 | ||
|
|
1915761fde | ||
|
|
65a2ace011 | ||
|
|
3cc7f9d629 | ||
|
|
9c1a912c8a | ||
|
|
981441bd4f | ||
|
|
c842bdee36 | ||
|
|
1018fa070e | ||
|
|
9b5c149aec | ||
|
|
7f33ba9dd9 | ||
|
|
b2810b60d6 | ||
|
|
68016bf599 | ||
|
|
e8df4f6375 | ||
|
|
77581d9878 | ||
|
|
39dffe4aa0 | ||
|
|
85de469f3d | ||
|
|
78bfcc7744 | ||
|
|
e796ecc0a2 | ||
|
|
43ab67e8a3 | ||
|
|
352db0d1d5 | ||
|
|
82d15cacb4 | ||
|
|
eaf6f3104e | ||
|
|
cad2588a50 | ||
|
|
b2794569ee | ||
|
|
b71d3cacdc | ||
|
|
3064d4052d | ||
|
|
bca39d3b1e | ||
|
|
6297dcd141 | ||
|
|
34a6a36d40 | ||
|
|
60a8df88d7 | ||
|
|
14367a46dd | ||
|
|
e396af4615 | ||
|
|
38910ee49d | ||
|
|
e212862a20 | ||
|
|
5ad2fa6d9c | ||
|
|
6d6fe4d6fe | ||
|
|
df12c40dca | ||
|
|
e802a9c910 | ||
|
|
5367deb9e7 | ||
|
|
e1309ef9d6 | ||
|
|
c8fafc3e01 | ||
|
|
a625dc3965 | ||
|
|
b74156c766 | ||
|
|
d127318010 | ||
|
|
45982eab2c | ||
|
|
2007e3095d | ||
|
|
aa40261df4 | ||
|
|
8b540999cf | ||
|
|
3eb0642aba | ||
|
|
c069366220 | ||
|
|
70292a398b | ||
|
|
5671e092b3 | ||
|
|
33b1f7ac3a | ||
|
|
daa30f4735 | ||
|
|
1b431c9b78 | ||
|
|
33bc8c4d79 | ||
|
|
8f1f6f47ba | ||
|
|
9a06c42fc4 | ||
|
|
28fdafd85b | ||
|
|
2c25334dab | ||
|
|
a387d1d5f6 | ||
|
|
8302a4cdf2 | ||
|
|
e2f8e143d5 | ||
|
|
0e5ece6919 | ||
|
|
57045a4722 | ||
|
|
0243e76a79 | ||
|
|
2930bfc0c1 | ||
|
|
ccac5f0c5a | ||
|
|
83cd9cde53 | ||
|
|
a02e1fed0c | ||
|
|
950c405b0f | ||
|
|
794b145a19 | ||
|
|
265528cc6c | ||
|
|
cb96c08125 | ||
|
|
210cff6e1f | ||
|
|
1cc6caed3e | ||
|
|
fe75e1b8d3 | ||
|
|
81f764072e | ||
|
|
341c7420f0 | ||
|
|
26bab89059 | ||
|
|
b741b03a5a | ||
|
|
c79b907d10 | ||
|
|
65c55cae96 | ||
|
|
93512315cf | ||
|
|
a3a8c702a3 | ||
|
|
c1c4fa1ec2 | ||
|
|
6d58b9ec58 | ||
|
|
819f5a345f | ||
|
|
c40860f8f6 | ||
|
|
f8369d1fa5 | ||
|
|
91ce9a2e72 | ||
|
|
e62e81ba8c | ||
|
|
b8c9c45df8 | ||
|
|
51911d4ec6 | ||
|
|
dadd38c671 | ||
|
|
198a9c8cb5 | ||
|
|
da054d8c15 | ||
|
|
eb38dedfbc | ||
|
|
17afb2ed9b | ||
|
|
c4e80b0dd1 | ||
|
|
3d0215ea34 | ||
|
|
1487ef693e | ||
|
|
0262f45d79 | ||
|
|
77ed335185 | ||
|
|
be7cc439dd | ||
|
|
28f2d4e814 | ||
|
|
9f1f45ea46 | ||
|
|
c2c1f1eb56 | ||
|
|
c116a126b9 | ||
|
|
06095010a1 | ||
|
|
a5d23fa8b3 | ||
|
|
2d7a230c66 | ||
|
|
346f3b40cf | ||
|
|
952aca77a6 | ||
|
|
fa79dd6751 | ||
|
|
096e9b19f9 | ||
|
|
381b6f1ebb | ||
|
|
b2a92a5345 | ||
|
|
6b3d5687da | ||
|
|
17531924e3 | ||
|
|
85042b357c | ||
|
|
6b1339c66f | ||
|
|
a408c4a9d1 | ||
|
|
cdc917879e | ||
|
|
5177a232f1 | ||
|
|
268e4491ad | ||
|
|
0745874cc4 | ||
|
|
6c35614385 | ||
|
|
3a1f655546 | ||
|
|
72e4a89785 | ||
|
|
e3a727ab22 | ||
|
|
4d9bb76591 | ||
|
|
810b4b2318 | ||
|
|
bd742a07d0 | ||
|
|
23cb51f860 | ||
|
|
a0b778a04f | ||
|
|
c3b1984cf2 | ||
|
|
66103dd4cf | ||
|
|
15796a43be | ||
|
|
b453e49a64 | ||
|
|
bdde5eb6c0 | ||
|
|
821b52ec63 | ||
|
|
64444c3470 | ||
|
|
15821ea1f0 | ||
|
|
4da2ade4ab | ||
|
|
e58f09a3a2 | ||
|
|
0c20455042 | ||
|
|
128dd6e5b6 | ||
|
|
2df0a310e8 | ||
|
|
854a1cf640 | ||
|
|
cbd0a13cc2 | ||
|
|
6be6743775 | ||
|
|
440e3d7fe4 | ||
|
|
718092ace9 | ||
|
|
b04f04c2d5 | ||
|
|
f0f16e38a5 | ||
|
|
3f4feeb0f7 | ||
|
|
63278cc96d | ||
|
|
72bfd2bba1 | ||
|
|
dfa7dcd7d1 | ||
|
|
63fae5d61b | ||
|
|
b28a8ab0d9 | ||
|
|
f398aabf4f | ||
|
|
f066941cc3 | ||
|
|
9dcc700e9b | ||
|
|
ea7591ceb7 | ||
|
|
1da581452c | ||
|
|
b8d82a392c | ||
|
|
b34b315b1e | ||
|
|
1b8d03bcec | ||
|
|
30df230ca0 | ||
|
|
2bdac9ff23 | ||
|
|
c2a8895543 | ||
|
|
1aa25005bd | ||
|
|
9d4528e27a | ||
|
|
f18ce1d48f | ||
|
|
2f30892999 | ||
|
|
e8db8da7ba | ||
|
|
a06259edc8 | ||
|
|
781b70e8f6 | ||
|
|
72a70777eb | ||
|
|
a69df82208 | ||
|
|
aa99c2edcc | ||
|
|
5cad9df360 | ||
|
|
6d2d918871 | ||
|
|
efbe2a31c0 | ||
|
|
c087cba6d5 | ||
|
|
547d561ec0 | ||
|
|
04909358f2 | ||
|
|
5f0dc4802f | ||
|
|
3349f59a56 | ||
|
|
bc2f767e74 | ||
|
|
012d8753ea | ||
|
|
acb1ad4b9e | ||
|
|
d813976707 | ||
|
|
4fe82568f8 | ||
|
|
4e0359d11f | ||
|
|
52b60d37b1 | ||
|
|
cc5a32b8f2 | ||
|
|
2dd4763647 | ||
|
|
eb83e65c9e | ||
|
|
f998415be5 | ||
|
|
5bf8673afe | ||
|
|
4838dd1e7d | ||
|
|
f7708e260d | ||
|
|
8a2f7c2b73 | ||
|
|
51646007b4 | ||
|
|
cf7a3205de | ||
|
|
bb854a1d37 | ||
|
|
b975015b12 | ||
|
|
a4e1c42dcd | ||
|
|
8c2eea0b3d | ||
|
|
f7f37fe584 | ||
|
|
44577e9e47 | ||
|
|
c34180e2df | ||
|
|
a42443d9ff | ||
|
|
5250b2df7d | ||
|
|
0b1b0d1e17 | ||
|
|
fa79519688 | ||
|
|
8c51f5404f | ||
|
|
d58225f757 | ||
|
|
413b04d360 | ||
|
|
db1f8f193e | ||
|
|
2a1ea43f4f | ||
|
|
4e4824afab | ||
|
|
7f0542b133 | ||
|
|
9f187b5dd0 |
No files matched your search
@@ -1,3 +1,150 @@
|
||||
2003-02-13 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* data/machine.config: added default sessionState section and handler.
|
||||
|
||||
2003-02-17 Daniel Morgan <[email protected]>
|
||||
|
||||
* doc/provider-factory: add new web page
|
||||
about Mono.Data's ProviderFactory
|
||||
|
||||
* doc/web/commands
|
||||
* doc/web/makefile: add provider-factory web page to build
|
||||
|
||||
* doc/ado-net
|
||||
* doc/ibmdb2
|
||||
* doc/postgresql
|
||||
* doc/sqlclient
|
||||
* doc/tdsclient
|
||||
* doc/sybase
|
||||
* doc/mysql
|
||||
* doc/firebird
|
||||
* doc/oracle
|
||||
* doc/oledb
|
||||
* doc/odbc
|
||||
* doc/sqlite: updated web pages
|
||||
|
||||
2003-02-16 Martin Baulig <[email protected]>
|
||||
|
||||
* doc/jit-debug-sample
|
||||
* doc/jit-debug-sample2: Removed.
|
||||
|
||||
* doc/jit-debug: Updated.
|
||||
|
||||
2003-02-13 Daniel Morgan <[email protected]>
|
||||
|
||||
* doc/screenshots
|
||||
* doc/ado-net
|
||||
* doc/oracle
|
||||
* doc/gtk-sharp: update web pages
|
||||
|
||||
2003-02-13 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* data/machine.config: added sample globalization section.
|
||||
|
||||
2003-02-12 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* data/machine.config: added UrlAuthorizationModule and
|
||||
AuthenticationConfigHandler.
|
||||
|
||||
2003-02-11 Tim Coleman <[email protected]>
|
||||
* data/config.in: Add mapping for Oracle call interface
|
||||
(OCI) native libraries.
|
||||
|
||||
2003-02-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: added check for sys/un.h.
|
||||
|
||||
2003-01-29 Daniel Morgan <[email protected]>
|
||||
|
||||
* doc/postgresql
|
||||
* doc/mysql
|
||||
* doc/ado-net: updates to web pages
|
||||
|
||||
* man/sqlsharp.1: update to man page
|
||||
|
||||
2003-01-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* configure.in: added WIN32_THREADS flag when building under windows.
|
||||
It seems that the header files of the gc do not always define it when
|
||||
GC_WIN32_THREADS is defined.
|
||||
|
||||
2003-01-26 Daniel Morgan <[email protected]>
|
||||
|
||||
* doc/index
|
||||
* doc/ado-net
|
||||
* doc/firebird
|
||||
* doc/ibmdb2
|
||||
* doc/mysql
|
||||
* doc/odbc
|
||||
* doc/oledb
|
||||
* doc/oracle
|
||||
* doc/postgresql
|
||||
* doc/sqlclient
|
||||
* doc/sqlite
|
||||
* doc/sybase
|
||||
* doc/tdsclient: corrections
|
||||
|
||||
2003-01-26 Duncan Mak <[email protected]>
|
||||
|
||||
* doc/jit-debug: Update the links. Thanks for Andy Oliver for the report.
|
||||
|
||||
2003-01-22 Martin Baulig <[email protected]>
|
||||
|
||||
* configure.in: Set version number to 0.19.1.
|
||||
|
||||
Heads up: I'm going to commit some changes to the debugger
|
||||
which'll require you to use this new runtime, so if you update the
|
||||
debugger from CVS, you also need this new runtime.
|
||||
|
||||
2003-01-20 Duncan Mak <[email protected]>
|
||||
|
||||
* configure.in: Bump the release number to 0.19.
|
||||
|
||||
2003-01-19 Daniel Morgan <[email protected]>
|
||||
|
||||
* doc/ibmdb2: added file which is new web page
|
||||
about IBM DB2 data provider at Mono.Data.DB2Client
|
||||
|
||||
* makefile
|
||||
* commands: added ibmdb2 web page to go-mono web site
|
||||
|
||||
* doc/ado-net: added a couple more developers email, plus made the
|
||||
email spam resistant, added Mono's DB2 data provider to list,
|
||||
added more info about the ProviderFactory and retrieving data using
|
||||
ADO.NET from ASP.NET, add notes about testing, misc cleanup
|
||||
|
||||
* doc/mysql
|
||||
* doc/postgresql
|
||||
* doc/sqlclient
|
||||
* doc/oracle
|
||||
* doc/tdsclient
|
||||
* doc/firebird
|
||||
* doc/oledb
|
||||
* doc/odbc
|
||||
* doc/sybase
|
||||
* doc/sqlite: added testing notes and C# examples
|
||||
|
||||
* doc/gtk-sharp: added links for GTK# for Windows
|
||||
|
||||
* man/sqlsharp.1: added providers Npgsql and MySQLNet
|
||||
|
||||
2003-01-17 Duncan Mak <[email protected]>
|
||||
|
||||
* runtime/Makefile.am: Add the new Mono.Data.DB2Client.dll.
|
||||
|
||||
2003-01-16 Martin Baulig <[email protected]>
|
||||
|
||||
* configure.in (GTHREAD_LIBS, GTHREAD_CFLAGS): Removed the gthread
|
||||
check again, we're now using the mono/io-layer for this.
|
||||
|
||||
Wed Jan 15 16:20:54 CET 2003 Paolo Molaro <[email protected]>
|
||||
|
||||
* configure.in: allow MacOSX (from various people).
|
||||
|
||||
2003-01-14 Martin Baulig <[email protected]>
|
||||
|
||||
* configure.in (GTHREAD_LIBS, GTHREAD_CFLAGS): Added check for gthread.
|
||||
|
||||
2002-12-27 Jeroen Janssen <[email protected]>
|
||||
* fixed url for System.Windows.Forms in the class status
|
||||
|
||||
|
||||
@@ -1,3 +1,615 @@
|
||||
Hello everyone!
|
||||
|
||||
We are releasing a new version of Mono, Mono 0.22. A new release
|
||||
is made today because of the few recent bug-fixes that were committed
|
||||
to CVS.
|
||||
|
||||
Source code and binaries for this release can be found on the
|
||||
web page,
|
||||
|
||||
http://www.go-mono.com/download.html
|
||||
|
||||
The URLs for the sources are:
|
||||
|
||||
* MCS package (the Class Libraries, C# and VB.NET compiler
|
||||
and other assorted tools written in Managed code):
|
||||
|
||||
http://www.go-mono.com/archive/mcs-0.22.tar.gz
|
||||
|
||||
* Mono package (the Runtime engine and JIT compiler):
|
||||
|
||||
http://www.go-mono.com/archive/mono-0.22.tar.gz
|
||||
|
||||
RPM packages for this release can be downloaded from the web-page
|
||||
as well as from the 'Mono' channel on Red Carpet. Debian packages will
|
||||
appear on the download page later, as well as an installer for our
|
||||
Windows users.
|
||||
|
||||
Since last Thursday, 320 commits have been made to our CVS
|
||||
repository. These following hackers contributed to Mono since version
|
||||
0.21:
|
||||
|
||||
Aleksey Demakov, Alexandre Pigolkine, Atsushi Enomoto, Elan
|
||||
Feingeld, Dick Porter, Dietmar Maurer, Duncan Mak, Gonzalo
|
||||
Paniagua, Ian MacLean, Jackson Harper, Jean-Marc Andre, Jerome
|
||||
Laban, Lluis Sanchez, Martin Baulig, Miguel de Icaza, Nick
|
||||
Drochak, Paolo Molaro, Pedro Martinez, Per Ameng, Peter Williams,
|
||||
Rafael Teixeira, Reggie Burnett, Sebastien Pouliot, Tim Coleman
|
||||
and Zoltan Varga.
|
||||
|
||||
Highlights:
|
||||
|
||||
* The "MemoryStream" bug.
|
||||
This bug affected a lot of classes, and made them crashy,
|
||||
database code, XML parsing and a few others were
|
||||
crashing. Thanks to Gonzalo for fixing this bug.
|
||||
|
||||
* System.Data:
|
||||
More bug fixes from Aleksey and Tim.
|
||||
|
||||
* Reflection:
|
||||
Zoltan continues to provide fixes to our Reflection.Emit code
|
||||
to host IKVM.
|
||||
|
||||
* Remoting:
|
||||
Lluis added support for activation using activation
|
||||
attributes.
|
||||
|
||||
* PEToolkit:
|
||||
Jackson imported the PEAPI package from the Queensland
|
||||
University of Technology in Australia. This will replace the
|
||||
existing Mono.PEToolkit for our ILasm back-end.
|
||||
|
||||
* Windows Forms:
|
||||
More fixes from Reggie and Alexandre.
|
||||
|
||||
* System.Web.Mail:
|
||||
Per has been working on this namespace. He announces recently
|
||||
that all major parts of System.Web.Mail has now been implemented.
|
||||
|
||||
* System.Web.Mobile:
|
||||
Gaurav continues to make progress here.
|
||||
|
||||
* Misc:
|
||||
|
||||
Ian MacLean contributed a /compile flag to monoresgen and
|
||||
assorted bug-fixes and improvements from the rest of the team.
|
||||
|
||||
|
||||
My name is Duncan Mak, and I just made my first Mono release.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Hello everyone!
|
||||
|
||||
The Mono Team introduces the best Mono release so far we have
|
||||
done. Thanks to everyone who contributed fixes, code, ideas, and bug
|
||||
reports.
|
||||
|
||||
Mono 0.20 has been released, it is available at the usual location:
|
||||
|
||||
http://www.go-mono.com/download.html
|
||||
|
||||
This is a truly heroic release of Mono. Major architectural
|
||||
chunks that were missing, or were miss-implemented have been fixed in
|
||||
this release, and we are very proud of it. Please see the list of
|
||||
features, because there is no short way of introducing just how good
|
||||
this release is. A big thanks goes to Piers for setting up a
|
||||
Tinderbox that monitors problems with the Mono CVS repository.
|
||||
|
||||
We released packages for SuSE 8.0, Mandrake 8.2, and various
|
||||
Red Hat releases. It is also available from Red Carpet on the Mono
|
||||
channel.
|
||||
|
||||
Source code for Mono, MCS, the Mono Debugger, XSP is available as
|
||||
well from that web page. The sources are:
|
||||
|
||||
MCS package (Class Libraries, C# and VB.NET compiler and managed tools):
|
||||
|
||||
http://www.go-mono.com/archive/mcs-0.20.tar.gz
|
||||
|
||||
Mono package (Runtime engine, JIT compiler):
|
||||
|
||||
http://www.go-mono.com/archive/mono-0.20.tar.gz
|
||||
|
||||
XSP package (XSP test web server for ASP.NET webforms):
|
||||
|
||||
http://www.go-mono.com/archive/xsp-0.3.tar.gz
|
||||
|
||||
This release is brought to you by: Alvaro del Castillo, Alan Tam,
|
||||
Alp Toker, Alejandro Sánchez, Alexandre Pigolkin, Atsushi Enomoto,
|
||||
Brian Ritchie, Christopher Bockner, Daniel Lopez, Daniel Morgan,
|
||||
Dennis Hayes, Dick Porter, Dietmar Maurer, Duncan Mak, Gaurav Vaish,
|
||||
Gonzalo Paniagua, Jackson Harper, Jaime Anguiano, Jeff Stedfast,
|
||||
Johannes Roith, John Sohn, Jonathan Pryor, "Lee Mallabone, "Lluis
|
||||
Sanchez, "Marco Ridoni, Mark Crichton, Martin Baulig, Martin Willemoes
|
||||
Hansen, Miguel de Icaza, Mike Kestner, Nick Drochak, Paolo Molaro,
|
||||
Patrik Torstensson, Pedro Martinez, Per Arneng, Peter Williams, Petr
|
||||
Danecek, Piers Haken, Radek Doulik, Rafael Teixeira, Rodrigo Moya,
|
||||
Sebastien Pouliot, Tim Coleman, Ville Palo, and Zoltan Varga.
|
||||
|
||||
They commited 1810 changes to CVS patches in the past 33 days.
|
||||
|
||||
* New in this release
|
||||
|
||||
* Zoltan and IKVM
|
||||
|
||||
Zoltan's patches to run Jeroen's IKVM (the Java VM that
|
||||
translates JVM bytecodes into .NET bytecodes) are in.
|
||||
|
||||
* Remoting.
|
||||
|
||||
The remoting team's patches that were held off on the previous
|
||||
release are here. Lluis and Patrik have done a fantastic job
|
||||
in getting remoting to work. Many low-level runtime engine
|
||||
changes, and plenty of work on the class-library stuff.
|
||||
|
||||
Lluis has posted a couple of sample applications to the
|
||||
mailing list, you can try those out.
|
||||
|
||||
The new release includes a working BinaryFormatter and
|
||||
BinaryFormatterSink. It means that together with TcpChannel
|
||||
it is possible to make remote calls with any type of
|
||||
parameters and return values, including value types,
|
||||
MarshalByRefObject types (that are properly
|
||||
marshalled/unmarshalled), delegates, enums, etc.
|
||||
|
||||
RemotingConfiguration is partially implemented. It cannot read
|
||||
from config files, but manual configuration using the api is
|
||||
fully working.
|
||||
|
||||
Implemented full support for client activated types and for
|
||||
well known objects (both singleton and single call).
|
||||
|
||||
Lease manager fully working (it manages the lifetime of server
|
||||
objects).
|
||||
|
||||
Implemented interception of the new operator, so it is
|
||||
possible to create a remote object using "new", if the type is
|
||||
properly registered in RemotingConfiguration.
|
||||
|
||||
In Lluis' words: `Basically, 0.20 will have almost all needed
|
||||
for a distributed application with Remoting'
|
||||
|
||||
* New threading semantics, IO-layer
|
||||
|
||||
Dick Porter in a couple of weeks has heroically redone much of
|
||||
the threading support to match the .NET behavior (details are
|
||||
on the .NET threading book as posted on the Mono site).
|
||||
|
||||
He also did a lot of bug fixes in the IO/threading space. The
|
||||
threading implementation now contains a new and faster Monitor
|
||||
implementation, as well as a correct Pulse()/Wait()
|
||||
implementation.
|
||||
|
||||
GC thread finalization has been re-enabled. This means that
|
||||
finalizers will be ran on a separate thread, as done in the
|
||||
Microsoft.NET Framework. This might expose some bugs on
|
||||
existing finalizer code.
|
||||
|
||||
* Moved to NUnit2
|
||||
|
||||
Nick and Gonzalo helped us move to the new NUnit2 platform for
|
||||
all of our tests. A big applause goes to them.
|
||||
|
||||
* Cross Appdomain invocations work now.
|
||||
|
||||
ASP.NET and NUnit2 both used cross appdomain invocations, we
|
||||
have fixed a number of problems, and they are now functional.
|
||||
|
||||
The AppDomain fixes and the Remoting fixes have allowed us to
|
||||
remove a number of hacks in the ASP.NET implementation that
|
||||
were previously there.
|
||||
|
||||
Implemented CrossAppDomainChannel, for calls between domains.
|
||||
|
||||
* C# Compiler and Debugging.
|
||||
|
||||
When generating debugging information in the compiler (with
|
||||
-debug, -g or -debug+) the compiler will embed the debugging
|
||||
information into the resulting executable instead of
|
||||
generating a separate file. Very nice.
|
||||
|
||||
Generating debugging information has also improved vastly
|
||||
performance-wise, and now it is possible to always use
|
||||
debugging builds for software development.
|
||||
|
||||
A number of bugs were fixed on the compiler as well and
|
||||
by using the Mono profiler we have reduced the memory
|
||||
consumption and accelerated the compiler.
|
||||
|
||||
Thanks to Jackson, Martin, Paolo and for helping here.
|
||||
|
||||
* VB.NET Compiler.
|
||||
|
||||
Plenty of new features are included in the compiler in our
|
||||
path to conformance. See <FIXME:get-url-for-posting> for
|
||||
details on the status of the compiler, and the pieces missing.
|
||||
|
||||
* ILasm and Mono.PEToolkit.
|
||||
|
||||
Work on the IL assembler has resumed, but it is not yet ready
|
||||
for production use. The Mono IL Assembler uses the
|
||||
Mono.PEToolkit library done by Sergey and Jackson to
|
||||
manipulate CIL image files.
|
||||
|
||||
* Cryptographic work.
|
||||
|
||||
Sebastien has provided a cert2spc and secutil tools for
|
||||
certificate management. This is the first release that ships
|
||||
an assembly for System.Security
|
||||
|
||||
Also a new internal assembly used only on Windows allows Mono
|
||||
users to use the unmanaged crypto providers.
|
||||
|
||||
* System.XML
|
||||
|
||||
Atsushi has continued to improve the work on our XML
|
||||
implementation: fixing bugs and more closely matching the
|
||||
Microsoft implementation.
|
||||
|
||||
* More PowerPC/Alpha support.
|
||||
|
||||
Taylor Christopher has contributed more code generation macros
|
||||
for PPC and Laramie Leavitt for Alpha.
|
||||
|
||||
* System.XML.Xsl
|
||||
|
||||
Gonzalo continued the implementation of our XSLT transformation
|
||||
API (custom .NET functions are still missing though). It no
|
||||
longer uses temporary files to apply transformations. Thanks
|
||||
to an idea from Zdravko Tashev. Xslt Web controls work as
|
||||
part of this fix.
|
||||
|
||||
* ASP.NET
|
||||
|
||||
Gonzalo has cleaned up a lot the code base, and now our test
|
||||
server supports a --root and --virtual command line options
|
||||
for better control.
|
||||
|
||||
Also, now we generate a much nicer error page on errors. We
|
||||
are looking for volunteers to improve the default look of this
|
||||
page.
|
||||
|
||||
Authentication is now supported
|
||||
|
||||
* Mobile Controls.
|
||||
|
||||
Gaurav Vaish continues on his quest to complete the
|
||||
implementation of the Mobile controls. These controls are
|
||||
required to run a stock IBuySpy application.
|
||||
|
||||
* Class Libraries:
|
||||
|
||||
New Mono.Posix class library that contains classes for working
|
||||
on a Posix systems. Things like Unix domain sockets are here.
|
||||
|
||||
* System.Windows.Forms
|
||||
|
||||
Alexandre Pigolkine continues to contribute more code to our
|
||||
Windows.Forms implementation. Currently it only runs on
|
||||
Windows (or in Linux without GC enabled, due to the
|
||||
pthread/Wine threading library mismatch. This is being
|
||||
actively addressed as part of the Wine work due to the
|
||||
movement to the new thread implementation available in RH 8.1).
|
||||
|
||||
* Database providers
|
||||
|
||||
Christopher Bockner has updated his DB2 database provider (now
|
||||
with prepared statement functionality) and Tim Coleman has
|
||||
continued work on the Oracle database provider (welcome back
|
||||
Tim!)
|
||||
|
||||
* Database code.
|
||||
|
||||
Dan Morgan continues to develop core components in System.Data
|
||||
(and now we welcome Alan Tam to the System.Data core hackers)
|
||||
|
||||
The SQL# tool now supports MySQLNet, Npgsql, DB2Client, and
|
||||
Oracle clients.
|
||||
|
||||
* Runtime
|
||||
|
||||
mono --profile now performs memory allocation profiling too.
|
||||
|
||||
* Runtime fixes.
|
||||
|
||||
We now support multi-module with external file reference
|
||||
assemblies.
|
||||
|
||||
The above in English means that we can now run Eiffel.NET code
|
||||
in Mono.
|
||||
|
||||
* Monograph:
|
||||
|
||||
More statistics supported now.
|
||||
|
||||
* System.Web.Mail
|
||||
|
||||
Per has contributed the code for this namespace.
|
||||
|
||||
* Bugs
|
||||
|
||||
Plenty of bugs were closed.
|
||||
-------------------------------------------------------------------------
|
||||
Hello everyone!
|
||||
|
||||
We have made a new release of Mono available. Despite the fact
|
||||
that we just did Mono 0.18, this release is packed with new features.
|
||||
|
||||
* Availability.
|
||||
|
||||
Mono 0.19 is available in package format from:
|
||||
|
||||
http://www.go-mono.com/download.html
|
||||
|
||||
We released packages for SuSE 8.0, Mandrake 8.2, Debian and various
|
||||
Red Hat releases. It is also available from Red Carpet on the Mono
|
||||
channel.
|
||||
|
||||
Source code for Mono, MCS, the Mono Debugger, XSP is available as
|
||||
well from that web page.
|
||||
|
||||
* New in this release
|
||||
|
||||
* Remoting news:
|
||||
|
||||
Lluis has implemented and documented the Binary formatter
|
||||
Woohoo! He has done a lot of work as well to support
|
||||
remoting.
|
||||
|
||||
Patrik has also been working heavily on fixing a
|
||||
number of remoting related bugs and missing features.
|
||||
|
||||
Ajay also implemented 1-d array serialization in System.Xml
|
||||
|
||||
* New database provider: IBM DB2
|
||||
|
||||
Christopher Bockner has contributed a DB2 data
|
||||
provider for System.Data. We have a very complete
|
||||
range of data providers.
|
||||
|
||||
* System.Web.Mobile
|
||||
|
||||
Gaurav has started work on this assembly, this will
|
||||
allow us to run the unmodified reference ASP.NET
|
||||
applications that were designed to support Mobile
|
||||
browsing.
|
||||
|
||||
* System.Data and System.XML:
|
||||
|
||||
More implementation work on XmlDataDocument from Ville
|
||||
and plenty of fixes from Atsushi.
|
||||
|
||||
* MacOS patches:
|
||||
|
||||
Paolo integrated John Duncan's and Benjamin Reed
|
||||
patches to make Mono run on MacOS X out of the box.
|
||||
|
||||
* IsolatedStorage
|
||||
|
||||
The initial implementation of it was done by Jonathan
|
||||
Pryor and included in this release.
|
||||
|
||||
* Compilers:
|
||||
|
||||
More work on the Mono Visual Basic compiler (it is now
|
||||
included in the packages).
|
||||
|
||||
Plenty of bug fixes from Jackson, Miguel to the C#
|
||||
compiler.
|
||||
|
||||
Patches from Francesco and Daniel to the VB.NET
|
||||
support runtime.
|
||||
|
||||
* Debugger support
|
||||
|
||||
Plenty of updates to run the new Mono Debugger from Martin.
|
||||
|
||||
* Main missing bits:
|
||||
|
||||
Some of everyone's favorite patches or code chunks have not yet
|
||||
been integrated, hopefully Mono 0.20 will have them:
|
||||
|
||||
* Zoltan's patch to run IKVM is not yet on this release
|
||||
|
||||
* Some parts of Patrik's remoting code did not make it to the
|
||||
release either.
|
||||
|
||||
* Reggie's MySQL native provider is also missing.
|
||||
|
||||
Enjoy!
|
||||
Miguel.
|
||||
-------------------------------------------------------------------------
|
||||
Hello everyone!
|
||||
|
||||
We have made a new release of Mono available. Despite the fact
|
||||
that we just did Mono 0.18, this release is packed with new features.
|
||||
|
||||
* Availability.
|
||||
|
||||
Mono 0.19 is available in package format from:
|
||||
|
||||
http://www.go-mono.com/download.html
|
||||
|
||||
We released packages for SuSE 8.0, Mandrake 8.2, Debian and various
|
||||
Red Hat releases. It is also available from Red Carpet on the Mono
|
||||
channel.
|
||||
|
||||
Source code for Mono, MCS, the Mono Debugger, XSP is available as
|
||||
well from that web page.
|
||||
|
||||
* New in this release
|
||||
|
||||
* Remoting news:
|
||||
|
||||
Lluis has implemented and documented the Binary formatter
|
||||
Woohoo! He has done a lot of work as well to support
|
||||
remoting.
|
||||
|
||||
Patrik has also been working heavily on fixing a
|
||||
number of remoting related bugs and missing features.
|
||||
|
||||
Ajay also implemented 1-d array serialization in System.Xml
|
||||
|
||||
* New database provider: IBM DB2
|
||||
|
||||
Christopher Bockner has contributed a DB2 data
|
||||
provider for System.Data. We have a very complete
|
||||
range of data providers.
|
||||
|
||||
* System.Web.Mobile
|
||||
|
||||
Gaurav has started work on this assembly, this will
|
||||
allow us to run the unmodified reference ASP.NET
|
||||
applications that were designed to support Mobile
|
||||
browsing.
|
||||
|
||||
* System.Data and System.XML:
|
||||
|
||||
More implementation work on XmlDataDocument from Ville
|
||||
and plenty of fixes from Atsushi.
|
||||
|
||||
* MacOS patches:
|
||||
|
||||
Paolo integrated John Duncan's and Benjamin Reed
|
||||
patches to make Mono run on MacOS X out of the box.
|
||||
|
||||
* IsolatedStorage
|
||||
|
||||
The initial implementation of it was done by Jonathan
|
||||
Pryor and included in this release.
|
||||
|
||||
* Compilers:
|
||||
|
||||
More work on the Mono Visual Basic compiler (it is now
|
||||
included in the packages).
|
||||
|
||||
Plenty of bug fixes from Jackson, Miguel to the C#
|
||||
compiler.
|
||||
|
||||
Patches from Francesco and Daniel to the VB.NET
|
||||
support runtime.
|
||||
|
||||
* Debugger support
|
||||
|
||||
Plenty of updates to run the new Mono Debugger from Martin.
|
||||
|
||||
* Main missing bits:
|
||||
|
||||
Some of everyone's favorite patches or code chunks have not yet
|
||||
been integrated, hopefully Mono 0.20 will have them:
|
||||
|
||||
* Zoltan's patch to run IKVM is not yet on this release
|
||||
|
||||
* Some parts of Patrik's remoting code did not make it to the
|
||||
release either.
|
||||
|
||||
* Reggie's MySQL native provider is also missing.
|
||||
|
||||
Enjoy!
|
||||
Miguel.
|
||||
------------------------------------------------------------------------------
|
||||
Happy new year!
|
||||
|
||||
The Mono team is proud to release Mono 0.18, with plenty of bug
|
||||
fixes and improvements. If you are a happy 0.17 user, this
|
||||
release is a happiness extension release. Many bugs in the
|
||||
runtime, class libraries and C# compiler have been fixed.
|
||||
|
||||
Also, our special envoy in Japan has reported that there is
|
||||
some naming confussion about the naming of Mono, as can be
|
||||
seen in the following documentary material:
|
||||
|
||||
Atsushi Enomoto shows the source of confussion:
|
||||
|
||||
http://primates.ximian.com/~duncan/gallery/Duncan-in-Tokyo/DSCN0702
|
||||
|
||||
Nick and Duncan echo it:
|
||||
|
||||
http://primates.ximian.com/~duncan/gallery/Duncan-in-Tokyo/DSCN0703
|
||||
|
||||
* Availability
|
||||
|
||||
Mono 0.18 packages and source code is available for download from:
|
||||
|
||||
http://www.go-mono.com/download.html
|
||||
|
||||
Those using Red Carpet on Linux can install Mono 0.18 from
|
||||
the Mono channel. The packages have already been pushed for
|
||||
you.
|
||||
|
||||
At release time we have packages for Red Hat 8.0, 7.3,
|
||||
7.2 and 7.1 and Mandrake 8.2.
|
||||
|
||||
* Contributors to this release
|
||||
|
||||
This release is brought to you by:
|
||||
|
||||
Alejandro Sanchez, Alp Toker, Atsushi Enomoto, Cesar Octavio
|
||||
Lopez Netaren, Daniel Lopez (mod_mono), Daniel Morgan, Dennis
|
||||
Hayes, Dick Porter, Dietmar Maurer, Duncan Mak, Eduardo
|
||||
Garcia, Gaurav Vaish, Gonzalo Paniagua, Jackson Harper, Jaime
|
||||
Anguiano, Jeroen Janssen, Johannes Roith, Jonathan Pryor, Juli
|
||||
Mallett, Lluis Sanchez, Marco Ridoni, Martin Baulig, Miguel de
|
||||
Icaza, Nick Drochak, Paolo Molaro, Patrik Torstensson, Piers
|
||||
Haken, Rachel Hestilow, Rafael Teixeira, Ravi Pratap,
|
||||
Sebastian Pouliot, Tim Coleman, Tim Hayes, Ville Palo, Zoltan
|
||||
Varga.
|
||||
|
||||
* New in this release
|
||||
|
||||
VB.NET compiler:
|
||||
|
||||
Many improvements to the Mono VB.NET compiler.
|
||||
|
||||
ASP.NET:
|
||||
|
||||
Plenty of bug fixes in ASP.NET. Larger applications
|
||||
can now be run with it. The authentication system has
|
||||
been deployed, most changes are from Gonzalo.
|
||||
|
||||
We have a modified IBuySpy running (without Xslt)
|
||||
|
||||
If you want to run ASP.NET you can run it with either
|
||||
our XSP proof-of-concept server, or with Daniel's
|
||||
Apache module that can be fetched from CVS (module
|
||||
name: mod_apache)
|
||||
|
||||
Type Reflector:
|
||||
|
||||
A Console, Gtk# and Windows.Forms tool to browse
|
||||
compiled assemblies and examine the types on it, from
|
||||
Jonathan Pryor.
|
||||
|
||||
Moving to NUnit 2.0
|
||||
|
||||
Nick continues the work on moving our test suite to NUnit 2.0
|
||||
|
||||
Mobile.Controls:
|
||||
|
||||
Gaurav has started work on the Mobile controls, which
|
||||
are required to run some of the reference applications
|
||||
in full-mode like IBuySpy.
|
||||
|
||||
Remoting:
|
||||
|
||||
The remoting infrastructure has got a big boost from
|
||||
Lluis in this release.
|
||||
|
||||
System.Data/XML
|
||||
|
||||
Ville has been working on improving our System.Data
|
||||
classes in the XML assembly.
|
||||
|
||||
Crypto:
|
||||
|
||||
Plenty of new crypto from Sebastien as well. A new
|
||||
web page in our site can be used to track this.
|
||||
|
||||
http://www.go-mono.com/crypto.html
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Hello!
|
||||
|
||||
Version 0.17 of Mono has been released.
|
||||
@@ -106,7 +718,13 @@ Hello!
|
||||
Many regression tests have been added as well (Ville has been
|
||||
doing a great job here).
|
||||
|
||||
Brian also created a DB provider multiplexor (The ProviderFactory)
|
||||
|
||||
Stuart Caborn contributed Writing XML from a DataSet.
|
||||
Luis Fernandez contributed constraint handling code.
|
||||
|
||||
Also there is new a Gtk# GUI tool from Dan that can be used to
|
||||
try out various providers.
|
||||
|
||||
* System.XML:
|
||||
|
||||
|
||||
+20
-4
@@ -1,7 +1,7 @@
|
||||
AC_INIT(README)
|
||||
AC_CANONICAL_SYSTEM
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono, 0.17)
|
||||
AM_INIT_AUTOMAKE(mono, 0.23)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
#
|
||||
@@ -9,7 +9,9 @@ AM_MAINTAINER_MODE
|
||||
# compiling code that will embed Mono
|
||||
#
|
||||
libmono_cflags=""
|
||||
libmono_ldflags=""
|
||||
AC_SUBST(libmono_cflags)
|
||||
AC_SUBST(libmono_ldflags)
|
||||
|
||||
# Thread configuration inspired by sleepycat's db
|
||||
AC_MSG_CHECKING([host platform characteristics])
|
||||
@@ -19,7 +21,7 @@ case "$host" in
|
||||
AC_DEFINE(PLATFORM_WIN32)
|
||||
CC="gcc -mno-cygwin"
|
||||
HOST_CC="gcc"
|
||||
CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS"
|
||||
CPPFLAGS="$CPPFLAGS -DGC_WIN32_THREADS -DWIN32_THREADS"
|
||||
libdl=
|
||||
;;
|
||||
*-*-*bsd*)
|
||||
@@ -27,6 +29,7 @@ case "$host" in
|
||||
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
|
||||
libmono_cflags="-D_THREAD_SAFE"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
libmono_ldflags="-pthread"
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
AC_DEFINE(PTHREAD_POINTER_ID)
|
||||
libdl=
|
||||
@@ -35,6 +38,7 @@ case "$host" in
|
||||
platform_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -DMONO_USE_EXC_TABLES -D_GNU_SOURCE -D_REENTRANT -fexceptions"
|
||||
libmono_cflags="-DMONO_USE_EXC_TABLES -fexceptions -D_REENTRANT"
|
||||
libmono_ldflags="-lpthread"
|
||||
libdl="-ldl"
|
||||
;;
|
||||
*-*-solaris*)
|
||||
@@ -43,6 +47,16 @@ case "$host" in
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
;;
|
||||
*-*-darwin*)
|
||||
platform_win32=no
|
||||
CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_THREAD_SAFE"
|
||||
libmono_cflags="-D_THREAD_SAFE"
|
||||
LDFLAGS="$LDFLAGS -pthread"
|
||||
libmono_ldflags="-pthread"
|
||||
AC_DEFINE(NEED_LINK_UNLINK)
|
||||
AC_DEFINE(PTHREAD_POINTER_ID)
|
||||
libdl=
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([*** Please add $host to configure.in checks!])
|
||||
platform_win32=no
|
||||
@@ -81,7 +95,7 @@ AC_HEADER_STDC
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h)
|
||||
AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
|
||||
|
||||
# for mono/metadata/debug-symfile.c
|
||||
AC_CHECK_HEADERS(elf.h)
|
||||
@@ -487,7 +501,7 @@ i*86-*-*) TARGET=X86; arch_target=x86;;
|
||||
sparc*-*-*) TARGET=SPARC; arch_target=sparc; ACCESS_UNALIGNED="no";;
|
||||
#alpha*-*-linux* | alpha*-*-osf*) TARGET=ALPHA; ACCESS_UNALIGNED="no";;
|
||||
#m68k-*-linux*) TARGET=M68K;;
|
||||
macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | powerpc-*-sysv*) TARGET=POWERPC; arch_target=ppc;;
|
||||
macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | powerpc-*-sysv* | powerpc-*-darwin*) TARGET=POWERPC; arch_target=ppc;;
|
||||
arm-*-linux-* | armv4l-*-linux-*) TARGET=ARM; arch_target=arm; ACCESS_UNALIGNED="no";;
|
||||
s390-*-linux*) TARGET=S390; arch_target=s390; ACCESS_UNALIGNED="no";;
|
||||
esac
|
||||
@@ -517,6 +531,7 @@ AC_SUBST(LIBC)
|
||||
AC_SUBST(arch_target)
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(CPPFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
@@ -535,6 +550,7 @@ mono/arch/ppc/Makefile
|
||||
mono/arch/sparc/Makefile
|
||||
mono/arch/s390/Makefile
|
||||
mono/arch/arm/Makefile
|
||||
mono/arch/alpha/Makefile
|
||||
mono/interpreter/Makefile
|
||||
mono/tests/Makefile
|
||||
mono/benchmark/Makefile
|
||||
|
||||
+3
-1
@@ -9,6 +9,8 @@
|
||||
<dllmap dll="libpango-1.0-0.dll" target="libpango-1.0.so" />
|
||||
<dllmap dll="libatk-1.0-0.dll" target="libatk-1.0.so" />
|
||||
<dllmap dll="libgdk-win32-2.0-0.dll" target="libgdk-x11-2.0.so" />
|
||||
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk-pixbuf-2.0.so" />
|
||||
<dllmap dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so" />
|
||||
<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so" />
|
||||
<dllmap dll="libgtk-win32-2.0-0.dll" target="libgtk-x11-2.0.so" />
|
||||
<dllmap dll="oci" target="clntsh" />
|
||||
</configuration>
|
||||
+30
-11
@@ -7,23 +7,34 @@
|
||||
|
||||
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler, System" />
|
||||
<sectionGroup name="system.web">
|
||||
<section name="httpHandlers" type="System.Web.Configuration.HttpHandlersSectionHandler, System.Web" />
|
||||
<section name="httpModules" type="System.Web.Configuration.HttpModulesConfigurationHandler, System.Web" />
|
||||
<section name="machineKey" type="System.Web.Configuration.MachineKeyConfigHandler, System.Web" />
|
||||
<section name="authentication" type="System.Web.Configuration.AuthenticationConfigHandler, System.Web" />
|
||||
<section name="httpHandlers"
|
||||
type="System.Web.Configuration.HttpHandlersSectionHandler, System.Web" />
|
||||
<section name="httpModules"
|
||||
type="System.Web.Configuration.HttpModulesConfigurationHandler, System.Web" />
|
||||
<section name="machineKey"
|
||||
type="System.Web.Configuration.MachineKeyConfigHandler, System.Web" />
|
||||
<section name="authentication"
|
||||
type="System.Web.Configuration.AuthenticationConfigHandler, System.Web" />
|
||||
<section name="authorization"
|
||||
type="System.Web.Configuration.AuthorizationConfigHandler, System.Web" />
|
||||
<section name="globalization"
|
||||
type="System.Web.Configuration.GlobalizationConfigurationHandler, System.Web" />
|
||||
<section name="sessionState"
|
||||
type="System.Web.SessionState.SessionStateSectionHandler, System.Web" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
|
||||
<add verb="*" path="*.asax" type="System.Web.HttpForbiddenHandler" />
|
||||
<add verb="*" path="*.ascx" type="System.Web.HttpForbiddenHandler" />
|
||||
<add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler" />
|
||||
<add verb="GET,HEAD" path="*" type="System.Web.StaticFileHandler" />
|
||||
<add verb="*" path="*" type="System.Web.HttpMethodNotAllowedHandler" />
|
||||
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web" />
|
||||
<add verb="*" path="*.asax" type="System.Web.HttpForbiddenHandler, System.Web" />
|
||||
<add verb="*" path="*.ascx" type="System.Web.HttpForbiddenHandler, System.Web" />
|
||||
<add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler, System.Web" />
|
||||
<add verb="GET,HEAD" path="*" type="System.Web.StaticFileHandler, System.Web" />
|
||||
<add verb="*" path="*" type="System.Web.HttpMethodNotAllowedHandler, System.Web" />
|
||||
</httpHandlers>
|
||||
<httpModules>
|
||||
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
|
||||
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule, System.Web" />
|
||||
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule, System.Web" />
|
||||
</httpModules>
|
||||
<authentication mode="Forms">
|
||||
<forms name=".MONOAUTH" loginUrl="login.aspx" protection="All" timeout="30" path="/">
|
||||
@@ -33,6 +44,14 @@
|
||||
</forms>
|
||||
</authentication>
|
||||
<machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1" />
|
||||
<!-- Sample globalization settings
|
||||
<globalization requestEncoding="iso-8859-1"
|
||||
responseEncoding="iso-8859-1"
|
||||
fileEncoding="iso-8859-1"
|
||||
culture="en-US"
|
||||
uiculture="en-US" />
|
||||
-->
|
||||
<sessionState mode="InProc" />
|
||||
</system.web>
|
||||
|
||||
<appSettings>
|
||||
|
||||
+30
@@ -15,3 +15,33 @@ To publish changes:
|
||||
|
||||
cd web
|
||||
make push
|
||||
|
||||
############## Samples
|
||||
|
||||
|
||||
If you want to add a new item in the left menu
|
||||
you have to edit mono/doc/web/commands and add
|
||||
the entry there.
|
||||
|
||||
For new files you can add something as:
|
||||
level,entry,path_to_the_file,file.src
|
||||
|
||||
ex: 1,COBOL#,cobol.html,cobol.src
|
||||
|
||||
If you just want to add a link to the menu:
|
||||
1,MyEntry,URL
|
||||
|
||||
ex: 1,About Linux,http://www.linux.org
|
||||
|
||||
To test the results under Linux:
|
||||
1. Edit mono/doc/web/makefile
|
||||
|
||||
Delete all the references to class status
|
||||
and the deploy/index.rss as well as the
|
||||
mono.exe commands.
|
||||
|
||||
2. make
|
||||
3. Open your browser and point to the
|
||||
file:///(YOUR PATH HERE)mono/doc/web/deploy/index.html
|
||||
|
||||
|
||||
+356
-106
@@ -1,81 +1,235 @@
|
||||
* ADO.NET
|
||||
|
||||
The coordinator for the ADO.NET implementation is
|
||||
<a href="mailto:[email protected]">Rodrigo Moya</a>,
|
||||
with the collaboration of:
|
||||
<a href="mailto:[email protected]">Daniel Morgan</a>,
|
||||
<a href="mailto:[email protected]">Tim Coleman</a>,
|
||||
<a href="mailto:[email protected]">Brian Ritchie</a>, and
|
||||
<a href="mailto:[email protected]">Vladimir Vukicevic</a>.
|
||||
<p>Mono's ADO.NET Developers:
|
||||
|
||||
<table border=1>
|
||||
|
||||
<tr>
|
||||
<td><b>Developer</b></td>
|
||||
<td><b>Email</b></td>
|
||||
<td><b>Contribution</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Rodrigo Moya</td>
|
||||
<td>rodrigo -AT-<br> ximian.comNOSPAM</td>
|
||||
<td>ADO.NET coordinator,<br> OLE DB provider,<br> and tests</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Daniel Morgan</td>
|
||||
<td>danmorg -AT-<br> sc.rr.comNOSPAM</td>
|
||||
<td>MySQL, PostgreSQL, <br>Oracle providers,<br> and tests</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Tim Coleman</td>
|
||||
<td>tim -AT- <br>timcoleman.comNOSPAM</td>
|
||||
<td>Microsoft SQL Server, <br>Sybase, <br>TDS providers,<br> Oracle,
|
||||
<br>and tests.<br>
|
||||
He has
|
||||
contributed <br>to other parts <br>of Mono too, <br>such as,
|
||||
<br>EnterpriseServices,
|
||||
XML, <br>and WebServices.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Brian Ritchie</td>
|
||||
<td>brianlritchie -AT-<br> hotmail.comNOSPAM</td>
|
||||
<td>ODBC provider <br>and the ProviderFactory <br>in Mono.Data</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Vladimir Vukicevic</td>
|
||||
<td>vladimir -AT-<br> pobox.comNOSPAM</td>
|
||||
<td>SQL Lite provider. <br> He has contributed to GTK# <br>and mPhoto too.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Christopher Bockner</td>
|
||||
<td>cleared -AT-<br> rogers.comNOSPAM</td>
|
||||
<td>IBM DB2 Universal <br>Database provider</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Ville Palo</td>
|
||||
<td>vi64pa -AT-<br> koti.soon.fiNOSPAM</td>
|
||||
<td>XML stuff <br>in System.Data <br>including DataSet <br>
|
||||
and XmlDataDocument, <br>and tests</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Gonzalo Paniagua Javier</td>
|
||||
<td>gonzalo -AT-<br> ximian.comNOSPAM</td>
|
||||
<td>Integration between <br>System.Web and <br>System.Data</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Gaurav Vaish</td>
|
||||
<td>gvaish -AT-<br> iitk.ac.inNOSPAM</td>
|
||||
<td>Web controls</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Phillip Jerkins</td>
|
||||
<td>Phillip.Jerkins -AT-<br> morgankeegan.comNOSPAM</td>
|
||||
<td>Named Instance support <br>in System.Data.SqlClient</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
** Bugs and Feature Requests
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Bugs with Mono or any data provider in Mono should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have a Bugzilla user account, it is free
|
||||
and easy to create
|
||||
one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
<li>Any RFE (Request For Enhancement) for features missing or new functionality
|
||||
should be entered as a bug in Bugzilla too</li>
|
||||
|
||||
* Action plan
|
||||
</ul>
|
||||
|
||||
** ADO.NET Data Providers
|
||||
|
||||
<p>List of ADO.NET Data Providers working in Mono:
|
||||
|
||||
<ul>
|
||||
<li><a href="http://www.go-mono.com/ibmdb2.html">IBM DB2 Universal Database</a></li>
|
||||
<li><a href="http://www.go-mono.com/mysql.html">MySQL</a></li>
|
||||
<li><a href="http://www.go-mono.com/odbc.html">ODBC</a></li>
|
||||
<li><a href="http://www.go-mono.com/oracle.html">Oracle</a></li>
|
||||
<li><a href="http://www.go-mono.com/oledb.html">OLE DB</a></li>
|
||||
<li><a href="http://www.go-mono.com/postgresql.html">PostgreSQL</a></li>
|
||||
<li><a href="http://www.go-mono.com/sqlclient.html">Microsoft SQL Server</a></li>
|
||||
<li><a href="http://www.go-mono.com/sqlite.html">SQL Lite</a></li>
|
||||
<li><a href="http://www.go-mono.com/sybase.html">Sybase</a></li>
|
||||
<li><a href="http://www.go-mono.com/tdsclient.html">TDS Generic</a></li>
|
||||
</ul>
|
||||
|
||||
<p>The current plan to implement ADO.NET is as follows:
|
||||
<p>Providers which we do not have, but we would like to have. Currently,
|
||||
some of these databases are supported via the ODBC or OLE DB providers.
|
||||
|
||||
<ul>
|
||||
<li>Either create ADO.NET providers or modify pre-exiting ADO.NET providers to
|
||||
work with Mono
|
||||
|
||||
<ul>
|
||||
<li>Create ADO.NET Providers
|
||||
<ul>
|
||||
<li><a href="http://msdn.microsoft.com/library/en-us/dnsql2k/html/sqlxml_intromanagedclasses.asp?frame=true">Managed Classes for SqlXml</a> which is
|
||||
a .NET data provider for retrieving XML data from a Microsoft SQL Server 2000 database. The System.Data.SqlClient provider
|
||||
in Mono can be used as a starting point at mcs/class/System.Data/System.Data.SqlClient.</li>
|
||||
<li><a href="http://www.hughes.com.au/">miniSQL</a></li>
|
||||
<li><a href="http://www.sleepycat.com/">BerkeleyDB (Sleepycat)</a></li>
|
||||
<li><a href="http://www.sapdb.org/">SapDB</a></li>
|
||||
<li><a href="http://www-3.ibm.com/software/data/informix/">Informix</a></li>
|
||||
<li><a href="http://msdn.microsoft.com/vfoxpro/">Foxpro</a></li>
|
||||
<li>Microsoft Access - could be done by creating C# bindings to <a href="http://mdbtools.sourceforge.net">MDB Tools</a></li>
|
||||
<li>dbase or xbase type database files</li>
|
||||
<li>Others are welcome</li>
|
||||
</ul>
|
||||
|
||||
<p>External Projects that have created ADO.NET Providers that work on Mono:
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a href="http://www.go-mono.com/firebird.html">Firebird Interbase</a></li> is a
|
||||
Firebird SQL Managed data provider. It can be used with Interbase databases too. It
|
||||
is written in 100%C# and does not require a client library. Works on .NET and Mono.</a>
|
||||
<li><a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a> is a
|
||||
PostgreSQL Managed data provider written
|
||||
in 100% C#, does not require a client library, and works on .NET and Mono</li>
|
||||
<li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> is a
|
||||
MySQL Managed data provider written in 100% C#, does not
|
||||
require a client library, and works on .NET and Mono</li>
|
||||
</ul>
|
||||
|
||||
** Tools
|
||||
|
||||
<p>Some tools that can be used for ADO.NET and other technologies (ASP.NET, XML, etc).
|
||||
|
||||
<ul>
|
||||
<li><b>SQL# CLI</b> - a SQL query tool with a command-line interface.
|
||||
It can be used to enter and execute SQL statements or
|
||||
execute a batch of SQL commands from a file. It can
|
||||
be used to test connection strings, connect to various ADO.NET
|
||||
providers, save output to text, html, or xml. It is a work-in-progress.
|
||||
The SQL# CLI is distributed with the
|
||||
Mono runtime and class libraries as an executable assembly sqlsharp.exe.
|
||||
The source to SQL# CLI can be found in the mcs source at
|
||||
mcs/tools/SqlSharp/SqlSharpCli.cs
|
||||
</li>
|
||||
|
||||
<li><p><b>SQL# GUI - a graphical SQL query tool</b> allows a user
|
||||
to enter SQL commands in a top panel which is a text editor. It
|
||||
has a toolbar and menu for various tasks, such as, executing
|
||||
SQL commands one-at-a-time or in a batch. The results would appear
|
||||
in a bottom panel in a grid or could be saved to a file (xml, html, csv).
|
||||
Also, the bottom panel would allow logging of SQL command executed.
|
||||
Currently, there is a <a href="http://go-mono.com/images/sqlsharp.png">SQL# For GTK#</a> which
|
||||
provides a GUI interface using the <a href="http://gtk-sharp.sourceforge.net">Gtk#</a> toolkit. SQL# For GTK#
|
||||
is a work-in-progress and can be found in the mcs source at
|
||||
mcs/tools/SqlSharp/gui/gtk-sharp</li>
|
||||
</ul>
|
||||
|
||||
<p>Tools we would like to have, but they have not been created yet:
|
||||
|
||||
<ul>
|
||||
<li><b>XML Schema Definition tool</b> <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconxmlschemadefinitiontoolxsdexe.asp">xsd.exe</a> needs
|
||||
to be created. Maybe this TODO item should be at the System.XML web page instead.
|
||||
|
||||
<ul>
|
||||
<li><a href="http://www.go-mono.com/mysql.html">MySQL</a>
|
||||
<li><a href="http://www.go-mono.com/odbc.html">ODBC</a>
|
||||
<li><a href="http://www.go-mono.com/oracle.html">Oracle</a>
|
||||
<li><a href="http://www.go-mono.com/oledb.html">OLE DB</a>
|
||||
<li><a href="http://www.go-mono.com/postgresql.html">PostgreSQL</a>
|
||||
<li><a href="http://www.go-mono.com/sqlclient.html">Microsoft SQL Server</a>
|
||||
<li><a href="http://www.go-mono.com/sqlite.html">SQL Lite</a>
|
||||
<li><a href="http://www.go-mono.com/sybase.html">Sybase</a>
|
||||
<li><a href="http://www.go-mono.com/tdsclient.html">TDS Generic</a>
|
||||
<li>Providers which we do not have, but we would like to have. Currently,
|
||||
some of these databases are supported via the ODBC or OLEDB providers.
|
||||
<ul>
|
||||
<li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a>
|
||||
<li><a href="http://www.hughes.com.au/">miniSQL</a></li>
|
||||
<li><a href="http://www.sleepycat.com/">BerkeleyDB (Sleepycat)</a></li>
|
||||
<li><a href="http://www.sapdb.org/">SapDB</a></li>
|
||||
<li>Microsoft Access - could be done by creating C# bindings to <a href="http://mdbtools.sourceforge.net">MDB Tools</a></li>
|
||||
<li>dbase or xbase type database files</li>
|
||||
<li>Others are welcome</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<br>
|
||||
<li>Modify Pre-existing ADO.NET Providers to work with Mono. This may
|
||||
require fixing or implementing areas of Mono too.
|
||||
<ul>
|
||||
<li><a href="http://www.go-mono.com/firebird.html">Firebird Interbase</a></li>
|
||||
<li><a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a> is a PostgreSQL Managed data provider written
|
||||
in 100% C# and does not require a client library </li>
|
||||
<li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> is a MySQL Manager data provider written in 100% C# and does not
|
||||
require a client library</li>
|
||||
<li><a href="http://sourceforge.net/projects/mysqldrivercs/">MySQLDriverCS</a> is a MySQL data provider written in C#</li>
|
||||
|
||||
</ul>
|
||||
<li>This tool
|
||||
would work like the xsd.exe tool included with
|
||||
the .NET Framework. The Xsd.exe tools has the
|
||||
following uses:
|
||||
<ul>
|
||||
<li><b>XDR to XSD</b> - used to generate an XML schema from an XDR (XML Data Reduced schema) file.
|
||||
XDR was used by Microsoft prior to XSD becoming a W3C recommendation. So, this needs
|
||||
to be supported for legacy reasons</li>
|
||||
<li><b>XML to XSD</b> - used to generate an XML schema from an XML file</li>
|
||||
<li><b>XSD to DataSet</b> - used to generate DataSet classes from an XSD schema file. The
|
||||
DataSet classes created can then be used with XML data</li>
|
||||
<li><b>XSD to Classes</b> - used to generate classes from an XSD schema file. The
|
||||
classes created can be used with System.XML.Serialization.XMLSerializer
|
||||
to read and write XML code that follows the schema</li>
|
||||
<li><b>Classes to XSD</b> - used to generate an XML schema
|
||||
from type(s) in a assembly file. The
|
||||
XML schema created by the tool defines the XML format used
|
||||
by System.XML.Serialization.XMLSerializer</li>
|
||||
</ul>
|
||||
<li>Xsd.exe is used to manipulate XML schemas that
|
||||
follow the http://www.w3.org/XML/Schema">XML Schema Definition (XSD)</a> language
|
||||
recommended by the <a href="http://w3.org/">World Wide Web Consortium (W3C)</a></li>
|
||||
|
||||
<li>How this tool could be created:
|
||||
<ul>
|
||||
<li>Write xsd.exe in C# and run on Mono</li>
|
||||
<li>Make sure we have XML Schema support in System.Xml.Schema. Currently,
|
||||
it is wrapped around libxlst</li>
|
||||
<li>XML serialization support in System.Data classes</li>
|
||||
<li>Create the TypedDataSetGenerator class in System.Data</li>
|
||||
<li>Using CodeDOM or Reflection.Emit to create code</li>
|
||||
<li>Make sure DataSet, XmlDataDocument, and related classes
|
||||
are implemented fully</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<li>Create Tools for Configuration, Testing, and Entering SQL Queries
|
||||
<ul>
|
||||
<li><b>SQL# CLI - a command-line tool</b> written in C# to
|
||||
execute SQL commands,
|
||||
test connection strings, and connect to various ADO.NET
|
||||
providers in Mono. The SQL# CLI can be found in
|
||||
mcs/tools/SqlSharp/SqlSharpCli.cs</li>
|
||||
<li><p><b>SQL# GUI - a GUI tool</b> written in C# to
|
||||
execute SQL commands.
|
||||
Currently, there is SQL# For GTK# which
|
||||
can be found at
|
||||
mcs/tools/SqlSharp/gui/gtk-sharp
|
||||
It has a SQL editor with
|
||||
syntax hi lighting of SQL keywords</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><b>Application XML Configuration File Editor</b> - a tool
|
||||
to create and edit an application configuration file, such as,
|
||||
we have a .net application named Accouting.exe, the tool could edit
|
||||
the application configuration file Accounting.exe.config so a user could
|
||||
connect to the database used by the program. This tool has not
|
||||
been created.</li>
|
||||
|
||||
<li><b>Configuration Command-Line and GUI Tools for ADO.NET</b>.
|
||||
These tools have not been started. The tools would be written in
|
||||
C# and run on Mono. The
|
||||
configuration tool can be used to do the following:
|
||||
<ul>
|
||||
<li>bebased on the Application XML Configuration File Editor</li>
|
||||
<li>setup DSNs for the ODBC and OLE-DB
|
||||
providers and configurations for
|
||||
their underlying libraries (unixODBC and libgda)</li>
|
||||
@@ -85,36 +239,85 @@
|
||||
freetds.conf for Microsoft SQL Server and Sybase</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
|
||||
<p>Variouls ADO.NET Providers have been created: PostgreSQL, MySQL, Sybase, SQL Lite,
|
||||
Microsoft SQL Server, OLE DB, ODBC, and TDS Generic. See their respective web page for
|
||||
more information.
|
||||
</ul>
|
||||
|
||||
** Extra Classes in Mono ADO.NET
|
||||
|
||||
<p>An ADO.NET <a href="http://www.go-mono.com/provider-factory.html">Provider Factory</a>
|
||||
was created by Brian Ritchie. The
|
||||
Provider Factory is a way to dynamically create
|
||||
connections, commands, parameters, and data adapters based on configuration
|
||||
information.
|
||||
|
||||
** Current Status
|
||||
|
||||
<p>Various ADO.NET Providers have been created at various stages of
|
||||
development including:
|
||||
Firebird/Interbase, IBM DB2 Universal Database, MySQL, ODBC, OLE DB, Oracle,
|
||||
PostgreSQL, SQL Lite, Sybase, Microsoft SQL Server, and TDS Generic.
|
||||
See their respective web page for more information.
|
||||
|
||||
<p><b>Data Relations</b> via DataRelation, DataRelationCollection, and
|
||||
other classes have not been implemented
|
||||
|
||||
<p><b>Constraints</b> need lots of work
|
||||
|
||||
<p><b>XML Schema Definition tool</b> xsd.exe that is included
|
||||
in the .NET Framework has not been created for Mono
|
||||
|
||||
<p><b>TypeDataSetGenerator</b> needs to be stubbed and implemented.
|
||||
|
||||
<p><b>DataSet, DataAdaptor, DataTable, DataRelation, DataRow, DataColumn,
|
||||
DataColumnCollection, DataRowCollection, and others</b> need more work. There are
|
||||
many classes that are just stubs and need to be implemented.
|
||||
many classes that are just stubs and need to be implemented. Ville Palo has been
|
||||
doing much testing here.
|
||||
|
||||
<p><b>XML support in System.Data</b> needs work. This involves working on
|
||||
the classes: DataSet, XmlDataDocument, and the method ExecuteXmlReader() that
|
||||
exists in a provider's class that implements IDbCommand, and others.
|
||||
Stuart Caborn has started the XML support in a DataSet. Tim Coleman started
|
||||
XML support in the ExecuteXmlReader() in a SqlCommand.
|
||||
|
||||
<p><b>ADO.NET Provider Factory</b> has been started by Brian Ritchie. The
|
||||
Provider Factory is used to dynamically create
|
||||
connections, commands, parameters, and data adapters based on configuration information. This
|
||||
provider factory can also provide utility functions needed by a lot of
|
||||
providers but are not exposed via the provider.
|
||||
XML support in the ExecuteXmlReader() in a SqlCommand. Ville Palo has been
|
||||
heavily modifying DataSet, XmlDataDocument, and other classes for reading
|
||||
and writing XML. XML Serialization support in DataSet needs to be implemented.
|
||||
|
||||
<p><b>Integration with ASP.NET</b> has not been started, such as, data binding
|
||||
to a System.Web.UI.WebControls.DataGrid. This may involve implementing many classes
|
||||
in System.Web and System.Data. Gonzalo, Gaurav, Leen, Patrik, Duncan, and others are
|
||||
working very hard on the ASP.NET support. If you want to help,
|
||||
contact <a href="mailto:[email protected]">Gonzalo Paniagua Javier</a>
|
||||
<p><b>Integration with ASP.NET</b> has been created. Data binding of
|
||||
a DataTable in a DataSet to a System.Web.UI.WebControls.DataGrid works. Data binding
|
||||
of other types works too.
|
||||
|
||||
<p><b>Database Access from ASP.NET</b>:
|
||||
<ul>
|
||||
<li>Take a look at xsp in cvs and look at the examples in test: dbpage1.aspx
|
||||
and dbpage2.aspx:
|
||||
<ul>
|
||||
<li>Notice that the namespace System.Data is imported via <b>import</b></li>
|
||||
<li>A NameValueCollection is gotten using ConfigurationSettings.AppSetings. These
|
||||
settings are gotten from the file server.exe.config which is a XML file. The XML
|
||||
file has a section appSettings. In the appSettings section, you have keys
|
||||
for DBProviderAssembly, DBConnectionType, and DBConnectionString.
|
||||
<ul>
|
||||
<li><b>DBProviderAssembly</b> is the assembly of the ADO.NET provider.
|
||||
For example:
|
||||
"Mono.Data.PostgreSqlClient"</li>
|
||||
<li><b>DBConnectionType</b> is the System.Type of the class that
|
||||
implements System.Data.IDbConnection that is found
|
||||
in the DBProviderAssembly.
|
||||
For example:
|
||||
"Mono.Data.PostgreSqlClient.PgConnection"</li>
|
||||
<li><b>DBConnectionString</b> is the ConnectionString to set to the
|
||||
IDbConnection object to use in opening a connection to a data source.
|
||||
For Example:
|
||||
"hostaddr=127.0.0.1;user=monotest;password=monotest;dbname=monotest"</li>
|
||||
</ul>
|
||||
<li>The function GetConnectionData() gets the database provider assembly, connection type,
|
||||
and connection string parameters if they exist; otherwise, it uses default values. This is
|
||||
done during the loading of the web page.</li>
|
||||
<li>With the connection parameters, the assembly is loaded, the connection type is verified that
|
||||
it implements IDbConnection and an instance of the class can be created, creates a instance
|
||||
of the class, sets the connection string, and opens the connection.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p><b>Integration with Windows.Forms</b> has not been started, such as, data binding
|
||||
to a System.Windows.Forms.DataGrid. This may involve implementing many classes
|
||||
@@ -124,33 +327,12 @@
|
||||
has not been started, such as, data binding
|
||||
to a GtkTreeView. This may involve creating new classes
|
||||
to go between the glist data model and the ADO.NET data model.
|
||||
Mike Kestner would be the best person to ask for help on GTK#.
|
||||
Mike Kestner or Rachel Hestilov would be the best people to ask for help on GTK#.
|
||||
|
||||
<p><b>Integration with QT#</b> has not been started. Any information on
|
||||
how this can be done is appreciated. Adam Treat would be the best
|
||||
person to ask about QT#.
|
||||
|
||||
<p><b>Integration with GDA#</b> has not been started. It is
|
||||
included in the GTK# project, GDA#
|
||||
does not require GTK+ nor GNOME. GDA# is C# bindings
|
||||
to <a href="http://www.gnome-db.org/">GDA</a> which
|
||||
is an ADO/OLE-DB like layer for Linux provided as a C library. Classes
|
||||
that would bind data between the ADO.NET data model and the GDA data model will
|
||||
need to be created. Rodrigo Moya is the best person to contact about this.
|
||||
|
||||
<p><b>Integration with GnomeDb#</b> has not been started. It is
|
||||
included in the GTK# project and uses GDA# for its data access model.
|
||||
Creating classes to bind data between the data model in ADO.NET
|
||||
and the data model that exists in GDA# and GnomeDb# will
|
||||
need to be started. GnomeDb# is C# bindings to
|
||||
<a href="http://www.gnome-db.org/">GnomeDb</a> which uses
|
||||
<a href="http://www.gnome-db.org/">GDA</a> as its data access layer. GnomeDb
|
||||
is a C API in a library that contains
|
||||
gtk+ widgets (GUI controls) for data access. There are some nifty widgets
|
||||
(GUI controls) that can be used, such as, GnomeDbGrid, GnomeDbBrowswer,
|
||||
GnomeDbSqlEditor, GnomeDbList, GnomeDbLogin, GnomeDbReportEditor, GnomeDbTableEditor,
|
||||
GnomeDbCombo, and GnomeDbForm. Rodrigo Moya is the best person to contact.
|
||||
|
||||
<p><b>Building System.Data</b>
|
||||
|
||||
<p>The System.Data.dll gets built with the rest of the class library.
|
||||
@@ -194,3 +376,71 @@
|
||||
</pre>
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
<li>Testing connection-oriented classes are done
|
||||
via the provider specific tests
|
||||
found in the mcs source at mcs/class</br>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td><b>Name</b></td>
|
||||
<td><b>Assembly /</br> Namespace</b></td>
|
||||
<td><b>Test</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Microsoft</br> SQL</br> Server</br></td>
|
||||
<td>System.Data /</br> System.Data.SqlClient</td>
|
||||
<td>SqlTest.cs at</br> System.Data/Test</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>PostgreSQL</br> (Mono)</td>
|
||||
<td>Mono.Data.PostgreSqlClient /</br> Mono.Data.PostgreSqlClient</td>
|
||||
<td>PostgresTest.cs at</br> System.Data/Test</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>MySQL</br> (Mono)</td>
|
||||
<td>Mono.Data.MySql /</br> Mono.Data.MySql</td>
|
||||
<td>MySqlTest.cs at</br> Mono.Data.MySql/Test</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Oracle</br> (Mono)</td>
|
||||
<td>System.Data.OracleClient /</br> System.Data.OracleClient</td>
|
||||
<td>TestOracleClient.cs at</br> System.Data.OracleClient</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>ODBC</br> (Mono)</td>
|
||||
<td>System.Data.OracleClient /</br> System.Data.OracleClient</td>
|
||||
<td>TestOracleClient.cs at</br> System.Data.OracleClient</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<li><a href="http://www.go-mono.com/testing.html">Testing non-connection classes</a> are
|
||||
done via mono's modified version of NUnit.
|
||||
<ul>
|
||||
<li>To run all the NUnit tests for Mono, you need the mcs source. cd to the root
|
||||
of the mcs source. To run it:
|
||||
<ul>
|
||||
<li>On Linux: make -f makefile test</li>
|
||||
<li>On Windows: make test</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>If you just want to run the NUnit tests for System.Data, you would cd into
|
||||
the mcs source at class/System.Data/Test and run it:
|
||||
<ul>
|
||||
<li>On Linux: make -f makefile test</li>
|
||||
<li>On Windows: make test</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+33
-56
@@ -9,8 +9,8 @@
|
||||
|
||||
There is work underway for both systems. The Web Forms
|
||||
support is more advanced at this point, and various ".aspx"
|
||||
programs can be run using the Mono runtime and the XSP page
|
||||
parser.
|
||||
programs can be run using the Mono runtime (embedded into
|
||||
either the XSP server or the mod_mono Apache module).
|
||||
|
||||
We are now working bug fixing and adding missing features
|
||||
after making the whole pipeline compatible with MS.
|
||||
@@ -21,41 +21,6 @@
|
||||
Web Services support. Work for the supporting class libraries
|
||||
just started recently.
|
||||
|
||||
* Web Forms: The pieces
|
||||
|
||||
There are a couple of components to the puzzle:
|
||||
|
||||
<ul>
|
||||
* .aspx page parser (converts .aspx to C# code).
|
||||
|
||||
* System.Web.HttpRuntime support.
|
||||
|
||||
* Web controls (System.Web.UI.HtmlControls and
|
||||
System.Web.UI.WebControls).
|
||||
|
||||
* Underlying infrastructure for the controls (System.Web.UI).
|
||||
|
||||
* HttpRuntime.ProcessRequest is the core of the ASP.NET
|
||||
implementation.
|
||||
</ul>
|
||||
|
||||
|
||||
Gonzalo has been working on an ASP.NET parser that takes .aspx
|
||||
files and generated the code required to run them (the code lives in
|
||||
module `xsp' along with a little web server for testing).
|
||||
|
||||
Most of the runtime support was written by Patrik Torstensson
|
||||
(now at Intel). This was interesting, because in order to implement
|
||||
some of its features, Patrik had to go into the runtime/JIT engine and
|
||||
he spent a few weeks doing work there.
|
||||
|
||||
The classes for running ASP.NET are being actively written.
|
||||
Gaurav, Leen and Patrik worked in the core of the classes
|
||||
required to run ASP.NET web application as well as a small
|
||||
embeddable web server.
|
||||
|
||||
Duncan got our System.Web assembly to compile.
|
||||
|
||||
** HttpRuntime
|
||||
|
||||
Patrik has authored most of the HttpRuntime support (both on
|
||||
@@ -104,29 +69,41 @@
|
||||
over the web probably do not want to use direct ASP.NET but a
|
||||
wrapper around it.
|
||||
|
||||
** Roadmap
|
||||
* Web Forms: The pieces (historical)
|
||||
|
||||
1. The Parser.
|
||||
There are a couple of components to the puzzle:
|
||||
|
||||
2. Get the parser to generate output compatible with ASP.NET.
|
||||
|
||||
3. Run the sample output with the real Microsoft runtime
|
||||
but using our generated page.
|
||||
|
||||
4. Run the sample with our classes with the .NET runtime.
|
||||
|
||||
5. Run the samples with our classes with the our runtime (without
|
||||
using HttpRuntime).
|
||||
|
||||
6. Finish HttpRuntime.
|
||||
<ul>
|
||||
* .aspx page parser (converts .aspx to C# code).
|
||||
|
||||
7. Running our sample code with our classes with our runtime.
|
||||
|
||||
8. Debug and add missing features.
|
||||
|
||||
We are in step 8. Among the missing features: server side includes,
|
||||
better caching, some configuration stuff, more validators...
|
||||
* System.Web.HttpRuntime support.
|
||||
|
||||
* Web controls (System.Web.UI.HtmlControls and
|
||||
System.Web.UI.WebControls).
|
||||
|
||||
* Underlying infrastructure for the controls (System.Web.UI).
|
||||
|
||||
* HttpRuntime.ProcessRequest is the core of the ASP.NET
|
||||
implementation.
|
||||
</ul>
|
||||
|
||||
|
||||
Gonzalo has been working on an ASP.NET parser that takes .aspx
|
||||
files and generated the code required to run them (the code lives in
|
||||
module `xsp' along with a little web server for testing).
|
||||
|
||||
Most of the runtime support was written by Patrik Torstensson
|
||||
(now at Intel). This was interesting, because in order to implement
|
||||
some of its features, Patrik had to go into the runtime/JIT engine and
|
||||
he spent a few weeks doing work there.
|
||||
|
||||
The classes for running ASP.NET are being actively written.
|
||||
Gaurav, Leen and Patrik worked in the core of the classes
|
||||
required to run ASP.NET web application as well as a small
|
||||
embeddable web server.
|
||||
|
||||
Duncan got our System.Web assembly to compile.
|
||||
|
||||
** How to Help
|
||||
|
||||
Testing and fixing HtmlControls, WebControls and validators is an
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
A Retargetable C Compiler - Design and Implementation: C. Fraser, David
|
||||
Hanson
|
||||
|
||||
* Threading
|
||||
|
||||
.NET Multithreading: Alan L. Dennis (ISBN 1-930110-54-5)
|
||||
|
||||
* Reference Manuals
|
||||
|
||||
<a
|
||||
@@ -34,4 +38,4 @@
|
||||
MIPS Processor supplement</a>
|
||||
|
||||
<a href="http://www.sparc.org/standards/V8.pdf">The SPARC Architecture
|
||||
Manual Version 8</a>
|
||||
Manual Version 8</a>
|
||||
@@ -35,6 +35,9 @@
|
||||
<li><a
|
||||
href="http://www.go-mono.com/class-status-System.Runtime.Serialization.Formatters.Soap.html">System.Runtime.Serialization.Formatters.Soap</a>.
|
||||
|
||||
<li><a
|
||||
href="http://www.go-mono.com/class-status-System.Security.html">System.Security</a>:
|
||||
Xml Signature Security classes, also check the <a href="crypto.html">Cryptography status pages</a>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
+11
-33
@@ -8,53 +8,31 @@
|
||||
multilingual documentation makes for significant additional text.
|
||||
|
||||
With these considerations in mind, Mono will use external XML files
|
||||
for type documentation, rather than documenting the source inline.
|
||||
|
||||
for type documentation, rather than documenting the source
|
||||
inline. The XML file format used is inspired by the XML format used
|
||||
to document the ECMA APIs.
|
||||
|
||||
Several tools will be created for managing, verifying, generating,
|
||||
and updating class library documentation, including:
|
||||
|
||||
<ul>
|
||||
<li><a href="#monodoc">MonoDoc - A graphical documentation editor and viewer.</a></li>
|
||||
<li><a href="#mkmaster">MkMaster - A command line tool to feed stub information to MonoDoc.</a></li>
|
||||
<li><a href="#aspnet">An ASP.NET documentation editor.</a></li>
|
||||
<li><a href="#xsltool">An xsl tool to convert monodoc xml to html documentation.</a></li>
|
||||
<li><a href="#monodoc">monodoc - A graphical documentation viewer.</a></li>
|
||||
<li>xmllint: a tool used to validate a proper XML document.
|
||||
</ul>
|
||||
|
||||
** XML Documentation Files and Formats
|
||||
You can download the tools to document Mono from the CVS
|
||||
repository from module `monodoc'.
|
||||
|
||||
|
||||
*** Monodoc XML
|
||||
This XML is Mono's documentation format. Documentation and a DTD/Schema
|
||||
for Monodoc XML is located in cvs and can be found <a href="http://go-mono.org/monodoc.dtd">here</a>.
|
||||
|
||||
This XML could be generated by MonoDoc or the ASP.NET client.
|
||||
|
||||
More about the XML format <a href="http://go-mono.org/monodoc-xml.html">here</a>.
|
||||
** Documentation Tools
|
||||
|
||||
*** <a name="monodoc">MonoDoc</a>
|
||||
A graphical documentation editor and viewer. Currently, MonoDoc
|
||||
consists of a Qt# application and is in heavy development.
|
||||
|
||||
*** <a name="mkmaster">MkMaster</a>
|
||||
This tool creates the Master.xml file that MonoDoc uses as a reference
|
||||
for documentation generation. This is a reflection engine that is used
|
||||
to gather metadata from assemblies and create an xml representation.
|
||||
|
||||
*** <a name="aspnet">ASP.NET</a>
|
||||
This tool is planned.
|
||||
|
||||
*** <a name="xsltool">An XSL converter</a>
|
||||
This tool is planned. If someone wants to step forward and adopt this
|
||||
project, it would be very helpful ;)
|
||||
A graphical documentation viewer written in Gtk#. In the
|
||||
future we will have an ASP.NET front-end to present the
|
||||
documentation on the web as well.
|
||||
|
||||
** Status and Roadmap
|
||||
|
||||
*** 16, September 2002
|
||||
|
||||
A preliminary version of MonoDoc is in Mono's cvs. It is under heavy development.
|
||||
Once this is complete we will start documenting the API!
|
||||
|
||||
** Get Involved
|
||||
|
||||
Help us develop Mono's documentation tools! Subscribe to
|
||||
|
||||
+118
-84
@@ -13,28 +13,32 @@
|
||||
<ul>
|
||||
* Every classes are present.
|
||||
|
||||
* Most classes have their unit tests.
|
||||
* Most classes have their unit tests. Some tests like <code>
|
||||
SymmetricAlgorithmTest</code> are generated by an external
|
||||
tool.
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
<ul>
|
||||
* Support for adding/modifying algorithms and OID using the
|
||||
<code>machine.config</code> configuration file (in progress).
|
||||
* Support for adding/modifying OID using the
|
||||
<code>machine.config</code> configuration file (algorithms
|
||||
are done).
|
||||
|
||||
* RNGCryptoServiceProvider is currently only working on Linux.
|
||||
The current implementation reside in Mono's runtime and use
|
||||
the <code>/dev/[u]random</code> device (which do not exists
|
||||
under Windows). A Windows alternative is in the work...
|
||||
under Windows). A Windows specific alternative is available
|
||||
using the Mono.Security.Win32 assembly.
|
||||
|
||||
* Keypair persistance for RSA and DSA. This persistance must
|
||||
somehow be linked with X509 certificate stores (in planning).
|
||||
|
||||
* <code>PasswordDeriveBytes</code> is currently limited to
|
||||
generating keys with the maximum length equals to the hash
|
||||
output (as specified in PKCS #5). However the framework
|
||||
implementation allows for longer keys to be generated. Also
|
||||
the algorithms used by CryptDeriveKey (used by Windows
|
||||
applications) are unknown.
|
||||
* <code>PasswordDeriveBytes.CryptDeriveKey</code> is included
|
||||
in MS BCL to provide compatibility with existing Windows
|
||||
applications. The main problem is that the key derivation
|
||||
algorithm can be different for every CSP (Crypto Service
|
||||
Provider). However for compatibility we should provide an
|
||||
implementation compatible with the MS CSP (most likely used).
|
||||
|
||||
* Analyse the current coverage of the unit tests on the
|
||||
cryptographic classes and complete the unit tests.
|
||||
@@ -50,6 +54,9 @@
|
||||
classes named <code>*CryptoServiceProvider</code>, with the
|
||||
exception of <code>RNGCryptoServiceProvider</code> (which
|
||||
resides in the runtime).
|
||||
* Look at assembly Mono.Security.Win32 if you require more
|
||||
compatiblity with the Microsoft implementation (like accessing
|
||||
a particuliar keypair container in a CSP).
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -57,17 +64,18 @@
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* X.509 certificates are parsed using 100% managed code.
|
||||
* X.509 certificates are parsed using 100% managed code
|
||||
(using the Mono.Security.ASN1 class).
|
||||
|
||||
* Software Publisher Certificates (SPC) used by Authenticode
|
||||
(tm) to sign assemblies are supported (extraction from PE
|
||||
files) but <b>not</b> validated.
|
||||
|
||||
* Tests are generated from a set of existing certificates
|
||||
* Unit tests are generated from a set of existing certificates
|
||||
(about a dozen) each having different properties. Another
|
||||
set of certificates (more than 300) are used for a more
|
||||
complete test (but isn't part of the test suite for size
|
||||
and time consideration).
|
||||
complete test (but isn't part of the standard test suite for
|
||||
size and time consideration).
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
@@ -75,26 +83,30 @@
|
||||
* Authenticode(tm) support is incomplete. We can extract the
|
||||
certificates from PE files but cannot validate the signature
|
||||
nor the certificate chain (and we're still missing some trust
|
||||
anchors).
|
||||
anchors). See Tools section for more information.
|
||||
|
||||
* Integration with CryptoAPI isn't possible as long as the
|
||||
<code>X509Certificate(IntPtr)</code> constructor isn't
|
||||
completed.
|
||||
* Integration with CryptoAPI (on Windows) isn't possible as
|
||||
long as the <code>X509Certificate(IntPtr)</code> constructor
|
||||
isn't completed.
|
||||
</ul>
|
||||
|
||||
**** Notes
|
||||
<ul>
|
||||
* <b>There's no validation of the certificates</b> done in this
|
||||
class (this isn't a restriction of Mono!). This means that
|
||||
certificate signatures and validity dates are never checked!
|
||||
* Except for their structure <b>there are no validation of the
|
||||
certificates</b> done by this class (this is by design and
|
||||
isn't a restriction of Mono!). This means that certificate
|
||||
signatures and validity dates are <b>never</b> checked
|
||||
(except when used for Authenticode, i.e.
|
||||
<code>CreateFromSignedFile</code>).
|
||||
|
||||
* The newer X509Certificate class included in Microsoft's Web
|
||||
Service Enhancement (WSE) is a little better (as it includes
|
||||
validation).
|
||||
CryptoAPI's validation) when <code>IsCurrent</code> is called.
|
||||
See assembly <b>Microsoft.Web.Services</b> for more details.
|
||||
|
||||
* Microsoft implementation of <code>X509Certificate</code> is
|
||||
done by using CryptoAPI. From the exceptions thrown
|
||||
Authenticode(tm) support is done via COM.
|
||||
done by using CryptoAPI (unmanaged code). From the exceptions
|
||||
thrown Authenticode(tm) support is done via COM.
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
@@ -102,47 +114,57 @@
|
||||
|
||||
*** Namespace: <b>System.Security.Cryptography.Xml</b>
|
||||
|
||||
This namespace implements the XML Digital Signature specification from
|
||||
W3C.
|
||||
This namespace implements the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
XML Digital Signature</a> specification from
|
||||
<a href="http://www.w3.org/">W3C</a>.
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* All classes are present but some are only stubbed.
|
||||
* All classes are present but some (most Transforms) are only
|
||||
stubbed.
|
||||
|
||||
* Most classes have their unit tests.
|
||||
|
||||
* This assembly is present in CVS but isn't (yet) part of the
|
||||
build.
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
<ul>
|
||||
* All the transforms needs to be done. But this requires far
|
||||
more XML knowledge than crypto.
|
||||
|
||||
* Fix the tests (see notes) then include the assembly into the
|
||||
build process.
|
||||
more XML knowledge than crypto. Note: Most tests runs because
|
||||
the feeded XML is pre-c14n (by hand in the code) before
|
||||
signing (not because the transforms works). In the short
|
||||
term <code>libxml2</code> could be used to provide C14N, but
|
||||
in the long term a fully managed class would be much better.
|
||||
</ul>
|
||||
|
||||
**** Notes
|
||||
<ul>
|
||||
* Many current tests fails because the XML generated by Mono
|
||||
isn't exactly the same as the one produced by the Microsoft
|
||||
implementation (but 100% equivalent). We'll either have to
|
||||
change the XML code or the tests.
|
||||
<hr>
|
||||
** Assembly: Mono.Security
|
||||
|
||||
* Testing is difficult because the classes use CryptoConfig
|
||||
to create the required cryptographic objects. When running
|
||||
the unit tests the CryptoConfig executing is the one in
|
||||
mscorlib (not Mono's one) so it doesn't return the expected
|
||||
objects. This results in InvalidCastException.
|
||||
This assembly provides the missing pieces to .NET security. On Windows
|
||||
CryptoAPI is often used to provide much needed functionalities (like
|
||||
some cryptographic algorithms, code signing, X.509 certificates).
|
||||
|
||||
*** Namespace: Mono.Security
|
||||
*** Namespace: Mono.Security.Authenticode
|
||||
*** Namespace: Mono.Security.Cryptography
|
||||
*** Namespace: Mono.Security.X509
|
||||
*** Namespace: Mono.Security.X509.Extensions
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* Work has been under way for quite some time - and should
|
||||
start hitting CVS soon.
|
||||
|
||||
* A big part of this assembly is also included inside Mono's
|
||||
corlib. The class are duplicated in this assembly so the
|
||||
functionalities can be used with a dependency on Mono's
|
||||
corlib (which depends on Mono's runtime).
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
** Assembly: Mono.Security.Win32
|
||||
|
||||
This assembly is to provide maximum compatibility with CryptoAPI to
|
||||
application running with Mono's runtime on the Windows operating
|
||||
This assembly goal is to provide maximum compatibility with CryptoAPI
|
||||
to application running with Mono's runtime on the Windows operating
|
||||
system.
|
||||
|
||||
<b>This assembly should NEVER be used directly by any application</b>.
|
||||
@@ -154,18 +176,26 @@
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* A RNGCryptoServiceProvider built on top of CryptoAPI.
|
||||
* A RNGCryptoServiceProvider built on top of CryptoAPI. This
|
||||
allows Windows users to get around the limitation of the
|
||||
runtime RNG (which requires <code>/dev/[u]random/</code>).
|
||||
|
||||
* Not (yet) commited in CVS.
|
||||
* Wrapper classes for unmanaged versions of hash algorithms:
|
||||
MD2, MD4, MD5 and SHA1 are supported. <b>note</b>: some
|
||||
algorithms shouldn't be used in new design (MD4 is broken and
|
||||
MD2 isn't considered safe). They are included to preserve
|
||||
interoperability with older applications (e.g. some old, but
|
||||
still valid, X.509 certificates use MD2).
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
<ul>
|
||||
* Unmanaged versions of hash algorithms (SHA1 and MD5).
|
||||
* Unmanaged versions of symmetric encryption algorithms
|
||||
(like DES, TripleDES, RC2 and others present in CryptoAPI).
|
||||
* Unmanaged versions of asymmetric algorithms (like DSA and
|
||||
RSA) which persist their keypair into the specified CSP.
|
||||
* Wrapper classes for unmanaged versions of symmetric
|
||||
encryption algorithms (like DES, TripleDES, RC2 and others
|
||||
present in default CSP).
|
||||
* Wrapper classes for unmanaged versions of asymmetric
|
||||
algorithms (like DSA and RSA) which persist their keypair
|
||||
into the specified CSP.
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
@@ -175,29 +205,34 @@
|
||||
Development Kit (WSDK) in it's beta days, is an add-on the .NET
|
||||
framework that implements WS-Security (and other WS-* specifications).
|
||||
It also includes improved support for XML Signature (replacing and/or
|
||||
extending <code>System.Security.Cryptography.Xml</code>) and X509
|
||||
certificates.
|
||||
extending <code>System.Security.Cryptography.Xml</code>) and X.509
|
||||
certificates classes.
|
||||
|
||||
Note: WSE is distributed as an add-on because the WS-Security
|
||||
specification isn't yet completed by OASIS.
|
||||
Note: WSE is distributed as an add-on because some specifications,
|
||||
like WS-Security, aren't yet completed by
|
||||
<a href="http://www.oasis-open.org/committees/wss/">OASIS</a> or
|
||||
other committees.
|
||||
|
||||
<b>There are some licensing issues to consider before stating to
|
||||
<b>[*] There are some licensing issues to consider before stating to
|
||||
implement WS-Security. All contributors must sign an agreement with
|
||||
Microsoft before commiting anything related to WS-Security into CVS.
|
||||
</b>
|
||||
|
||||
*** Namespace: Microsoft.Web.Services.Security
|
||||
*** Namespace: Microsoft.Web.Services.Timestamp
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* Nothing (yet) commited in CVS.
|
||||
* Nothing (yet) commited in CVS <b>[*]</b>.
|
||||
</ul>
|
||||
|
||||
*** Namespace: Microsoft.Web.Services.Security.X509
|
||||
|
||||
**** Status
|
||||
<ul>
|
||||
* Nothing (yet) commited in CVS.
|
||||
* Nothing (yet) commited in CVS. However the classes in this
|
||||
namespace are outside WS-Security scope. So development
|
||||
could be done without signing any agreements.
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
@@ -208,24 +243,12 @@
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
** Other stuff
|
||||
|
||||
There are other, not so visible, uses of cryptography both inside and
|
||||
outside the class library - such as:
|
||||
|
||||
<ul>
|
||||
* SSL/TLS for secure communication (investigation under way).
|
||||
|
||||
* Assembly signing (and verification) using StrongNames.
|
||||
|
||||
* Assembly signing (and verification) using Authenticode(tm).
|
||||
</ul>
|
||||
|
||||
|
||||
*** Tools
|
||||
** Tools
|
||||
|
||||
There are many tools in the .NET framework that indirectly interacts
|
||||
with some cryptographic classes. Mono will eventually need these tools.
|
||||
Unless noted the tools should work on any CLR (tested with both Mono
|
||||
and Microsoft).
|
||||
|
||||
**** Status
|
||||
|
||||
@@ -236,8 +259,8 @@
|
||||
re-used in source code (C# or VB.NET syntax).
|
||||
|
||||
* <code>cert2spc</code> is a tool to transform multiple X.509
|
||||
certificates (a chain) into a Software Publisher Certificate
|
||||
(SPC) - which is a long name for a simple PKCS#7 file.
|
||||
certificates and CRLs into a Software Publisher Certificate
|
||||
(SPC) file - which is a long name for a simple PKCS#7 file.
|
||||
</ul>
|
||||
|
||||
**** TODO
|
||||
@@ -245,10 +268,11 @@
|
||||
<ul>
|
||||
* <code>monosn</code> is a clone of the <code>sn</code> to manage
|
||||
strongnames. This tools is part of the runtime (not the class
|
||||
library) and as such is written in C.
|
||||
library) and as such is written in C and won't run without Mono.
|
||||
|
||||
* <code>signcode</code> and <code>chktrust</code> for signing
|
||||
and validating Authenticode(tm) signatures on assemblies.
|
||||
* <code>signcode</code> and <code>chktrust</code> (in progress)
|
||||
for signing and validating Authenticode(tm) signatures on
|
||||
assemblies (or any PE file).
|
||||
|
||||
* <code>makecert</code> to create X.509 test certificates that
|
||||
can be used (once transformed in SPC) to sign assemblies.
|
||||
@@ -259,6 +283,14 @@
|
||||
Note that many of the tools requires the class library and/or the
|
||||
runtime to be ready for them.
|
||||
|
||||
<hr>
|
||||
** Other stuff
|
||||
|
||||
<ul>
|
||||
* SSL/TLS for secure communication (a prototype is under way).
|
||||
</ul>
|
||||
|
||||
|
||||
<hr>
|
||||
** How to Help
|
||||
|
||||
@@ -266,9 +298,9 @@
|
||||
|
||||
Add missing unit tests to classes or methods.
|
||||
|
||||
Write some documentation on the cryptographic classes for MonkeyGuide
|
||||
(as I'm not a good writer - but you must be a good reader if you got to
|
||||
this part).
|
||||
Write some documentation on the cryptographic classes for the
|
||||
<a href="http://go-mono.com/tutorial/html/en/index.html">Mono
|
||||
Handbook</a> as I'm not a good writer (at least in English).
|
||||
|
||||
Optimization can also be done on algorithms as crypto is never fast
|
||||
enough. Just be sure to test every optimization (using the unit test)
|
||||
@@ -278,3 +310,5 @@
|
||||
, <a href="mailto:[email protected]">work</a>) if you need additional
|
||||
informations about the status of the cryptographic classes.
|
||||
|
||||
<hr>
|
||||
Last reviewed: March 4, 2003 (post mono 0.21)
|
||||
+192
-3
@@ -14,13 +14,16 @@
|
||||
<ul>
|
||||
|
||||
* The development tools (compilers, assembler tools,
|
||||
language reference, design time features).
|
||||
language reference, design time features): these
|
||||
live in the `monodoc' CVS module.
|
||||
|
||||
* Frequently Asked Question compilations.
|
||||
|
||||
* HOWTO documents.
|
||||
|
||||
* The Class Libraries
|
||||
* The Class Libraries (Both the original .NET class
|
||||
libraries as well as the class libraries produced by
|
||||
the project).
|
||||
|
||||
* Tutorials on Mono and the specifics of running it.
|
||||
|
||||
@@ -29,11 +32,197 @@
|
||||
|
||||
</ul>
|
||||
|
||||
** Class Library documentation
|
||||
* Class Library documentation
|
||||
|
||||
We are moving to a new setup for documenting the class libraries,
|
||||
and you can read about it <a href="classlib-doc.html">here</a>.
|
||||
|
||||
There are two classes of documentation: free documentation for
|
||||
existing .NET classes and documentation for the classes that
|
||||
we have developed on top of .NET.
|
||||
|
||||
There is a large body of documentation that came from the ECMA
|
||||
standarization effort that has been checked into CVS. It does
|
||||
not contain everything Mono and .NET have, so they need to be
|
||||
updated and augmented.
|
||||
|
||||
** Gtk# documentation
|
||||
|
||||
We also have a large body of class libraries that are specific
|
||||
to Mono, for example the documentation for Gtk#.
|
||||
|
||||
We have checked in stub documentation for Gtk# into the CVS
|
||||
repository (on gtk-sharp/doc) and we need volunteers to help
|
||||
populate the documentation for it. Since Gtk# is a wrapper
|
||||
for Gtk, plenty of documentation exists in the <a
|
||||
href="http://developer.gnome.org/doc/API">Gnome developer
|
||||
site</a>.
|
||||
|
||||
To get started:
|
||||
|
||||
You need to download Gtk# from the CVS repository. The module
|
||||
name is `gtk-sharp'. You can obtain a copy from both the CVS
|
||||
repository or the anonymous CVS repository.
|
||||
|
||||
To pull your copy type:
|
||||
|
||||
<pre>
|
||||
cvs co gtk-sharp
|
||||
</pre>
|
||||
Documentation lives in gtk-sharp/doc/en. The "en" indicates the
|
||||
English language, the first one we are targeting. We can later
|
||||
do translations, but for now we are focusing on a single
|
||||
language.
|
||||
|
||||
In that directory you will find the documentation organized by
|
||||
namespaces. One directory per namespace. In the directories
|
||||
you will find one XML file per class that needs to be
|
||||
documented. The mission is to fill in the data with useful
|
||||
information. Feel free to grab liberally information from the
|
||||
Gtk documentation from:
|
||||
|
||||
<a href="http://developer.gnome.org/doc/API/">http://developer.gnome.org/doc/API/</a>
|
||||
|
||||
Of course, the API does not apply directly. It only applies at
|
||||
a foundational level, so you can not really just copy and
|
||||
paste. Summaries, and remarks sections can probably be lifted
|
||||
with little or no effort.
|
||||
|
||||
Gtk# uses properties to represent get/set operations in the C
|
||||
API, so you can also use some bits from there.
|
||||
|
||||
Most of the documentation contains already place holders for
|
||||
text, we use the internationally approved phrase for this
|
||||
purpose, `To be added'. So the quest is to remove all of the
|
||||
"To be added" strings with information with resembles as closely
|
||||
as possible the toolkit reality.
|
||||
|
||||
*** The pieces to be filled.
|
||||
|
||||
Summaries are one or two line descriptions of the element
|
||||
(class, struct, interface, method, field, event, delegate), and
|
||||
its used to render summary pages. So it has to be short.
|
||||
|
||||
The "remarks" section is used to describe in detail the element.
|
||||
|
||||
**** Tags.
|
||||
|
||||
As you document Gtk# you will have a number of tags that you can
|
||||
use inside the summary and remarks sections, these are:
|
||||
|
||||
<pre>
|
||||
<para> </para>
|
||||
</pre>
|
||||
Used to separate paragraphs.
|
||||
|
||||
<pre>
|
||||
<paramref name="param_name"/>
|
||||
</pre>
|
||||
Used to reference a formal parameter to a function.
|
||||
|
||||
<pre>
|
||||
<see cref="T:SomeTypeName"/>
|
||||
</pre>
|
||||
Use this to reference a type, this will include an hyper
|
||||
link to the page for type SomeTypeName.
|
||||
|
||||
For example, to reference "System.Enum", do:
|
||||
|
||||
<pre>
|
||||
<see cref="T:System.Enum"/>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<see cref="P:SomeTypeName.Property"/>
|
||||
</pre>
|
||||
Use this to reference a property, this will include an hyper
|
||||
link to the page for the property `Property' of type `SomeTypeName'.
|
||||
|
||||
For example, to reference the BaseType property in System.Type, do:
|
||||
|
||||
<pre>
|
||||
<see cref="P:System.Type.BaseType"/>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<see cref="M:SomeTypeName.Method(type,type)"/>
|
||||
</pre>
|
||||
Use this to reference a method, this will include an hyper
|
||||
link to the page for the method `Method' of type `SomeTypeName'.
|
||||
|
||||
For example, to reference the ToString method in System.Object, do:
|
||||
|
||||
<pre>
|
||||
<see cref="M:System.Object.ToString()"/>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<see langword="keyword"/>
|
||||
</pre>
|
||||
Use this to link to a keyword in the C# language, for
|
||||
example to link to `true', do:
|
||||
|
||||
<pre>
|
||||
<see langword="true"/>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<example> ... </example>
|
||||
</pre>
|
||||
Use example to insert an example. The example can
|
||||
contain explanatory text and code.
|
||||
|
||||
<pre>
|
||||
<code lang="C#">.. </code>
|
||||
</pre>
|
||||
|
||||
Use this to provide a sample C# program, typically used
|
||||
within the <example> tags.
|
||||
|
||||
When providing examples, try to provide a full example,
|
||||
we would like to be able to have a button to compile and
|
||||
run samples embedded into the documentation, or pop up
|
||||
an editor to let the user play with the sample.
|
||||
|
||||
You can link to an example like this:
|
||||
|
||||
<pre>
|
||||
<code lang="C#" source="file.cs"> </code>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<item>
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
<list type="bullet"> </list>
|
||||
</pre>
|
||||
|
||||
Use this to create lists. Lists contains <item>
|
||||
elements
|
||||
|
||||
<pre>
|
||||
<list type="table"> </lits>
|
||||
<listheader>
|
||||
<term>YOUR FIRST COLUMN</term>
|
||||
<description>YOUR DESCRIPTION</description>
|
||||
</listheader>
|
||||
</pre>
|
||||
For two-column tables. Inside use:
|
||||
|
||||
<pre>
|
||||
<item>
|
||||
<term>First</term>
|
||||
<description>First descritpion</description>
|
||||
</item>
|
||||
<item>
|
||||
<term>Second</term>
|
||||
<description>Second descirption</description>
|
||||
</item>
|
||||
</pre>
|
||||
|
||||
** Words of warning.
|
||||
|
||||
A few words of warning and advice for class documentors:
|
||||
|
||||
A well-documented API can ease hours of frustration; as Mono
|
||||
|
||||
+363
-87
@@ -17,9 +17,9 @@
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.17</b><br>
|
||||
<a href="archive/mono-0.17">Release notes</a><br>
|
||||
Dec 9th, 2002.
|
||||
<b>Release 0.22</b><br>
|
||||
<a href="archive/mono-0.22">Release notes</a><br>
|
||||
March 5, 2003
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
@@ -29,10 +29,10 @@
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.17.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.17.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/mcs-0.22.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.22.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/gc6.1.tar.gz">Boehm GC 6.1</a>
|
||||
<li><a href="archive/xsp-0.2.tar.gz">XSP web server</a> <b><font color="#dd0000">New!</font></b>
|
||||
<!-- <li><a href="archive/xsp-0.3.tar.gz">XSP web server (0.3)</a> -->
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -44,7 +44,7 @@
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.17-2.src.rpm">mono-0.17-2.src.rpm</a>
|
||||
<li><a href="archive/mono-0.22-1.src.rpm">mono-0.22-1.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -57,8 +57,8 @@
|
||||
<ul>
|
||||
<li><a href="archive/redhat-73-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-73-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-73-i386/mono-0.17-2.i386.rpm">mono-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-73-i386/mono-devel-0.17-2.i386.rpm">mono-devel-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-73-i386/mono-0.22-1.i386.rpm">mono-0.22-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-73-i386/mono-devel-0.22-1.i386.rpm">mono-devel-0.22-1.i386.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
@@ -66,8 +66,8 @@
|
||||
<ul>
|
||||
<li><a href="archive/redhat-72-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-72-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-72-i386/mono-0.17-2.i386.rpm">mono-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-72-i386/mono-devel-0.17-2.i386.rpm">mono-devel-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-72-i386/mono-0.22-1.i386.rpm">mono-0.22-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-72-i386/mono-devel-0.22-1.i386.rpm">mono-devel-0.22-1.i386.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -77,8 +77,8 @@
|
||||
<ul>
|
||||
<li><a href="archive/redhat-71-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-71-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-71-i386/mono-0.17-2.i386.rpm">mono-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-71-i386/mono-devel-0.17-2.i386.rpm">mono-devel-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-71-i386/mono-0.22-1.i386.rpm">mono-0.22-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-71-i386/mono-devel-0.22-1.i386.rpm">mono-devel-0.22-1.i386.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
@@ -86,44 +86,113 @@
|
||||
<ul>
|
||||
<li><a href="archive/mandrake-82-i386/libgc-6.1-1.i586.rpm">libgc-6.1-1.i586.rpm</a>
|
||||
<li><a href="archive/mandrake-82-i386/libgc-devel-6.1-1.i586.rpm">libgc-devel-6.1-1.i586.rpm</a>
|
||||
<li><a href="archive/mandrake-82-i386/mono-0.17-2.i586.rpm">mono-0.17-2.i586.rpm</a>
|
||||
<li><a href="archive/mandrake-82-i386/mono-devel-0.17-2.i586.rpm">mono-devel-0.17-2.i586.rpm</a>
|
||||
<li><a href="archive/mandrake-82-i386/mono-0.22-1.i586.rpm">mono-0.22-1.i586.rpm</a>
|
||||
<li><a href="archive/mandrake-82-i386/mono-devel-0.22-1.i586.rpm">mono-devel-0.22-1.i586.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>SuSE 8.0/x86</b>
|
||||
<ul>
|
||||
<li><a href="archive/suse-80-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/mono-0.17-1.i386.rpm">mono-0.17-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/mono-devel-0.17-1.i386.rpm">mono-devel-0.17-1.i386.rpm</a>
|
||||
</ul>
|
||||
<td bgcolor="#999999">
|
||||
<b>SuSE 8.0/x86</b>
|
||||
<ul>
|
||||
<li><a href="archive/suse-80-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/mono-0.22-1.i386.rpm">mono-0.22-1.i386.rpm</a>
|
||||
<li><a href="archive/suse-80-i386/mono-devel-0.22-1.i386.rpm">mono-devel-0.22-1.i386.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <tr> -->
|
||||
<!-- <td bgcolor="#999999"> -->
|
||||
<!-- <b>Debian packages</b> -->
|
||||
<!-- <ul> -->
|
||||
<!-- <li><a href="http://www.atoker.com/mono/">Alp's web site</a> -->
|
||||
<!-- </ul> -->
|
||||
<!-- </td> -->
|
||||
<!-- </tr> -->
|
||||
<tr> -->
|
||||
<td bgcolor="#999999">
|
||||
<b>Windows Setup Wizard (NT/2000/XP)</b>
|
||||
<ul>
|
||||
<li><a href="archive/mono-0.22-win32-1.exe">Mono-Setup</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr bgcolor="#CCCCC">
|
||||
<td>
|
||||
<b>Regression Tests</b><br>
|
||||
</td>
|
||||
<td>
|
||||
You can get binaries for the Mono Regression Test
|
||||
Suite <a href="archive/mono-tests.tar.gz">here</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
der Releases:
|
||||
|
||||
We provide binaries for older releases until we have packages for the new release.
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.21</b><br>
|
||||
<a href="archive/mono-0.21">Release notes</a><br>
|
||||
Feb 27th, 2003
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source Code</b>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
<b>Red Hat 8.0/x86</b>
|
||||
<ul>
|
||||
<li><a href="archive/redhat-80-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/mono-0.17-2.i386.rpm">mono-0.17-2.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/mono-devel-0.17-2.i386.rpm">mono-devel-0.17-2.i386.rpm</a>
|
||||
</ul>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.21.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.21.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/gc6.1.tar.gz">Boehm GC 6.1</a>
|
||||
<li><a href="archive/xsp-0.3.tar.gz">XSP web server (0.3)</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source RPMs</b><br>
|
||||
(No RPMS for XSP).
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.21-1.src.rpm">mono-0.21-1.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Windows Setup Wizard (NT/2000/XP)</b>
|
||||
<ul>
|
||||
<li><a href="archive/mono-0.17-stable.exe">Mono-Setup</a>
|
||||
</ul>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
<b>Debian packages</b>
|
||||
<ul>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Debian packages</b>
|
||||
<ul>
|
||||
<li><a href="http://www.atoker.com/mono/">Alp's web site</a>
|
||||
</ul>
|
||||
</td>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Windows Setup Wizard (NT/2000/XP)</b>
|
||||
<ul>
|
||||
<li><a href="archive/mono-0.21-win32-1.exe">Mono-Setup</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -142,15 +211,230 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
* Older Releases:
|
||||
|
||||
We provide binaries for older releases until we have packages for the new release.
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.20</b><br>
|
||||
<a href="archive/mono-0.20">Release notes</a><br>
|
||||
Feb 20th, 2003
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source Code</b>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.20.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.20.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/gc6.1.tar.gz">Boehm GC 6.1</a>
|
||||
<li><a href="archive/xsp-0.3.tar.gz">XSP web server (0.3)</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source RPMs</b><br>
|
||||
(No RPMS for XSP).
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.20-1.src.rpm">mono-0.20-1.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Red Hat 8.0/x86</b>
|
||||
<ul>
|
||||
<li><a href="archive/redhat-80-i386/libgc-6.1-1.i386.rpm">libgc-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/libgc-devel-6.1-1.i386.rpm">libgc-devel-6.1-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/mono-0.20-1.i386.rpm">mono-0.20-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-80-i386/mono-devel-0.20-1.i386.rpm">mono-devel-0.20-1.i386.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
<b>Debian packages</b>
|
||||
<ul>
|
||||
<li><a href="http://www.atoker.com/mono/">Alp's web site</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Windows Setup Wizard (NT/2000/XP)</b>
|
||||
<ul>
|
||||
<li><a href="archive/mono-0.20-stable-win32-2.exe">Mono-Setup</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr bgcolor="#CCCCC">
|
||||
<td>
|
||||
<b>Regression Tests</b><br>
|
||||
</td>
|
||||
<td>
|
||||
You can get binaries for the Mono Regression Test
|
||||
Suite <a href="archive/mono-tests.tar.gz">here</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.19</b><br>
|
||||
<a href="archive/mono-0.19">Release notes</a><br>
|
||||
Jan 20th, 2003
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source Code</b>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.19.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.19.tar.gz">Mono Runtime</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source RPMs</b><br>
|
||||
(No RPMS for XSP).
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.19-1.src.rpm">mono-0.19-1.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.18</b><br>
|
||||
<a href="archive/mono-0.18">Release notes</a><br>
|
||||
Jan 12th, 2003
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source Code</b>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.18.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.18.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/gc6.1.tar.gz">Boehm GC 6.1</a>
|
||||
<li><a href="archive/xsp-0.2.tar.gz">XSP web server</a> <b><font color="#dd0000">New!</font></b>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source RPMs</b><br>
|
||||
(No RPMS for XSP).
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.18-1.src.rpm">mono-0.18-1.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.17</b><br>
|
||||
<a href="archive/mono-0.17">Release notes</a><br>
|
||||
Dec 9th, 2002.
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="3">
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source Code</b>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/mcs-0.17.tar.gz">Mono Class Libraries and C# Compiler.</a>
|
||||
<li><a href="archive/mono-0.17.tar.gz">Mono Runtime</a>
|
||||
<li><a href="archive/gc6.1.tar.gz">Boehm GC 6.1</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor="#BBBBBB">
|
||||
<td>
|
||||
<b>Source RPMs</b><br>
|
||||
(No RPMS for XSP).
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="archive/libgc-6.1-1.src.rpm">libgc-6.1-1.src.rpm</a>
|
||||
<li><a href="archive/mono-0.17-2.src.rpm">mono-0.17-2.src.rpm</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Windows Setup Wizard (NT/2000/XP)</b>
|
||||
<ul>
|
||||
<li><a href="archive/mono-0.17-stable.exe">Mono-Setup</a>
|
||||
</ul>
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
<b>Debian packages</b>
|
||||
<ul>
|
||||
<li><a href="http://www.atoker.com/mono/">Alp's web site</a>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.16</b><br>
|
||||
<a href="archive/mono-0.16">Release notes</a><br>
|
||||
@@ -187,7 +471,7 @@
|
||||
<tr>
|
||||
<td bgcolor="#999999">
|
||||
<b>Linux s390</b>
|
||||
<ul>
|
||||
<ul>
|
||||
<li><a href="archive/s390/glib2-2.0.6-13.s390.rpm">glib2-2.0.6-13.s390.rpm</a>
|
||||
<li><a href="archive/s390/glib2-devel-2.0.6-13.s390.rpm">glib2-devel-2.0.6-13.s390.rpm</a>
|
||||
<li><a href="archive/s390/libgc-6.1alpha5-1.s390.rpm">libgc-6.1alpha5-1.s390.rpm</a>
|
||||
@@ -201,14 +485,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr bgcolor="#CCCCC">
|
||||
<td>
|
||||
<b>Regression Tests</b><br>
|
||||
</td>
|
||||
<td>
|
||||
You can get binaries for the Mono Regression Test
|
||||
Suite <a href="archive/mono-tests.tar.gz">here</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -216,7 +492,7 @@
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<tr bgcolor="#DDDDDD">
|
||||
<td>
|
||||
<b>Release 0.15</b><br>
|
||||
<a href="archive/mono-0.15">Release notes</a><br>
|
||||
@@ -260,7 +536,7 @@
|
||||
</td>
|
||||
<td bgcolor="#999999">
|
||||
<b>Red Hat null-8.0/x86</b>
|
||||
<ul>
|
||||
<ul>
|
||||
<li><a href="archive/redhat-null-i386/libgc-6.1alpha5-1.i386.rpm">libgc-6.1alpha5-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-null-i386/libgc-devel-6.1alpha5-1.i386.rpm">libgc-devel-6.1alpha5-1.i386.rpm</a>
|
||||
<li><a href="archive/redhat-null-i386/mono-0.15-1.i386.rpm">mono-0.15-1.i386.rpm</a>
|
||||
@@ -274,7 +550,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
** Binaries for other platforms.
|
||||
inaries for other platforms.
|
||||
|
||||
Already daily volunteer's made binaries:
|
||||
|
||||
@@ -283,9 +559,9 @@
|
||||
* <a href="http://www.superin.formativ.net/mono/mono.htm">Windows</a> (works without cygwin!)
|
||||
</ul>
|
||||
|
||||
* Snapshots
|
||||
apshots
|
||||
|
||||
<a name="snapshots">
|
||||
ame="snapshots">
|
||||
|
||||
<a href="http://www.go-mono.com/snapshots">Nightly snapshots</a> of
|
||||
the CVS repository are made every day at 10pm EST (Boston
|
||||
@@ -295,7 +571,7 @@
|
||||
The <a href="anoncvs.html">anoncvs</a> mirrors provided by
|
||||
Hispalinux are updated every six hours.
|
||||
|
||||
* Compiling the code
|
||||
mpiling the code
|
||||
|
||||
There are a number of ways of compiling Mono
|
||||
|
||||
@@ -309,8 +585,8 @@
|
||||
|
||||
(which is an easy way to get the latest CVS information)
|
||||
|
||||
<a name="scripts">
|
||||
* Compiling with scripts
|
||||
ame="scripts">
|
||||
mpiling with scripts
|
||||
|
||||
There are scripts to help build mono for both Unix and Windows. Get
|
||||
<a href="mono-build.sh">mono-build.sh</a> for Unix, or <a
|
||||
@@ -341,14 +617,14 @@
|
||||
set your CVSROOT environment variable before running the script to
|
||||
select a particular cvs server.
|
||||
|
||||
<a name="install">
|
||||
** Building the software manually
|
||||
ame="install">
|
||||
uilding the software manually
|
||||
|
||||
You will need to obtain the Mono dependencies first: <a
|
||||
href="http://www.gtk.org">glib 2.x</a> and
|
||||
<a href="http://www.freedesktop.org/software/pkgconfig">pkg-config</a>.
|
||||
|
||||
*** Building on Linux
|
||||
Building on Linux
|
||||
|
||||
<ul>
|
||||
Unpack the Mono runtime distribution:
|
||||
@@ -390,9 +666,9 @@
|
||||
</ul>
|
||||
|
||||
|
||||
*** On Windows, to install and work on the compiler and the class libraries:
|
||||
On Windows, to install and work on the compiler and the class libraries:
|
||||
|
||||
**** Install Cygwin and the GNU build tools, Microsoft's .NET Framework SDK and the precompiled GLIB 2.0 and pkg-config libraries.
|
||||
Install Cygwin and the GNU build tools, Microsoft's .NET Framework SDK and the precompiled GLIB 2.0 and pkg-config libraries.
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -419,9 +695,9 @@
|
||||
<pre>
|
||||
make
|
||||
</pre>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
*** On Windows, to compile the mono runtime:
|
||||
On Windows, to compile the mono runtime:
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -440,7 +716,7 @@
|
||||
|
||||
</ul>
|
||||
|
||||
* Software resources and notes
|
||||
ftware resources and notes
|
||||
|
||||
The required and additional software can be downloaded here:
|
||||
|
||||
@@ -475,7 +751,7 @@
|
||||
</ul>
|
||||
|
||||
|
||||
*** Notes on compiling GLIB 2.0 and pkg-config from source:
|
||||
Notes on compiling GLIB 2.0 and pkg-config from source:
|
||||
|
||||
|
||||
<ul>
|
||||
@@ -485,18 +761,18 @@
|
||||
`make maintainer-clean' after the update).
|
||||
|
||||
* Download, compile and install <a href="http://www.freedesktop.org/software/pkgconfig">pkg-config</a> from source.
|
||||
(I had to change line 674 of
|
||||
<nobr><tt>pkg-config-0.8.0/glib-1.2.8/gstrfuncs.c</tt></nobr> from
|
||||
(I had to change line 674 of
|
||||
<nobr><tt>pkg-config-0.8.0/glib-1.2.8/gstrfuncs.c</tt></nobr> from
|
||||
<nobr><tt>extern char *strsignal (int sig);</tt></nobr> to
|
||||
<nobr><tt>extern const char *strsignal (int sig);</tt></nobr>.
|
||||
|
||||
<pre>
|
||||
tar xzvf pkg-config-0.8.0.tar.gz
|
||||
cd pkg-config-0.8.0
|
||||
./configure --prefix=/usr
|
||||
make
|
||||
make install
|
||||
</pre>
|
||||
>
|
||||
xzvf pkg-config-0.8.0.tar.gz
|
||||
kg-config-0.8.0
|
||||
nfigure --prefix=/usr
|
||||
|
||||
install
|
||||
e>
|
||||
|
||||
* Download, compile and install <a href="ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.7.tar.gz">libiconv</a> from source.<br>
|
||||
If you dont have MS Visual C/C++ 4.0 or 5.0 or 6.0 you can also try
|
||||
@@ -504,15 +780,15 @@ make install
|
||||
href="http://www.gimp.org/win32/libiconv-dev-20001007.zip">
|
||||
http://www.gimp.org/win32/libiconv-dev-20001007.zip</a>.
|
||||
|
||||
|
||||
|
||||
* Download, compile and install the
|
||||
<a href="ftp://ftp.gtk.org/pub/gtk/v2.0/glib-2.0.6.tar.gz">
|
||||
glib 2.0</a> from source.
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="upgrading">
|
||||
** Upgrading
|
||||
ame="upgrading">
|
||||
pgrading
|
||||
|
||||
To upgrade your Mono installation from CVS, it is very
|
||||
important that you update your Mono and MCS modules from CVS
|
||||
@@ -547,4 +823,4 @@ make install
|
||||
|
||||
Notice that following the above procedure does not require you
|
||||
to manually install the software in the `mcs' directory, as
|
||||
the relevant files will be copied by the `mono' makefiles.
|
||||
the relevant files will be copied by the `mono' makefiles.
|
||||
@@ -721,26 +721,44 @@ A: Replace the __stdcall attribute with the STDCALL macro, and include this
|
||||
<a name="asp">
|
||||
** Mono and ASP.NET
|
||||
|
||||
Q: Is Mono supporting ASP.NET?
|
||||
Q: Does Mono support ASP.NET?
|
||||
|
||||
A: Yes. The development of the support for ASP.NET comes in various stages,
|
||||
here is what Gonzalo has been working on: 1. The Parser. 2. Getting the
|
||||
parser to generate output compatible with ASP.NET. 3. Running the sample
|
||||
output with the real Microsoft runtime but using our generated page. 4.
|
||||
Running the sample with our classes with the .NET runtime. 5. Running
|
||||
our sample code with our classes with our runtime. This is the process
|
||||
we are following. Currently Gonzalo has reached point 5.
|
||||
A: Yes.
|
||||
|
||||
Mono supports ASP.NET, we have shown an unmodified IBuySpy
|
||||
installation running on Mono as well as various other programs. You can
|
||||
try it yourself downloading the XSP server.
|
||||
|
||||
Q: Do I need install cygwin to work on ASP.NET in mono or Linux is enough since
|
||||
it is self host right now.
|
||||
|
||||
A: Linux is enough.
|
||||
|
||||
Q: How can I run ASP.NET-based applications with Mono?
|
||||
|
||||
A: You need the Mono runtime and a hosting web server. Currently we distribute a
|
||||
small web server called `xsp' which is used to debug applications, or you can choose
|
||||
to use Daniel's Apache 2 module.
|
||||
|
||||
Q: Any plan to make ASP.NET in mono works with Apache in Linux?.
|
||||
|
||||
A: Yes, we have plans to do so, but we need to wait for Patrik's patches to
|
||||
HttpRuntime. Once that is there, writing a mod_mono should be trivial
|
||||
(look at mono/samples/embed for a sample embedded application).
|
||||
A: Daniel has authored an Apache2 Module for Mono that hosts the ASP.NET runtime
|
||||
and is available here: <a
|
||||
href="http://apacheworld.org/modmono/">http://apacheworld.org/modmono/</a>
|
||||
|
||||
Q: Will you support Apache 1?
|
||||
|
||||
A: Modules developed for Apache 2 are not compatible with Apache 1.3
|
||||
Daniel plans to support Apache 1.3 in the future but the current focus is on
|
||||
Apache 2, because of the better support for threading and Windows.
|
||||
|
||||
Q: Can I run Apache 1 and Apache 2 on the same machine?
|
||||
|
||||
You can always keep a copy of Apache 2 running in paralell with your Apache
|
||||
1.3 (either different port or using a reverse proxy).
|
||||
|
||||
You can also bind the two servers to different IP addresses on the
|
||||
same physical machine.
|
||||
|
||||
<a name="ado">
|
||||
** Mono and ADO.NET
|
||||
|
||||
+103
-7
@@ -1,22 +1,30 @@
|
||||
* Firebird and Interbase Data Provider
|
||||
|
||||
<ul>
|
||||
<li>ADO.NET Data Provider for Firebird and Interbase databases</li>
|
||||
|
||||
<li>Does not exist in Mono, but is a separate project</li>
|
||||
|
||||
<li><a href="http://firebird.sourceforge.net/index.php">Firebird Relational Database</a> is
|
||||
an independent project which uses source code based on the Interbase source code released
|
||||
<li>The <a href="http://firebird.sourceforge.net/index.php">Firebird Relational Database</a> is
|
||||
is an independent project which uses source code based on the Interbase source code released
|
||||
by Borland under the Interbase Public License</li>
|
||||
|
||||
<li>Both the Firebird Relational Database and the Firebird .NET Data Provider can be
|
||||
downloaded from <a href="http://sourceforge.net/projects/firebird/firebird">here</a></li>
|
||||
downloaded from <a href="http://sourceforge.net/projects/firebird/">here</a></li>
|
||||
|
||||
<li>The Firebird .NET Data provider has been made
|
||||
available by Carlos Guzmán Álvarez (aka "Carlos G.A."), who has also made a
|
||||
number of contributions to the OdbcJdbc code</li>
|
||||
available by Carlos Guzmán Álvarez (aka "Carlos G.A."), who has also made a
|
||||
number of contributions to the OdbcJdbc code</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Currently, it is able to connect to Firebird and Interbase databases
|
||||
@@ -56,7 +64,7 @@
|
||||
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Action Plan
|
||||
|
||||
<ul>
|
||||
<li>Bug fixing</li>
|
||||
@@ -98,3 +106,91 @@
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Need a working mono and mcs</li>
|
||||
|
||||
<li>Need access to a Firebird Relational Database or you can download
|
||||
it from <a href="http://firebird.sourceforge.net">here</a></li>
|
||||
|
||||
<li>Get the Firebird .NET data provider from here as
|
||||
<a href="http://lists.sourceforge.net/lists/listinfo/firebird-net-provider">firebird-net-provider</a>. Make
|
||||
sure the Firebird .NET data provider binary assembly FirebirdSql.Data.Firebird.dll is
|
||||
installed in the same place as the mono class libraries.</li>
|
||||
|
||||
<li>Has a ConnectionString format:
|
||||
<pre>
|
||||
"Database=databasefile.gdb;User=user;Password=pass;Dialect=3;Server=hostname"
|
||||
</pre>
|
||||
|
||||
</li>
|
||||
|
||||
<li>C# Example:
|
||||
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using FirebirdSql.Data.Firebird;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Database=C:\\PROGRAM FILES\\FIREBIRD\\EXAMPLES\\EMPLOYEE.GDB;" +
|
||||
"User=SYSDBA;" +
|
||||
"Password=masterkey;" +
|
||||
"Dialect=3;" +
|
||||
"Server=localhost";
|
||||
IDbConnection dbcon = new FbConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
string sql = "SELECT * FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
object dataValue = myReader.GetValue(0);
|
||||
string sValue = dataValue.ToString();
|
||||
Console.WriteLine("Value: " + sValue);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r FirebirdSql.Data.Firebird.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r FirebirdSql.Data.Firebird.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+4
-6
@@ -1,9 +1,7 @@
|
||||
* The GCC front-end
|
||||
|
||||
The GCC front-end will accept input in a binary file with
|
||||
codes in the Common Intermediate Language (CIL), and generate
|
||||
native code.
|
||||
|
||||
This will allow pre-compilation and full optimization to take
|
||||
place before a program is executed.
|
||||
Jeremy Singer has developed a .NET backend for GCC, his
|
||||
research work is available <a
|
||||
href="http://www.cl.cam.ac.uk/~jds31/research/gccnet/">here</a>.
|
||||
|
||||
|
||||
+139
-6
@@ -3,19 +3,152 @@
|
||||
<a href="http://gtk-sharp.sourceforge.net">Gtk#</a> (Gtk
|
||||
sharp) is a set of C# language bindings for the
|
||||
<a href="http://www.gtk.org">Gtk+</a> toolkit and other
|
||||
libraries that are part of the <a
|
||||
href="http://www.gnome.org">GNOME</a> platform .
|
||||
libraries that are part of the
|
||||
<a href="http://www.gnome.org">GNOME</a> platform .
|
||||
|
||||
** API of Gtk#
|
||||
|
||||
The API is browsable
|
||||
<a
|
||||
href="http://primates.ximian.com/~tvgm/gtk-sharp-docs/">here</a>
|
||||
<a href="http://primates.ximian.com/~tvgm/gtk-sharp-docs/">here</a>
|
||||
|
||||
** Where to learn more.
|
||||
|
||||
Visit the official site for the <a
|
||||
href="http://gtk-sharp.sourceforge.net">Gtk# Project</a>.
|
||||
Visit the official site for the <a href="http://gtk-sharp.sourceforge.net">Gtk# Project</a>.
|
||||
The <a href="http://www.go-mono.org/faq">Mono FAQ</a> has some useful
|
||||
information too.
|
||||
|
||||
** GTK# On Linux
|
||||
|
||||
<p>Where to get distributions of GTK# for Linux:
|
||||
<ul>
|
||||
<li><a href="http://gtk-sharp.sourceforge.net">RPMs</a></li>
|
||||
<li><a href="http://www.debianplanet.org/mono/">Debs</a></li>
|
||||
</ul>
|
||||
|
||||
<p>Buidling on Linux:
|
||||
|
||||
<ul>
|
||||
<li>Get GTK# source from <a href="http://gtk-sharp.sourceforge.net">Gtk# Project</a>.</li>
|
||||
<li>run ./autogen.sh --prefix=my_mono_installation_prefix</li>
|
||||
<li>make</li>
|
||||
<li>make install</li>
|
||||
</ul>
|
||||
|
||||
** GTK# On Windows
|
||||
|
||||
<p>There is a Windows Installer for GTK# <a href="http://www.sport-huettn.de/mono/gtk-sharp-0.6-stable-2.exe">here</a>.
|
||||
|
||||
<p>If you want to build GTK# yourself on Windows:
|
||||
|
||||
<p>To build gtk# under windows, you will need the following:
|
||||
|
||||
<ul>
|
||||
<li>cygwin from <a href="http://www.cygwin.com/">here</a> When installing Cygwin via setup.exe,
|
||||
by default binutils and other tools do not get installed; you have to make
|
||||
sure to select these items. Just make
|
||||
sure Base and Development are set to Install.</li>
|
||||
<li>Mono 0.17 or later from <a href="http://www.go-mono.com/download.html">here</a>
|
||||
You can use Windows Setup Wizard (NT/2000/XP).</li>
|
||||
<li>GTK+ 2.0 (and dependencies). You can obtain gtk+ 2.0 by either of the
|
||||
following:
|
||||
<ul>
|
||||
<li>You can get a Windows Installer at:
|
||||
<a href="http://www.dropline.net/jade/download.html">here</a> </li>
|
||||
<li>or get the separate binary and dev/lib packages at
|
||||
at <a href="http://www.gimp.org/~tml/gimp/win32/downloads.html">here</a> </li>
|
||||
<li>or binary package from Dev-C++ site <a href="http://www.bloodshed.net/dev/packages/gtk.html">here</a> </li>
|
||||
<li>or get Gtk4Win <a href="http://wingtk.sourceforge.net/index.html">here</a> </li>
|
||||
<li>or the source at <a href="http://www.gtk.org/">here</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>binary distriubtion of a current web browser
|
||||
like Internet Explorer 4.0, Mozilla 1.0, or Netscape 7.0 which
|
||||
includes things like msvcrt.dll.</li>
|
||||
<li>Microsoft .NET Framework at
|
||||
<a href="http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/000/976/msdncompositedoc.xml&frame=true">here</a> </li>
|
||||
|
||||
<p>If you are running Windows 95/98/ME, then you will need Unicode support.
|
||||
Look in
|
||||
mono-list archives for information about how to get
|
||||
Mono to work on Windows 9x.
|
||||
<a href="http://lists.ximian.com/archives/public/mono-list/2002-December/004158.html">here</a>
|
||||
|
||||
<p>Environment Variables to set:
|
||||
<ul>
|
||||
<li>PATH - set to your mono installation bin and lib path.
|
||||
For example, my mono installation prefix is:
|
||||
<pre>
|
||||
F:/cygwin/home/DanielMorgan/mono/install
|
||||
</pre>
|
||||
<p>So, I would set my PATH in the Windows Control Panel as:
|
||||
<pre>
|
||||
F:/cygwin/home/DanielMorgan/mono/install/bin;F:/cygwin/home/DanielMorgan/mono/install/lib</li>
|
||||
</pre>
|
||||
</li>
|
||||
<li>LD_LIBRARY_PATH - set to your mono installation lib path</li>
|
||||
<li>PKG_CONFIG_PATH - set to your mono installation lib/pkgconfig path, such
|
||||
as,
|
||||
<pre>
|
||||
F:/cygwin/home/DanielMorgan/mono/install/lib/pkgconfig</li>
|
||||
</pre>
|
||||
|
||||
<p>If you got the gtk-sharp source, cd to the gtk-sharp directory, type:
|
||||
<pre>
|
||||
./autogen.sh --prefix=~/mono/install
|
||||
</pre>
|
||||
|
||||
<p>Set your --prefix= to whatever your mono installation prefix is located.
|
||||
This will take awhile to go through the ./autogen.sh and ./configure...
|
||||
|
||||
<p>After that it finishes succesfully, you run make with the makefile.win32
|
||||
like:
|
||||
<pre>
|
||||
make -f makefile.win32
|
||||
</pre>
|
||||
|
||||
<p>After that finishes succesfully, you can copy to your mono installation lib
|
||||
path like:
|
||||
<pre>
|
||||
cp */*.dll ~/mono/install/lib
|
||||
</pre>
|
||||
</ul>
|
||||
|
||||
<p>The pkg-config files for
|
||||
gtk+ 2.0 and dependencies will need to be set correctly if they haven't
|
||||
already been.
|
||||
|
||||
<p>Look in your mono installation/lib/pkgconfig, such as,
|
||||
<pre>
|
||||
F:/cygwin/home/DanielMorgan/mono/install/lib/pkgconfig
|
||||
</pre>
|
||||
|
||||
<p>You will find files like: gtk+-2.0.pc
|
||||
|
||||
<p>Edit the line that says
|
||||
|
||||
<pre>
|
||||
prefix=something
|
||||
</pre>
|
||||
|
||||
<p>And set it to your mono installation prefix, such as,
|
||||
|
||||
<pre>
|
||||
prefix=F:/cygwin/home/DanielMorgan/mono/install
|
||||
</pre>
|
||||
|
||||
<p>Do this for all the .pc files in that directory. If there are not any, then
|
||||
you will need to create them. Or get them from somewhere like the dev
|
||||
packages at
|
||||
<a href="http://www.gimp.org/~tml/gimp/win32/downloads.html">here</a>
|
||||
|
||||
** GTK# On FreeBSD
|
||||
|
||||
TODO. Any volunteers?
|
||||
|
||||
** GTK# On Solaris
|
||||
|
||||
TODO. Any volunteers?
|
||||
|
||||
** GTK# On AIX
|
||||
|
||||
TODO. Any volunteers?
|
||||
@@ -13,6 +13,14 @@ Some of them may start contributing because they want a mention in the
|
||||
|
||||
* Mono Hackers
|
||||
|
||||
** Zoltan Varga
|
||||
|
||||
Zoltan has contributed significantly to Mono, with bug reports and bug
|
||||
fixes as well as pushing the envelope of the things that can be done in
|
||||
and with the mono runtime: the gcc-based ngen compiler, code coverage
|
||||
and more recently his work with Reflection.Emit that got mono to the
|
||||
point of running the IKVM Java virtual machine.
|
||||
|
||||
** Sergey Chaban
|
||||
|
||||
Sergey has been a long time contributor to the project, from the early
|
||||
|
||||
Executable
+157
@@ -0,0 +1,157 @@
|
||||
* IBM DB2 Data Provider
|
||||
<ul>
|
||||
<li>ADO.NET Data Provider for <a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
|
||||
|
||||
<li>Exists in namespace DB2ClientCS and assembly Mono.Data.DB2Client</li>
|
||||
|
||||
<li>The source code exists at mcs/class/Mono.Data.DB2Client</li>
|
||||
|
||||
<li>Requires the Call Level Interface to IBM DB2 shared library. This
|
||||
is db2cli.dll on Windows. The IBM DB2 CLI API is very similar to the ODBC API. If
|
||||
you take a look at Mono's <a href="http://www.go-mono.com/odbc.html">System.Data.Odbc</a> ODBC provider, you will see the
|
||||
DllImport's have similiar function names.</li>
|
||||
|
||||
<li>IBM DB2 Provider created by Christopher Bockner.</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Compiles on Windows and Linux. Works on Windows. Still needs to be tested on Linux.</li>
|
||||
|
||||
<li>Able to connect to IBM DB2</li>
|
||||
|
||||
<li>Able to execute DML, such as, CREATE TABLE via ExecuteNonQuery()</li>
|
||||
|
||||
<li>Christopher says it can retrieve data via the DB2ClientDataReader</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Action Plan
|
||||
|
||||
<ul>
|
||||
<li>Still needs work to get it to retrieve data via ExecuteReader() and
|
||||
use the data reader to read data.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
In order to test.
|
||||
<ul>
|
||||
<li>Have working mono and mcs setup</li>
|
||||
|
||||
<li>Have access to an IBM DB2 database. If you do not have access, download the
|
||||
<a href="http://www-3.ibm.com/software/data/db2/">IBM DB2</a> software. There
|
||||
are versions for Windows, Linux, AIX, and Sun Solaris.</li>
|
||||
|
||||
<li>Make sure the assembly Mono.Data.DB2Client.dll was built and installed
|
||||
where the other class libraries are installed.</li>
|
||||
|
||||
<li>If you do not have the source to mcs, get the source from
|
||||
<a href="http://www.go-mono.com/download">here</a></li>
|
||||
|
||||
<li>Has a ConnectionString format like ODBC</li>
|
||||
|
||||
<li>Here is a ConnectionString format if you have a DSN setup:
|
||||
<pre>
|
||||
"DSN=dataSetName;UID=myuserid;PWD=mypassword"
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>Here is a ConnectionString format if you do not have a DSN (have not
|
||||
gotten this to work though, so, I am open to suggestions):
|
||||
<pre>
|
||||
"DRIVER={DB2 Driver};SERVER=localhost;DATABASE=test;UID=myuserid;PASSWORD=mypassword"
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>In mcs/class/Mono.Data.DB2Client/Test/DBConnTest, you will find
|
||||
a DBConnTest.cs.</li>
|
||||
|
||||
<li>To build DBConnTest:
|
||||
<ul>
|
||||
<li>On Unix:</li>
|
||||
<pre>
|
||||
mcs DBConnTest.cs -r System.Data.dll -r Mono.Data.DB2Client.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>On Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe DBConnTest.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Mono.Data.DB2Client.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>To run it on mono:
|
||||
<pre>
|
||||
mono DBConnTest.exe database userid password
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.DB2Client;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"DSN=sample;UID=db2admin;PWD=mypass";
|
||||
IDbConnection dbcon = new DB2ClientConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
string sql =
|
||||
"CREATE TABLE mono_db2_test1 ( " +
|
||||
" testid varchar(2), " +
|
||||
" testdesc varchar(16) " +
|
||||
")";
|
||||
dbcmd.CommandText = sql;
|
||||
dbcmd.ExecuteNonQuery();
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Mono.Data.DB2Client.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Mono.Data.DB2Client.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -56,11 +56,6 @@ TODO=multimedia
|
||||
<a name="projects">
|
||||
** Projects
|
||||
|
||||
<ul>
|
||||
TODO=xmlStorage,
|
||||
* Implement an xmlStorageSystem for the CLI:
|
||||
<a href="http://www.soapware.org/xmlStorageSystem">
|
||||
http://www.soapware.org/xmlStorageSystem</a>
|
||||
|
||||
TODO=guavac,Java compiler for .NET
|
||||
* You could take one of the existing Java compilers
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
You might also want to <a href="download.html">Download the
|
||||
source</a> for our work so far. Grab a <a
|
||||
href="snapshots">snapshot</a> of our current work, or <a
|
||||
href="http://cvs.hispalinux.es/cgi-bin/cvsweb/?hidenonreadable=1&f=u&logsort=date&sortby=file&hideattic=1&cvsroot=Mono">browse
|
||||
href="http://cvs.hispalinux.es/cgi-bin/cvsweb/?hidenonreadable=1&f=u&logsort=date&sortby=file&hideattic=1&cvsroot=mono">browse
|
||||
the sources</a>
|
||||
|
||||
You might want to <a
|
||||
@@ -34,6 +34,12 @@
|
||||
|
||||
You can contact the team at: <a
|
||||
href="mailto:[email protected]">[email protected]</a>
|
||||
|
||||
In order to follow the process of the project and to learn more
|
||||
about the team members we have created the <a
|
||||
href="http://monoevo.sf.net/mwn/index.html">Mono Weekly News letter</a>.
|
||||
Which archives can be found <a
|
||||
href="http://monoevo.sf.net/mwn/archives.html">here</a>.
|
||||
</td>
|
||||
<td>
|
||||
<table border=1>
|
||||
@@ -86,11 +92,214 @@
|
||||
<a href="index.rss"><img src="images/xml.gif"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="screenshots.html">Screenshots</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@item Mar 5th, 2003: Mono 0.22; MonoDoc 0.2; Debugger 0.2.1: Release-o-Rama.
|
||||
|
||||
Mono 0.22 has been released. See the <a
|
||||
href="archive/mono-0.22">release notes</a>. This is a bug fix
|
||||
release.
|
||||
|
||||
A new preview of MonoDoc 0.2, the Mono Documentation browser
|
||||
has been <a href="http://lists.ximian.com/archives/public/gtk-sharp-list/2003-March/001266.html">released</a>.
|
||||
|
||||
Martin also announced a <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-March/012756.html">new
|
||||
release</a> of the Mono Debugger (both GUI and command line).
|
||||
|
||||
@item Mar 3rd, 2003: The Mono Hackers Hall Of Fame welcomes Zoltan Varga
|
||||
|
||||
The <a href="hackers.html">Mono Hackers Hall Of Fame</a>
|
||||
continues to show our appreciation to the excellent
|
||||
contributors that make <b>mono::</b> a successful free
|
||||
software project.
|
||||
|
||||
Zoltan has contributed significantly to Mono, with bug reports and bug
|
||||
fixes as well as pushing the envelope of the things that can be done in
|
||||
and with the mono runtime: the gcc-based ngen compiler, code coverage
|
||||
and more recently his work with Reflection.Emit that got mono to the
|
||||
point of running the <a href="http://www.ikvm.net">IKVM</a> Java virtual
|
||||
machine.
|
||||
|
||||
@item Mar 2nd, 2003: New Mono mailing list.
|
||||
|
||||
A new mailing list for <a
|
||||
href="http://lists.ximian.com/mailman/listinfo/mono-devel-list">Mono
|
||||
Development</a> has been created.
|
||||
|
||||
@item Feb 27th, 2003: Mono 0.21 released
|
||||
|
||||
Mono 0.21 has been released. This is only a bug fix release.
|
||||
The <a href="archive/mono-0.21">release notes</a> are available.
|
||||
|
||||
@item Feb 25th, 2003: Mono 0.20 for Windows released; New Apache module released.
|
||||
|
||||
Packages of Mono for Windows have been <a
|
||||
href="archive/mono-0.20-stable-win32-2.exe">released</a>.
|
||||
Thanks to Daniel, Johannes and Paolo for setting this up.
|
||||
|
||||
Daniel has released a new version of his Mono Apache module that
|
||||
handles ASP.NET. The code is available at <a
|
||||
href="http://apacheworld.org/modmono/">here</a>
|
||||
|
||||
Nick has posted an update on the progress on our <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-February/012467.html">regression
|
||||
tests</a>. We are looking for more tests, and more volunteers to write them.
|
||||
|
||||
Also, remember to contribute to the Gtk# documentation effort,
|
||||
momentum is picking up! See the entry for Feb 18th for more details.
|
||||
|
||||
@item Feb, 23rd, 2003: Mono 0.20 released; Gtk# 0.8 released.
|
||||
|
||||
Mono 0.20 has been released. Check out the <a
|
||||
href="archive/mono-0.20">release notes</a> for an overview of
|
||||
the changes. You can get it <a href="download.html">here</a>.
|
||||
There are no major features in this release, mostly bug fixes
|
||||
and performance improvements.
|
||||
|
||||
Gtk# 0.8 has been <a
|
||||
href="http://lists.ximian.com/archives/public/gtk-sharp-list/2003-February/001114.html">released</a>
|
||||
|
||||
<b>Important</b>: The contributed binaries for Windows
|
||||
binaries of Mono 0.20 contain a virus. Please read <a
|
||||
href="virus.html">this</a> if you installed the binary.
|
||||
|
||||
@item Feb 18th, 2003: Volunteers to document Gtk#
|
||||
|
||||
With the availability of a documentation browser, we are
|
||||
looking for volunteers to help us complete the documentation
|
||||
of the Gtk# binding for Mono.
|
||||
|
||||
Experience with Gtk is useful, but not mandatory. We have
|
||||
checked in stubs, and we have instructions, and resources to
|
||||
how to complete this process <a
|
||||
href="documentation.html">here</a>. Mail the <a
|
||||
href="mailto:[email protected]">[email protected]</a>
|
||||
for further discussion.
|
||||
|
||||
@item Feb 14th, 2003: OpenGL# bindings for Mono; Mono Basic updates.
|
||||
|
||||
Mark Crichton has completed his OpenGL/GLUT bindings for
|
||||
Gnome. A screenshot can be seen <a
|
||||
href="sshots/oglcs.png">here</a>. The bindings are available
|
||||
on the Mono CVS repository on the module `glgen'. This is a
|
||||
straight binding to the C API.
|
||||
|
||||
Marco has <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-February/011752.html">posted
|
||||
an update</a> on the current state of the free VB.NET compiler
|
||||
for Mono.
|
||||
|
||||
We are looking for contributors and maintainers to the
|
||||
JavaScript compiler as well (Janet)
|
||||
|
||||
@item Feb 12th, 2003: New assemblies, Gtk# stub documentation, Authenticode, Polish site
|
||||
|
||||
Mono now distributes a few new assemblies: Mono.Security.Win32
|
||||
as a layer to use the crypto functionality on Win32. The
|
||||
Mono.Posix assembly which contains functionality for taking
|
||||
advantage of Unix facilities.
|
||||
|
||||
A <a href="http://www.go-mono.pl/">Mono site in Poland</a>.
|
||||
|
||||
Stubs for the Gtk# documentation have been checked into CVS.
|
||||
If you want to contribute please read <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-February/012108.html">this
|
||||
message</a>
|
||||
|
||||
Mono development is moving quickly: Tim and Daniel have been
|
||||
improving the Oracle database provider and Sebastien Pouliot
|
||||
has got code signing to work using Authenticode with pure open
|
||||
source and managed code. Plenty of new VB.NET work from Marco
|
||||
(compiler) and Daniel (runtime). Also Jackson has resumed
|
||||
work on the IL assembler and the fully managed library to
|
||||
generate CIL images (Sergey wrote the first Mono.PEToolkit).
|
||||
|
||||
@item Feb 11th, 2003: Mono Weekly News, New assemblies.
|
||||
|
||||
<a href="http://monoevo.sourceforge.net/mwn/index.html">Mono
|
||||
Weekly News</a>: Includes a new interview, software
|
||||
announcements and the PHP/Mono integration.
|
||||
|
||||
@item Feb 5th, 2003: MonoDoc 0.1
|
||||
|
||||
A <a
|
||||
href="http://www.go-mono.com/archive/monodoc-0.1.tar.gz">preliminary
|
||||
release</a> of the Mono Documentation Browser is now availble.
|
||||
Release <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-February/011935.html">notes</a>
|
||||
|
||||
@item Jan, 22th, 2003: Mono wins award, OpenLink releases Virtuoso.
|
||||
|
||||
Mono won the `Best Open Source Project' award at the Linux
|
||||
World Expo. A description is <a
|
||||
href="http://linuxtoday.com/news_story.php3?ltsn=2003-01-23-024-26-OP-EV">here</a>
|
||||
|
||||
Open Link has a <a
|
||||
href="http://biz.yahoo.com/prnews/030123/neth013_1.html">press
|
||||
release</a> about Virtuoso 3.0: the first commercial product
|
||||
shipping that uses Mono.
|
||||
|
||||
@item Jan, 20th, 2003: Mono 0.19 released; Screenshots page; Gtk# 0.7
|
||||
|
||||
Mono 0.19 has been released. Check out the <a
|
||||
href="archive/mono-0.19">release notes</a> for an overview of
|
||||
the changes. You can get it <a href="download.html">here</a>.
|
||||
There are no major features in this release, mostly bug fixes
|
||||
and performance improvements.
|
||||
|
||||
We have now a new section <a href="screenshots.html">with
|
||||
screenshots</a> of various Mono applications. You can see
|
||||
there the new released Debugger, as well as the work in
|
||||
progress on the documentation browser.
|
||||
|
||||
<a href="http://gtk-sharp.sf.net">Gtk# 0.7</a> has been <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-January/005222.html">released</a>
|
||||
|
||||
@item Jan, 19th, 2003: Mono Debugger released.
|
||||
|
||||
After six month of extensive development, Martin Baulig has
|
||||
released the first version of the Mono debugger. The Mono
|
||||
debugger is written in C# and can debug both managed and
|
||||
unmanaged applications, support for multiple-threaded
|
||||
applications and should be relatively easy to port to new
|
||||
platforms.
|
||||
|
||||
Details of the release are available in <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-January/005192.html">post</a>.
|
||||
|
||||
The debugger contains both Gtk# and command line interfaces.
|
||||
The debugging file format used in Dwarf (its already supported
|
||||
by our class libraries and the Mono C# compiler; To debug C
|
||||
applications, you need a recent GCC, or to pass the -gdwarf-2
|
||||
flag to gcc).
|
||||
|
||||
@item Jan, 17th, 2003: DB2 provider, MacOS X
|
||||
|
||||
Christopher Bockner has contributed a DB2 System.Data client.
|
||||
|
||||
MacOS X support on the runtime has been integrated into the
|
||||
distribution, and MCS works with it.
|
||||
|
||||
Zoltan has managed to get <a
|
||||
href="http://radio.weblogs.com/0109845/">IKVM</a> (a Java VM
|
||||
for .NET) to run with Mono. The HelloWorld.class runs with
|
||||
the Mono runtime.
|
||||
|
||||
@item Jan, 13th, 2003: Mono 0.18 released
|
||||
|
||||
Mono 0.18 has been released. Check out the <a
|
||||
href="archive/mono-0.18">release notes</a> for an overview of
|
||||
the changes. You can get it <a href="download.html">here</a>.
|
||||
|
||||
@item Jan 10th, 2003: Mono Weekly News.
|
||||
|
||||
A new issue of the <a
|
||||
|
||||
+23
-5
@@ -1,7 +1,7 @@
|
||||
* Debugging information
|
||||
|
||||
Compile your programs using the `-g' flag in MCS, that will generate a file
|
||||
with the extension .dbg containing the dwarf symbols for your executable.
|
||||
Compile your programs using the `-g' flag in MCS, that will all a special
|
||||
resource containing debugging information to your executable.
|
||||
|
||||
To get stack traces with line number information, you need to run your
|
||||
program like this:
|
||||
@@ -15,9 +15,27 @@
|
||||
|
||||
* Mono Debugger
|
||||
|
||||
A new debugger has been created in C# and using Gtk# for its
|
||||
user interface, this will simplify the debugging of CLI applications.
|
||||
The Mono debugger is written in C# and can debug both managed
|
||||
and unmanaged applications, support for multiple-threaded
|
||||
applications and should be relatively easy to port to new
|
||||
platforms.
|
||||
|
||||
Stay turned for its first public release.
|
||||
Details of the release are available in <a
|
||||
href="http://lists.ximian.com/archives/public/mono-list/2003-January/011415.html">post</a>.
|
||||
|
||||
The debugger contains both Gtk# and command line interfaces.
|
||||
The debugging file format used in Dwarf (its already supported
|
||||
by our class libraries and the Mono C# compiler; To debug C
|
||||
applications, you need a recent GCC, or to pass the -gdwarf-2
|
||||
flag to gcc).
|
||||
|
||||
The debugger is available now, you can get it from <a
|
||||
href="http://primates.ximian.com/~martin/debugger/mono-debugger-0.2.0.tar.gz">here</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
* A debugging session using a dynamically generated symbol file.
|
||||
|
||||
Let's assume we have the following C# application which we want to debug:
|
||||
|
||||
<pre>
|
||||
using System;
|
||||
|
||||
public class Foo
|
||||
{
|
||||
public struct MyStruct {
|
||||
int a;
|
||||
long b;
|
||||
double c;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
Int32 value = 5;
|
||||
long test = 512;
|
||||
|
||||
MyStruct my_struct;
|
||||
my_struct.a = 5;
|
||||
my_struct.b = test;
|
||||
my_struct.c = 23323.5235;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
First of all, we need to compile it and create the .il files:
|
||||
|
||||
<pre>
|
||||
$ mcs ./Foo.cs
|
||||
$ monodis /home/export/martin/MONO-LINUX/lib/corlib.dll > corlib.il
|
||||
$ monodis Foo.exe > Foo.il
|
||||
</pre>
|
||||
|
||||
Now we can start the JIT in the debugger:
|
||||
|
||||
<pre>
|
||||
$ gdb ~/monocvs/mono/mono/jit/mono
|
||||
(gdb) r --debug=dwarf --break Foo:Main ./Foo.exe
|
||||
Starting program: /home/martin/monocvs/mono/mono/jit/mono --debug=dwarf --break Foo:Main ./Foo.exe
|
||||
0x081e8911 in ?? ()
|
||||
(gdb) call mono_debug_make_symbols ()
|
||||
(gdb) add-symbol-file /tmp/Foo.o
|
||||
Reading symbols from /tmp/Foo.o...done.
|
||||
Current language: auto; currently c++
|
||||
(gdb) frame
|
||||
#0 Foo.Main () at Foo.il:26
|
||||
26 // method line 2
|
||||
(gdb) n
|
||||
Foo.Main () at Foo.il:38
|
||||
38 IL_0000: ldc.i4.5
|
||||
(gdb) list
|
||||
33 .maxstack 2
|
||||
34 .locals (
|
||||
35 int32 V_0,
|
||||
36 int64 V_1,
|
||||
37 valuetype MyStruct V_2)
|
||||
38 IL_0000: ldc.i4.5
|
||||
39 IL_0001: stloc.0
|
||||
40 IL_0002: ldc.i4 512
|
||||
41 IL_0007: conv.i8
|
||||
42 IL_0008: stloc.1
|
||||
43 IL_0009: ldloca.s 2
|
||||
44 IL_000b: ldc.i4.5
|
||||
45 IL_000c: stfld int32 .MyStruct::a
|
||||
46 IL_0011: ldloca.s 2
|
||||
47 IL_0013: ldloc.1
|
||||
48 IL_0014: stfld int64 .MyStruct::b
|
||||
49 IL_0019: ldloca.s 2
|
||||
50 IL_001b: ldc.r8 23323.5
|
||||
51 IL_0024: stfld float64 .MyStruct::c
|
||||
52 IL_0029: ret
|
||||
(gdb) until 52
|
||||
Foo.Main () at Foo.il:53
|
||||
53 }
|
||||
(gdb) info locals
|
||||
V_0 = 5
|
||||
V_1 = 512
|
||||
V_2 = {a = 5, b = 512, c = 23323.523499999999}
|
||||
</pre>
|
||||
|
||||
As you see in this example, you need to know IL code to use this debugging method - but
|
||||
it may be the only way to debug a library.
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
* A debugging session using a symbol file which has been created by MCS.
|
||||
|
||||
Let's assume we have the following C# application which we want to debug:
|
||||
|
||||
<pre>
|
||||
using System;
|
||||
|
||||
public class Foo
|
||||
{
|
||||
public struct MyStruct {
|
||||
int a;
|
||||
long b;
|
||||
double c;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
Int32 value = 5;
|
||||
long test = 512;
|
||||
|
||||
MyStruct my_struct;
|
||||
my_struct.a = 5;
|
||||
my_struct.b = test;
|
||||
my_struct.c = 23323.5235;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
First of all, we need to compile it with MCS, assemble the generated .s file and
|
||||
create the .il files for all referenced assemblies which were not compiled with MCS:
|
||||
|
||||
<pre>
|
||||
$ mcs -g ./Foo.cs
|
||||
$ as -o Foo-debug.o Foo-debug.s
|
||||
$ monodis /home/export/martin/MONO-LINUX/lib/corlib.dll > corlib.il
|
||||
</pre>
|
||||
|
||||
Now we can start the JIT in the debugger:
|
||||
|
||||
<pre>
|
||||
$ gdb ~/monocvs/mono/mono/jit/mono
|
||||
(gdb) r --debug=dwarf-plus --break Foo:Main ./Foo.exe
|
||||
Starting program: /home/martin/monocvs/mono/mono/jit/mono --debug=dwarf-plus --break Foo:Main ./Foo.exe
|
||||
Program received signal SIGTRAP, Trace/breakpoint trap.
|
||||
0x081e8681 in ?? ()
|
||||
(gdb) call mono_debug_make_symbols ()
|
||||
(gdb) add-symbol-file Foo-debug.o
|
||||
(gdb) add-symbol-file /tmp/corlib.o
|
||||
` (gdb) frame
|
||||
#0 Main () at ./Foo.cs:11
|
||||
11 public static void Main ()
|
||||
(gdb) n
|
||||
Main () at ./Foo.cs:13
|
||||
13 Int32 value = 5;
|
||||
(gdb)
|
||||
14 long test = 512;
|
||||
(gdb)
|
||||
17 my_struct.a = 5;
|
||||
(gdb)
|
||||
18 my_struct.b = test;
|
||||
(gdb)
|
||||
19 my_struct.c = 23323.5235;
|
||||
(gdb)
|
||||
20 }
|
||||
(gdb) info locals
|
||||
value = 5
|
||||
test = 512
|
||||
my_struct = { a = 5, b = 512, c = 23323.5235 }
|
||||
</pre>
|
||||
|
||||
+7
-3
@@ -37,10 +37,14 @@
|
||||
|
||||
There is a very interesting project to make a JavaVM for .NET
|
||||
<a href="http://radio.weblogs.com/0109845/">here</a>.
|
||||
Currently this will not work with Mono, as they use some
|
||||
pieces of Managed C++ to implement the JNI interface.
|
||||
|
||||
A workaround has been discussed, contact the author if you want to contribute.
|
||||
Zoltan has got IKVM to work with Mono.
|
||||
|
||||
<a name="PHP">
|
||||
** PHP
|
||||
|
||||
Sterling has code to allow PHP developers to use Mono code, in
|
||||
his <a href="http://www.php.net/~sterling/mono/">site</a>
|
||||
|
||||
<a name="MonoLogo">
|
||||
** MonoLogo
|
||||
|
||||
+57
-6
@@ -6,7 +6,16 @@
|
||||
|
||||
There are a number of mailing lists for Mono in English:
|
||||
|
||||
<table>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<b><a
|
||||
href="http://lists.ximian.com/mailman/listinfo/mono-announce-list">mono-announce-list</a></b>
|
||||
</td>
|
||||
<td>
|
||||
Announcements of Mono developments.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b><a
|
||||
@@ -19,11 +28,39 @@
|
||||
<tr>
|
||||
<td>
|
||||
<b><a
|
||||
href="http://lists.ximian.com/mailman/listinfo/mono-announce-list">mono-announce-list</a></b>
|
||||
href="http://lists.ximian.com/mailman/listinfo/mono-devel-list">mono-devel-list</a></b>
|
||||
</td>
|
||||
<td>
|
||||
A mailing list specifically dedicated to discussions
|
||||
about developing Mono and programming *with* Mono.
|
||||
Programmers that work on Mono are _strongly_ encouraged
|
||||
to join this list. Third-party programmers interested
|
||||
in running or compiling their managed applications with
|
||||
Mono or that are interested in using mono-specific
|
||||
technologies should join the list as well.
|
||||
<p>
|
||||
Examples of on-topic arguments are:
|
||||
<ul>
|
||||
<li>proposals and patches for new features for the mono runtime and programs
|
||||
<li>discussions about bugs in the mono runtime and programs
|
||||
<li>discussions about future directions
|
||||
<li>embedding API, scripting language bridges
|
||||
<li>mono/mcs build issues
|
||||
<li>programming with mono-specific assemblies
|
||||
<li>discussions about third-party compilers that target and/or use directly the CLR
|
||||
<li>discussions about getting a managed application run with mono
|
||||
</ul>
|
||||
|
||||
<p>Topics that are better discussed on other mailing lists:
|
||||
<ul>
|
||||
<li> general C# questions (use the specific lists at develop.com)
|
||||
<li> issues that are already covered by a more specific mono
|
||||
mailing list (like System.Windows.Forms or Gtk#)
|
||||
<li> success reports about new apps running on mono, including
|
||||
runtime/buildtime support for new programming languages (use
|
||||
mono-list to reach a wider audience)
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
Announcements of Mono developments.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@@ -40,7 +77,7 @@
|
||||
href="http://lists.ximian.com/mailman/listinfo/mono-patches">mono-patches</a></b>
|
||||
</td>
|
||||
<td>
|
||||
Track the CVS activity of Mono on this mailing list (patches are sent to recipients).
|
||||
Track the CVS activity of Mono on this mailing list (patches are sent to recipients). <p>
|
||||
You can get <a href="http://www.go-mono.com/snapshots">daily snapshots</a> as well.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -80,6 +117,15 @@
|
||||
Used to discuss the Windows.Forms implementatation for Mono using Wine.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b><a
|
||||
href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">gtk-sharp-list</a></b>
|
||||
</td>
|
||||
<td>
|
||||
Used to discuss the Gtk bindings for Mono (<a href="http://gtk-sharp.sf.net">Gtk#</a>).
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Other mailing lists of interest:
|
||||
@@ -92,6 +138,11 @@
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
* Alternative archive site
|
||||
|
||||
An alternate site that archives Mono List is available <a
|
||||
href="http://archive.neotonic.com/archive/mono-list">http://archive.neotonic.com/archive/mono-list</a>
|
||||
|
||||
* Google search of the archives
|
||||
|
||||
<!-- Google Search with mods -->
|
||||
|
||||
+14
-2
@@ -155,8 +155,20 @@ export PKG_CONFIG_PATH
|
||||
# /usr/local/include and /usr/local/lib to CPPFLAGS and LDFLAGS. We could
|
||||
# skip this if it would add /usr/include and /usr/lib, but leaving it
|
||||
# shouldnt break anything.
|
||||
iconvh=`locate include/iconv.h`
|
||||
iconvh_dir=`dirname $iconvh`
|
||||
iconvdirs="/usr/include /usr/local/include"
|
||||
for i in $iconvdirs
|
||||
do
|
||||
if [ -f $i/iconv.h ]; then
|
||||
iconvh_dir=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$iconvh_dir" ]; then
|
||||
echo "Can't find iconv headers (looked in $iconvdirs)"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
iconvlib_dir=`echo $iconvh_dir | sed -e 's/include/lib/'`
|
||||
|
||||
echo "Adding $iconvh_dir to CPPFLAGS"
|
||||
|
||||
@@ -1,66 +1,329 @@
|
||||
* MySQL Data Provider
|
||||
|
||||
<ul>
|
||||
<li>MySQL Data Provider for
|
||||
<a href="http://www.mysql.com/">MySQL</a> databases. It is written in C# and uses
|
||||
the MySQL C Client Library
|
||||
<p>There are two ADO.NET providers in Mono
|
||||
for a <a href="http://www.mysql.com/">MySQL</a> database:
|
||||
|
||||
<li>Exists in namespace Mono.Data.MySql and assembly Mono.Data.MySql
|
||||
|
||||
<li>Works on Windows and Linux via the MySQL client shared library
|
||||
(libmySQL.dll on Windows and libmysqlclient.so on Linux).
|
||||
|
||||
<li>Started by Daniel Morgan using C# Bindings to MySQL from Brad Meril.
|
||||
|
||||
<li><a href="http://www.mysql.com/articles/dotnet/">Exploring MySQL in the Microsoft .NET Environment</a> is an article
|
||||
by Mr. Venu who is a MySQL AB developer.
|
||||
|
||||
<li>Other projects which have created a .NET Data provider for MySQL in C#
|
||||
<ul>
|
||||
<li><a href="http://sourceforge.net/projects/mysqlnet/">ByteFX.Data.MySQLClient</a>
|
||||
<ul>
|
||||
<li><a href="http://sourceforge.net/projects/mysqldrivercs/">MySQLDriverCS</a> is a MySQL provider written in C#
|
||||
<li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> is a MySQL Manager provider written in C#
|
||||
|
||||
<li>Written in 100% C#</li>
|
||||
<li>Does not require a client library</li>
|
||||
<li>Works on Mono and Microsoft .NET</li>
|
||||
<li>Requires at least Mono 0.18 and MySQLNet 0.65 for it to work on Mono</li>
|
||||
<li>Works in the SQL# command-line and GTK# GUI version</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Mono.Data.MySql (deprecated)
|
||||
<ul>
|
||||
<li>Deprecated in favor of ByteFX.Data.MySQLClient
|
||||
|
||||
<li>Written in C# and uses
|
||||
the MySQL C Client Library</li>
|
||||
|
||||
<li>Exists in namespace Mono.Data.MySql and assembly Mono.Data.MySql</li>
|
||||
|
||||
<li>Works on Windows and Linux via the MySQL client shared library
|
||||
(libmySQL.dll on Windows and libmysqlclient.so on Linux).</li>
|
||||
|
||||
<li>Started by Daniel Morgan using
|
||||
<a href="http://www.cybercom.net/~zbrad/DotNet/MySql/">C# Bindings to MySQL</a> from <a href="mailto:[email protected]">Brad Merill</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><a href="http://www.mysql.com/articles/dotnet/">Exploring MySQL
|
||||
in the Microsoft .NET Environment</a> is an article
|
||||
by Mr. Venu who is a MySQL AB developer.</li>
|
||||
|
||||
<p>Testing for Mono's Mono.Data.MySql and ByteFX's ByteFX.Data.MySQLClient is below.
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
Current Status of the MySQL providers:
|
||||
|
||||
<ul>
|
||||
<li>can connect
|
||||
|
||||
<li>ByteFX.Data.MySQLClient
|
||||
<ul>
|
||||
<li>Build and Runs on Microsoft .NET and Mono</li>
|
||||
<li>Works with SQL# (command-line and GTK# GUI versions)</li>
|
||||
<li>MySQLCommandBuilder now implemented</li>
|
||||
<li>Transaction support now implemented (not all table types support this)</li>
|
||||
<li>GetSchemaTable fixed to not use xsd (for Mono)</li>
|
||||
<li>Driver is now Mono-compatible</li>
|
||||
<li>TIME data type now supported</li>
|
||||
<li>More work to improve Timestamp data type handling</li>
|
||||
<li>Changed signatures of all classes to match corresponding SqlClient classes</li>
|
||||
<li>Protocol compression using <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/default.asp">SharpZipLib</a></li>
|
||||
<li>Named pipes on Windows now working properly</li>
|
||||
<li>Work done to improve Timestamp data type handling</li>
|
||||
<li>Implemented IEnumerable on DataReader so DataGrid would work</li>
|
||||
<li>Speed increased dramatically by removing bugging network sync code</li>
|
||||
<li>Driver no longer buffers rows of data (more ADO.Net compliant)</li>
|
||||
<li>Conversion bugs related to TIMESTAMP and DATETIME fields fixed</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>can execute non-queries via ExecuteNonQuery()
|
||||
|
||||
<li>can execute aggregates via ExecuteScalar() and retrieve the
|
||||
single row/single column result
|
||||
|
||||
<li>can execute queries and retrieve results using a data reader.
|
||||
|
||||
<li>a schema DataTable has been partially
|
||||
implemented which is returned from GetSchemaTable() in MySqlDataReader.
|
||||
|
||||
<li>a DataTable in a DataSet can be filled via a MySqlDataAdapter
|
||||
<li>Mono.Data.MySql (deprecated)
|
||||
<ul>
|
||||
<li>Currently, only works with version 3.23.x of MySQL</li>
|
||||
|
||||
<li>The shared client libraries
|
||||
between windows version and linux are different: windows has libmySQL.dll
|
||||
while linux has libmysqlclient.so. This is handled by the
|
||||
file etc/mono/config which is mapped by the mono runtime in knowing
|
||||
which native shared library to load. In cvs, this file is mono/config.in and
|
||||
can be modified with a text editor.
|
||||
<li>can connect</li>
|
||||
|
||||
<li>can execute non-queries via ExecuteNonQuery()</li>
|
||||
|
||||
<li>can execute aggregates via ExecuteScalar() and retrieve the
|
||||
single row/single column result</li>
|
||||
|
||||
<li>can execute queries and retrieve results using a data reader.</li>
|
||||
|
||||
<li>a schema DataTable has been partially
|
||||
implemented which is returned from GetSchemaTable() in MySqlDataReader.</li>
|
||||
|
||||
<li>a DataTable in a DataSet can be filled via a MySqlDataAdapter</li>
|
||||
|
||||
<li>The shared client libraries
|
||||
between windows version and linux are different: windows has libmySQL.dll
|
||||
while linux has libmysqlclient.so. This is handled by the
|
||||
file etc/mono/config which is mapped by the mono runtime in knowing
|
||||
which native shared library to load. In cvs, this file is mono/config.in and
|
||||
can be modified with a text editor.</li>
|
||||
|
||||
<li>Works in the SQL# command-line and GTK# GUI version</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Action plan
|
||||
** Action plan
|
||||
|
||||
The current plan to work on the MySQL data provider:
|
||||
The current plan for the MySQL data providers:
|
||||
|
||||
<ul>
|
||||
<li>ByteFX.Data.MySQLClient
|
||||
<ul>
|
||||
<li>Testing and fixes</li>
|
||||
<li>Implement missing features</li>
|
||||
<li>Only fixes for bugs to build and run MySQLClient on Mono
|
||||
will be accepted in mono-cvs. Most bugs and any new features will
|
||||
go into sourceforge cvs. Anytime there is a release of MySQLClient,
|
||||
the source code will be copied from sourceforge cvs to mono-cvs</li>
|
||||
<li>Releases of MySQLClient are determined by Reggie Burnett and releases
|
||||
of Mono are determined by Miguel de Icaza</li>
|
||||
<li>Implement any missing features or fix any bugs in Mono to get new
|
||||
features all of MySQLClient to work on Mono</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Mono.Data.MySql (deprecated)
|
||||
<ul>
|
||||
<li>Testing and bug fixes</li>
|
||||
<li>Mono.Data.MySql is deprecated and therefore maybe removed
|
||||
at a later date. It will stay in Mono for now because other
|
||||
programs maybe using it now.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
** Testing for MySQLNet provider (ByteFX.Data.MySQLClient)
|
||||
|
||||
<ul>
|
||||
<li>Have access to a MySQL database or download it from
|
||||
<ul>
|
||||
<li><a href="http://www.mysql.com/downloads/index.html">MySQL AB</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>MySQLNet can be gotten from <a href="http://sourceforge.net/projects/mysqlnet/">here</a> and the
|
||||
binary assembly ByteFX.Data.dll needs to be installed
|
||||
in the same place as the mono class libraries.</li>
|
||||
|
||||
<li>MySQLNet requires <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/default.asp">SharpZipLib</a> which is
|
||||
a Zip Library written in 100% C#. This is used for compression/decompression of data
|
||||
sent/received over the network. The SharpZipLib binary assembly SharpZipLib.dll should
|
||||
be installed in the same place as the mono class libraries.</li>
|
||||
|
||||
<li>Has a ConnectionString format:
|
||||
<pre>
|
||||
"Server=hostname;" +
|
||||
"Database=database;" +
|
||||
"User ID=username;" +
|
||||
"Password=password"
|
||||
</pre>
|
||||
</li>
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using ByteFX.Data.MySQLClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=test;" +
|
||||
"User ID=myuserid;" +
|
||||
"Password=mypassword;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new MySQLConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = (string) reader["firstname"];
|
||||
string LastName = (string) reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Parameters support via MySqlParameter and MySqlParameterCollection
|
||||
|
||||
<li>Support LOBs (Large Object)
|
||||
|
||||
<li>Change the MySQL provider to not be dependent on a client library and
|
||||
be written in 100% C#
|
||||
|
||||
<li>Connection pooling
|
||||
|
||||
<li>Get the provider to work like other data providers
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r ByteFX.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r ByteFX.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Testing for Mono's MySQL provider (Mono.Data.MySql)
|
||||
|
||||
<ul>
|
||||
<li>Have access to a MySQL database or download it from
|
||||
<ul>
|
||||
<li><a href="http://www.mysql.com/downloads/index.html">MySQL AB</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Take a look at MySqlTest.cs in mcs/class/Mono.Data.MySql/Test</li>
|
||||
<li>On Linux, you may need to make a symbolic link from libmySQL.dll to libmysqlclient.dll</li>
|
||||
|
||||
<li>Has a ConnectionString format:
|
||||
<pre>
|
||||
"Server=hostname;Database=database;User ID=username;Password=password"
|
||||
(or)
|
||||
"Host=hostname;Dbname=database;User=username;Passwd=password"
|
||||
</pre>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.MySql;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=test;" +
|
||||
"User ID=myuserid;" +
|
||||
"Password=mypassword;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new MySqlConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["firstname"];
|
||||
string LastName = reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs \
|
||||
-r System.Data.dll \
|
||||
-r Mono.Data.MySql.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll \
|
||||
-r Mono.Data.MySql.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@@ -1,52 +1,218 @@
|
||||
* ODBC Data Provider
|
||||
<ul>
|
||||
<li>Exists in namespace System.Data.Odbc and assembly System.Data
|
||||
|
||||
<li>Works on Windows and Linux
|
||||
|
||||
<li>Works on Windows via the native Windows odbc32.dll
|
||||
|
||||
<li>Works on Linux via <a href="http://www.unixodbc.org/">unixODBC</a>
|
||||
|
||||
<li>List of unixODBC <a href="http://www.unixodbc.org/drivers.html">drivers</a> and
|
||||
an alternative list
|
||||
|
||||
<li>An alternative to unixODBC, but not tested with this
|
||||
provider is <a href="http://www.iodbc.org">iODBC</a>
|
||||
|
||||
<li>Another alternative to unixODBC, but not tested this provider is
|
||||
<a href="http://oplweb.openlinksw.com:8080/download/">OpenLink's</a>.
|
||||
<ul>
|
||||
|
||||
<li>ADO.NET Data Provider for Data Sources
|
||||
that have <a href="http://www.microsoft.com/data/odbc/">ODBC</a> support.</li>
|
||||
|
||||
<li>Exists in namespace System.Data.Odbc and assembly System.Data</li>
|
||||
|
||||
<li>Works on Windows and Linux. Should have no problems working on UNIX too.</li>
|
||||
|
||||
<li>Works on Windows via the native Windows odbc32.dll</li>
|
||||
|
||||
<li>Works on Linux via:
|
||||
|
||||
<ul>
|
||||
<li><a href="http://www.unixodbc.org/">unixODBC</a> which has
|
||||
commercial support
|
||||
from <a href="http://www.easysoft.com/">Easysoft</a></li>
|
||||
|
||||
<li><a href="http://www.iodbc.org/">iODBC</a> which has
|
||||
commercial support
|
||||
from <a href="http://oplweb.openlinksw.com:8080/download/">OpenLink Software</a></li>
|
||||
</ul>
|
||||
|
||||
<li>List of unixODBC <a href="http://www.unixodbc.org/drivers.html">drivers</a>
|
||||
|
||||
<li>List of <a href="http://ourworld.compuserve.com/homepages/Ken_North/odbcvend.htm">ODBC Vendors</a>
|
||||
|
||||
<li>ODBC can connect to various databases which has an ODBC driver installed:
|
||||
<ul>
|
||||
<li><a href="http://www.mysql.com/">MySQL</a></li>
|
||||
<li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
|
||||
<li><a href="http://www.oracle.com/">Oracle</a></li>
|
||||
<li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
|
||||
<li><a href="http://www.sybase.com/downloads">Sybase</a> (
|
||||
via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
|
||||
<li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
|
||||
via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
|
||||
<li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
|
||||
<li><a href="http://www.microsoft.com/office/access/default.asp">MS Access</a>
|
||||
(via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a> on UNIX)</li>
|
||||
</ul>
|
||||
|
||||
<li>ODBC Provider created by Brian Ritchie.
|
||||
<li>ODBC Provider created by Brian Ritchie.</li>
|
||||
|
||||
<li>Does not support trusted connections</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Connect on Windows via native Windows odbc32.dll
|
||||
|
||||
<li>Connect on Linux via unixODBC's libodbc.so
|
||||
<li>Can Connect on:
|
||||
<ul>
|
||||
<li>Windows via native Windows odbc32.dll</a></li>
|
||||
<li>Linux via:
|
||||
<ul>
|
||||
<li>unixODBC's libodbc.so</li>
|
||||
<li>iODBC's libiodbc.so</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Various databases have been tested using their
|
||||
ODBC drivers: MySQL, Oracle, IBM DB2, and Microsoft SQL Server
|
||||
ODBC drivers: MySQL, PostgreSQL, Oracle, IBM DB2, and Microsoft SQL Server</li>
|
||||
|
||||
<li>Can execute non-query commands via ExecuteNonQuery of a OdbcCommand
|
||||
<li>Can execute non-query commands via ExecuteNonQuery of a OdbcCommand</li>
|
||||
|
||||
<li>Can execute aggreates and retrieve a single row single column result via
|
||||
ExecuteScalar of a OdbcCommand
|
||||
ExecuteScalar of a OdbcCommand</li>
|
||||
|
||||
<li>Can execute queries via ExecuteReader of a OdbcCommand and
|
||||
retrieve results using an OdbcDataReader.
|
||||
retrieve results using an OdbcDataReader</li>
|
||||
|
||||
<li>Can get a DataTable containing schema info via GetSchemaTable() in a OdbcDataReader</li>
|
||||
|
||||
<li>Can Fill a DataTable in a DataSet via an OdbcDataAdapter</li>
|
||||
|
||||
<li>Works in SQL#, but Column names don't show up correctly.</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
|
||||
<li>Can get a DataTable containing schema info via GetSchemaTable() in a OdbcDataReader
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Action Plan
|
||||
|
||||
<ul>
|
||||
<li>Create a Data Adapter to Fill data into a DataTable in a DataSet
|
||||
|
||||
<li>TODO
|
||||
<li>Fixing bugs
|
||||
|
||||
<li>Testing with other setups
|
||||
</ul>
|
||||
|
||||
** Testing ODBC provider with IBM DB2 Universal Database
|
||||
|
||||
<ul>
|
||||
<li>You need a working mono and mcs</li>
|
||||
|
||||
<li>For Unix, you will need unixODBC or iODBC installed</li>
|
||||
|
||||
<li>Have acess to a <a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a> or
|
||||
you can download from IBM</li>
|
||||
|
||||
<li>Read these web pages about Unix, ODBC, and IBM DB2
|
||||
|
||||
<ul>
|
||||
<li><a href="http://www.unixodbc.com/doc/db2.html">unixODBC web page about IBM DB2</a></li>
|
||||
<li><a href="http://www-3.ibm.com/software/data/db2/udb/ad/v8/cli/t0010406">IBM web page about unixODBC and DB2</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>The ODBC provider is similar to the <a href="http://www.go-mono.com/ibmdb2.html">IBM DB2</a> provider.</li>
|
||||
</ul>
|
||||
|
||||
** Testing ODBC provider with MySQL
|
||||
|
||||
<p>You can test Mono's ODBC provider System.Data.Odbc with the MySQL ODBC driver MyODBC
|
||||
|
||||
<p><ul>
|
||||
<li>Take a look at OdbcTest.cs in mcs/class/System.Data/Test</li>
|
||||
|
||||
<li>Here is a ConnectionString format if you have a DSN setup:
|
||||
<pre>
|
||||
"DSN=dataSetName;UID=myuserid;PWD=mypassword"
|
||||
</pre>
|
||||
</li>
|
||||
<li>Here is a ConnectionString format if you do not have a DSN (have not
|
||||
gotten this to work though):
|
||||
<pre>
|
||||
"DRIVER={MySQL ODBC 3.51 Driver};" +
|
||||
"SERVER=localhost;DATABASE=test;" +
|
||||
"UID=myuserid;PASSWORD=mypassword;" +
|
||||
"OPTION=3";
|
||||
|
||||
</pre>
|
||||
</li>
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Odbc;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// have an ODBC DSN setup named MYSQLDSN
|
||||
// that accesses a MySQL database via
|
||||
// MyODBC driver for ODBC with a
|
||||
// hostname of localhost and database test
|
||||
string connectionString =
|
||||
"DSN=MYSQLDSN;" +
|
||||
"UID=myuserid;" +
|
||||
"PWD=mypassword";
|
||||
IDbConnection dbcon;
|
||||
dbcon.Open();
|
||||
dbcon = new OdbcConnection(connectionString);
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["firstname"];
|
||||
string LastName = reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@@ -1,53 +1,153 @@
|
||||
* OLE DB Provider
|
||||
|
||||
<ul>
|
||||
<li> Provides a OleDb-like provider for Mono
|
||||
using <a href="http://www.gnome-db.org/">GDA</a> as the data access layer.
|
||||
using <a href="http://www.gnome-db.org/">GDA</a> as the data access layer.</li>
|
||||
|
||||
<li> Exists in namespace System.Data.OleDb and assembly System.Data
|
||||
<li> Exists in namespace System.Data.OleDb and assembly System.Data</li>
|
||||
|
||||
<li>Created by Rodrigo Moya
|
||||
<li>Created by Rodrigo Moya</li>
|
||||
|
||||
<li>LibGDA has providers for:
|
||||
<li>LibGDA has providers for:</li>
|
||||
<ul>
|
||||
<li><a href="http://www.mysql.com/">MySQL</a>
|
||||
<li><a href="http://www.postgresql.org/">PostgreSQL</a>
|
||||
<li>XML
|
||||
<li>ODBC (via <a href="http://www.unixodbc.org/">unixODBC</a>)
|
||||
<li><a href="http://www.oracle.com/">Oracle</a>
|
||||
<li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a>
|
||||
<li><a href="http://www.mysql.com/">MySQL</a></li>
|
||||
<li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
|
||||
<li>XML</li>
|
||||
<li>ODBC (via <a href="http://www.unixodbc.org/">unixODBC</a>)</li>
|
||||
<li><a href="http://www.oracle.com/">Oracle</a></li>
|
||||
<li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
|
||||
<li><a href="http://www.sybase.com/downloads">Sybase</a> and
|
||||
<a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
|
||||
via <a href="http://www.freetds.org/">FreeTDS</a>)
|
||||
<li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a>
|
||||
<li><a href="http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a>
|
||||
<li><a href="http://www.microsoft.com/office/access/default.asp">MS Access</a>
|
||||
(via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a>)
|
||||
via <a href="http://www.freetds.org/">FreeTDS</a>)</li>
|
||||
<li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
|
||||
<li><a href="http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a></li>
|
||||
<li><a href="http://www.microsoft.com/office/access/default.asp">MS Access</a></li>
|
||||
(via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a>)</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Does not support trusted connections</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
<ul>
|
||||
<li>The OleDb provider is working with libgda (an OLE-DB/ADO data access for Unix).
|
||||
The C-Sharp bindings to libgda currently work - meaning they can compile, run,
|
||||
and you can connect to a
|
||||
PostgreSQL database via libgda via the C-Sharp bindings to libgda.
|
||||
PostgreSQL database via libgda via the C-Sharp bindings to libgda.</li>
|
||||
|
||||
<li>Basic
|
||||
functionality (execution of commands, data retrieval, transactions, etc) are
|
||||
now working.
|
||||
now working.</li>
|
||||
|
||||
<li>An inital implementation of GetSchemaTable() for
|
||||
the OleDbDataReader has been checked into cvs. GetSchemaTable() isn't correct for OleDb,
|
||||
but the foundation is there.
|
||||
but the foundation is there.</li>
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Action Plan
|
||||
<ul>
|
||||
<li>Current focus is on filling up the missing pieces (Data adapters
|
||||
mainly) and schema support.
|
||||
mainly) and schema support.</li>
|
||||
|
||||
<li>We need help building libgda on Windows though. libgda
|
||||
builds find on linux though.
|
||||
builds find on linux though.</li>
|
||||
|
||||
<li>Need to make the OleDb provider compatible with the OleDb provider in Microsoft .NET
|
||||
<li>Need to make the OleDb provider compatible with the OleDb provider in Microsoft .NET</li>
|
||||
</ul>
|
||||
|
||||
** Testing OleDb with libgda's PostgreSQL provider
|
||||
|
||||
<ul>
|
||||
<li>Requires a working mono and mcs</li>
|
||||
<li>Requires Linux because the OleDb provider uses libgda and libgda only
|
||||
works on Linux.</li>
|
||||
<li>Connection String format: "Provider=providerName;...". providerName is the
|
||||
name of the Provider you use, such as, PostgreSQL, MySQL, etc. The elipsis ...
|
||||
means that the connection parameters are dependent upon the provider being used and
|
||||
are passed to libgda for connecting. Such paramters, can be: Database, User ID, Password,
|
||||
Server, etc...</li>
|
||||
<li>See the test TestOleDb.cs found at mcs/class/System.Data/System.Data.OleDb</li>
|
||||
<li>C# Example for Mono's System.Data.OleDb:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// there is a libgda PostgreSQL provider
|
||||
string connectionString =
|
||||
"Provider=PostgreSQL;" +
|
||||
"Addr=127.0.0.1;" +
|
||||
"Database=test;" +
|
||||
"User ID=postgres;" +
|
||||
"Password=fun2db";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new OleDbConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["firstname"];
|
||||
string LastName = reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+161
-29
@@ -1,52 +1,184 @@
|
||||
* Oracle Data Provider
|
||||
|
||||
<ul>
|
||||
|
||||
<li>ADO.NET Data Provider for <a href="http://www.oracle.com/">Oracle</a> databases</li>
|
||||
|
||||
<li>Exists in namespace System.Data.OracleClient and assembly System.Data.OracleClient</li>
|
||||
|
||||
<li>Works on Windows</li>
|
||||
|
||||
<li>Works with Oracle 8i</li>
|
||||
|
||||
<li>More information about Oracle can be found at <a href="http://www.oracle.com/"/>here</a></li>
|
||||
<li>Works on Windows and Linux</li>
|
||||
|
||||
<li>Works with Oracle 8i</li>
|
||||
|
||||
<li>Untested, but should work with Oracle 9i</li>
|
||||
|
||||
<li>Uses the Oracle CLI (Call Level Interface) which is a C library (API) for the Oracle Client
|
||||
software</li>
|
||||
|
||||
<li>Internally, the OracleClient provider has OCI abstracted to an object-oriented programming model</li>
|
||||
|
||||
<li>Created by Daniel Morgan and Tim Coleman</li>
|
||||
|
||||
<li>Does not support trusted connections</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>OracleConnection can connect to an Oracle 8i database on
|
||||
Windows via oci.dll</li>
|
||||
<li>OracleConnection can connect and disconnect to an Oracle 8i database on
|
||||
Windows and Linux via OCI (Oracle Call-level Interface)</li>
|
||||
|
||||
<li>The native glue library only has makefiles for Borland C++ and
|
||||
Microsoft Visual C++ command line compilers. Only the makefile for
|
||||
Microsoft Visual C++ command-line compiler has been tested.</li>
|
||||
<li>No longer uses a glue library (a library between the System.Data.OracleClient.dll
|
||||
assembly and the oci library). In Current Mono cvs, System.Data.OracleClient
|
||||
directly platform invokes into the oci library thanks to Tim Coleman.</li>
|
||||
|
||||
<li>Can have multiple connections with different transactions where each transaction is
|
||||
separated from the others, so a rollback or commit in one transaction
|
||||
does not affect the other.</li>
|
||||
|
||||
<li>Can execute simple DML SQL statements, such as,
|
||||
INSERT a row into the EMP table via the OracleCommand's ExecuteNonQuery method</li>
|
||||
|
||||
|
||||
<li>The System.Data.OracleClient.dll assembly can be built with mcs/mono via
|
||||
the makefile.gnu for System.Data.OracleClient or csc/.net via the
|
||||
System.Data.OracleClient.build nant build file. There is also a Visual Studio.NET
|
||||
solution it too.
|
||||
System.Data.OracleClient.build nant build file.</li>
|
||||
|
||||
<li>Can retrieve data via ExecuteReader and OracleDataReader. Currently,
|
||||
supports character, numeric, some date data types. ExecuteScalar
|
||||
also works.</li>
|
||||
|
||||
<li>Simple input parameters (character and numeric data) can now
|
||||
be used in SQL queries. Output parameters do not yet work.</li>
|
||||
|
||||
<li>OracleException and Error handling exists now.</li>
|
||||
|
||||
<li>Message handling needs to be added for non-critical messages
|
||||
received from Oracle</li>
|
||||
|
||||
<li>Handling of various data types need to be added.</li>
|
||||
|
||||
<li>Data Adapter exists, and a DataSet can be filled using it. The
|
||||
Data Adapter is abstract enough that it should work as expected.</li>
|
||||
|
||||
<li>Lots of missing functionality and bugs.</li>
|
||||
|
||||
<li>Works with SQL# command-line and GTK# versions in cvs. Only works with
|
||||
simple character data though. SQL# For GTK# can only show the results to
|
||||
the TextView because the Data Adapter is not yet available</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Action Plan
|
||||
|
||||
<ul>
|
||||
<li>Get the makefile for the Borland C++ compiler to work
|
||||
since the <a href="http://www.borland.com/">Borland</a> C++ compiler is
|
||||
a free download</li>
|
||||
<li>Get the native glue lib System.Data.OracleClient.ocigule.dll to be built
|
||||
using gcc on Linux. This would require that Oracle 8i client software be installed
|
||||
on Linux with the oci headers and shared libraries</li>
|
||||
<li>Be able to retrieve results via a data reader</li>
|
||||
<li>Parameters support</li>
|
||||
<li>Be able to retrieve results via a data reader (WORKING)</li>
|
||||
<li>Parameters support (IN PROGRESS)</li>
|
||||
<li>transactions (WORKING)</li>
|
||||
<li>Stored Procedures, Functions, and Packages support</li>
|
||||
<li>Be able to fill a DataTable in a DataSet via a data adapter</li>
|
||||
<li>Support for Oracle 9i</li>
|
||||
<li>Figure out how to move the unmanaged OCI handling code in
|
||||
the oci glue C library to the managed C# assembly. I have been unable
|
||||
to successfully connect to an Oracle 8i database by using Platform Invoke and
|
||||
Marshalling in C# to the oci shared library (oci.dll on Windows)</li>
|
||||
<li>Be able to fill a DataTable in a DataSet via a data adapter (IN PROGRESS)</li>
|
||||
<li>Support for Oracle 8i and 9i (UNKNOWN)</li>
|
||||
<li>Support LOBs</li>
|
||||
<li>Support all the data types</li>
|
||||
<li>Implement Connection pooling</li>
|
||||
<li>Security</li>
|
||||
|
||||
</ul>
|
||||
|
||||
** Testing System.Data.OracleClient
|
||||
|
||||
<ul>
|
||||
<li>Have a working mono and mcs</li>
|
||||
|
||||
<li>Have access to an Oracle 8i database or download it from
|
||||
<a href="http://www.oracle.com/">Oracle</a>. If you are connecting
|
||||
remotely to an Oracle database, you need the Oracle client software.
|
||||
Registration to the <a href="http://technet.oracle.com/">Oracle Technology Network</a> is free. If installing on Linux,
|
||||
I suggest you do a lot of searching to see how others installed Oracle on Linux.</li>
|
||||
|
||||
<li>Make sure System.Data.OracleClient.dll assembly is built, if not, go
|
||||
into System.Data.OracleClient and do a make -f makefile.gnu (on Linux) or
|
||||
../../nant/NAnt.exe (on Windows using Cygwin).</li>
|
||||
|
||||
<li>Take a look at TestOracleClient.cs found at mcs/class/System.Data.OracleClient/Test</li>
|
||||
|
||||
<li>The Data Source is an Oracle TNSNAME</li>
|
||||
|
||||
<li>Has a connection string format:
|
||||
<pre>
|
||||
"Data Source=tnsname;User ID=userid;Password=password"
|
||||
</pre>
|
||||
</li>
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OracleClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Data Source=testdb;" +
|
||||
"User ID=scott;" +
|
||||
"Password=tiger;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new OracleConnection (connectionString);
|
||||
dbcon.Open ();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand ();
|
||||
string sql = "SELECT ename, job FROM scott.emp";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader ();
|
||||
while (reader.Read ()) {
|
||||
string employeeName = reader["ename"];
|
||||
string job = reader["job"];
|
||||
Console.WriteLine ("Employee Name: {0} Job: {1}",
|
||||
employeeName, job);
|
||||
}
|
||||
// clean up
|
||||
reader.Close ();
|
||||
reader = null;
|
||||
dbcmd.CommandText = sql;
|
||||
dbcmd.ExecuteNonQuery ();
|
||||
dbcmd.Dispose ();
|
||||
dbcmd = null;
|
||||
dbcon.Close ();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r System.Data.OracleClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r System.Data.OracleClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
* International sites
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a href="http://mono.es.gnome.org">Mono
|
||||
Hispano</a>: The spanish-speaking community of Mono
|
||||
developers and users. They have quite a number of
|
||||
unique documents and tutorials.
|
||||
|
||||
<li><a href="http://www.go-mono.pl">Mono Poland</a>:
|
||||
Mono site for polish users.
|
||||
|
||||
</ul>
|
||||
|
||||
* User sites
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Alp Toker's <a
|
||||
href="http://www.atoker.com/mono/">site</a>: He is an
|
||||
active Mono developer (gsirc, platano) and produces
|
||||
very nice Debian packages of Mono.
|
||||
|
||||
<li>Brian Ritchie's <a
|
||||
href="http://www12.brinkster.com/brianr/">site</a>:
|
||||
Brian is a contributor to Mono's class library (ODBC
|
||||
provider and the database multiplexing assembly), and
|
||||
has built an application server for .NET and Mono.
|
||||
His site contains news, software, as well as his
|
||||
weblog.
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
+297
-231
@@ -1,81 +1,187 @@
|
||||
* PostgreSQL Data Provider
|
||||
|
||||
There are two ADO.NET data providers for <a href="http://www.postgresql.org/">PostgreSQL</a> in Mono:
|
||||
|
||||
<ul>
|
||||
<li>Exists in namespace Mono.Data.PostgreSql and assembly Mono.Data.PostgreSql
|
||||
|
||||
<li><a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a>
|
||||
<ul>
|
||||
<li>a .NET Managed Data Provider for PostgreSQL
|
||||
|
||||
<li>Written in 100% C#</li>
|
||||
|
||||
<li>does not require a client library</li>
|
||||
|
||||
<li>works on Mono and Microsoft .NET</li>
|
||||
|
||||
<li>created by Francisco Figueiredo jr. and has many developers working on it
|
||||
|
||||
<li>works in the SQL# (command-line and GTK# GUI versions)</li>
|
||||
|
||||
<li>in namespace Npgsql and assembly Npgsql and is found in mcs
|
||||
at mcs/class/Npgsql</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Is a Mono Data Provider for the <a href="http://www.postgresql.org/">PostgreSQL</a>
|
||||
client/server database management system.
|
||||
<li>Mono.Data.PostgreSQL (deprecated)
|
||||
<ul>
|
||||
<li>Deprecated in favor of Npgsql</li>
|
||||
|
||||
<li>Exists in namespace Mono.Data.PostgreSql and assembly Mono.Data.PostgreSql</li>
|
||||
|
||||
<li>Written in C# and has C# bindings to the PostgreSQL C Client library pq.dll on Windows
|
||||
and libpq.so on Linux.
|
||||
<li>Is a Mono Data Provider for the <a href="http://www.postgresql.org/">PostgreSQL</a>
|
||||
client/server database management system.</li>
|
||||
|
||||
<li>Written in C# and has C# bindings to the PostgreSQL C Client library pq.dll on Windows
|
||||
and libpq.so on Linux.</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
Below, see separate Testing sections for Npgsql and Mono.Data.PostgreSqlClient.
|
||||
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Npgsql
|
||||
<ul>
|
||||
<li>Builds and Runs on both Microsoft .NET and Mono.</li>
|
||||
<li>Works using SQL# (command-line and GTK# versions)</li>
|
||||
<li>You can send insert, update, delete queries
|
||||
through NpgsqlCommand.ExecuteNonQuery() method.</li>
|
||||
<li>You can send queries like, select count(*) from table, select version()
|
||||
with NpgsqlCommand.ExecuteScalar() method.</li>
|
||||
<li>There is logging support. (Thanks Dave Page)
|
||||
To use it, place code like that in your program:</li>
|
||||
|
||||
<pre>
|
||||
// Enable logging.
|
||||
NpgsqlEventLog.Level = LogLevel.Debug; // LogLevel.
|
||||
NpgsqlEventLog.LogName = "NpgsqlTests.LogFile"; // LogFile.
|
||||
</pre>
|
||||
|
||||
<li>You can use Npgsql with Mono (Thanks Kristis Makris). It is not working perfectly.</li>
|
||||
<li>There is a winforms test suite (Thanks Dave Page).</li>
|
||||
<li>Clearer code in NpgsqlConnection removing *magic* numbers and constants. (Thanks Kristis Makris)</li>
|
||||
<li>Better support of ODBC-like ConnectionString in NpgsqlConnection (Thanks Dave Page)</li>
|
||||
<li>Thanks Ulrich Sprick for all discussion and ideas.</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<li>Mono.Data.PostgreSQL status
|
||||
<ul>
|
||||
|
||||
<li>Deprecated in favor of Npgsql</li>
|
||||
|
||||
<li>We are able to do simple CREATE TABLE, DROP TABLE, UPDATE, INSERT, and
|
||||
DELETE SQL commands using the ExecuteNonQuery method in PgSqlCommand.
|
||||
DELETE SQL commands using the ExecuteNonQuery method in PgSqlCommand.</li>
|
||||
|
||||
<li>We can execute multiple queries and do a NextResult() in PgSqlDataReader()
|
||||
to get the next result set.
|
||||
to get the next result set.</li>
|
||||
|
||||
<li>We are also able to do simple aggregate functions,
|
||||
ie, count(), sum(), min(), and max()
|
||||
in a simple SELECT SQL query using the ExecuteScalar() now.
|
||||
in a simple SELECT SQL query using the ExecuteScalar() now.</li>
|
||||
|
||||
<li>We are also able to retrieve data with a simple SELECT SQL query
|
||||
using ExecuteReader() which returns a PgSqlDataReader. We are able to
|
||||
use GetSchemaTable() to get the meta data about the table columns.
|
||||
We are able to Read() to get each row from the result set.
|
||||
We are able to Read() to get each row from the result set.</li>
|
||||
|
||||
<li>We are able to get
|
||||
String data (char, character, text, varchar), Int16 (smallint),
|
||||
Int32 (integer), Int64 (bigint), DateTime (time, date, timestamp),
|
||||
Boolean (boolean), Single (float), and Double (double).
|
||||
More data types will come later. Note, the types that do work still
|
||||
need thorough testing.
|
||||
need thorough testing.</li>
|
||||
|
||||
<li>Rows that are returned which contain columns that are NULL are handled now.
|
||||
The PgSqlDataReader method IsDBNull() needs to be called to determine
|
||||
if a field IS NULL before trying to read data from that field.
|
||||
if a field IS NULL before trying to read data from that field.</li>
|
||||
|
||||
<li>Calling PostgreSQL stored procedures works. It does not work perfectly.
|
||||
It may not
|
||||
even work to specification - yet. If you want to test it yourself, look at
|
||||
TestSqlDataReader.cs or PostgresTest.cs in
|
||||
mcs/class/System.Data/Test.
|
||||
mcs/class/System.Data/Test.</li>
|
||||
|
||||
<li>Below, I have some sample code you can
|
||||
use to call a PostgreSQL stored procedure named "version". This stored
|
||||
procedure returns a string containing the PostgreSQL server version. Notice
|
||||
the CommandType is StoredProcedure and the method ExecuteScalar() is called.
|
||||
the CommandType is StoredProcedure and the method ExecuteScalar() is called.</li>
|
||||
|
||||
<li>ExecuteScalar() is a lightweight method in class PgSqlCommand that only returns
|
||||
one row and one column as one object - even if there is more than row or column.
|
||||
one row and one column as one object - even if there is more than row or column.</li>
|
||||
|
||||
<li>We have the beginnings of Parameters support PostgreSQL. Only
|
||||
Input Parameters are currently supported. Output, Input/Output,
|
||||
and Return parameters still need to be done.
|
||||
|
||||
<li>A lot of functionality in System.Data is missing, but the
|
||||
infrastructure is starting to come together.
|
||||
and Return parameters still need to be done.</li>
|
||||
|
||||
<li>A lot of Exceptions need to be thrown for various exceptions. However,
|
||||
PgSqlException, PgSqlErrorCollection, and PgSqlError have been partially
|
||||
implemented.
|
||||
implemented.</li>
|
||||
|
||||
<li>Tim Coleman and Rodrigo Moya got the beginnings of the
|
||||
PgSqlDataAdapter/DataSet/DataTable/DataRow to work. Currently,
|
||||
the PgSqlDataAdapter can Fill() relational data into a DataTable in a DataSet.
|
||||
See the test mcs/class/System.Data/Test/TestSqlDataAdapter.cs to see it in action.
|
||||
See the test mcs/class/System.Data/Test/TestSqlDataAdapter.cs to see it in action.</li>
|
||||
|
||||
<li>Works in the SQL# command-line version
|
||||
and the GTK# version on Linux. It only works in SQL# command-line version
|
||||
on Windows.</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Testing the PostgreSQL Provider
|
||||
** Action Plan
|
||||
<ul>
|
||||
<li>More testing and fixing bugs</li>
|
||||
|
||||
<li>Better error handling</li>
|
||||
|
||||
<li>More Data Types to use</li>
|
||||
|
||||
<li>Any features for Npgsql should be implemented in Npgsql's main cvs repository at
|
||||
gborg.postgresql.org. Most bugs should be fixed in gborg.postgresql.org's cvs.
|
||||
Only bugs neccessary for building and running of Npgsql on Mono can be done in Mono cvs,
|
||||
but once applied they should be sent to Npgsql's mailing list
|
||||
at gborg.postgresql.org for inclusion into cvs there. Whenever there is
|
||||
a release of Npgsql (determined by Francisco Figueiredo jr. or a release
|
||||
of Mono (determined by Miguel de Icaza), then the Npgsql source
|
||||
in gborg.postgresql.org's cvs will be used to update the Npgsql source in
|
||||
Mono's cvs.
|
||||
</li>
|
||||
|
||||
<li>Mono.Data.PostgreSqlClient even though deprecated can still
|
||||
accept bug fixes. This is because other areas, such as, ASP.NET examples
|
||||
may still use this provider.</li>
|
||||
|
||||
<li>Add any missing functionality to Npgsql. If this funtionality works on
|
||||
.NET but not on Mono, implement the missing features or fix the bugs in Mono</li>
|
||||
|
||||
<li>Npgsql has replaced Mono.Data.PostgreSqlClient as the provider of
|
||||
choice to use. However, Mono.Data.PostgreSqlClient will remain in a
|
||||
deprecated state until nobody uses it anymore - then it can be removed</li>
|
||||
|
||||
<li>Implement more of PostgreSQL 7.3 features in Npgsql</li>
|
||||
</ul>
|
||||
|
||||
** Testing Mono.Data.PostgreSqlClient
|
||||
|
||||
<ul>
|
||||
* <p>In order to test Mono.Data.PostgreSqlClient, you will need to have
|
||||
access to a remote PostgreSQL DBMS, or you will have to install
|
||||
one locally. PostgreSQL was first ADO.NET provider created in Mono.
|
||||
one locally. PostgreSQL was the first ADO.NET provider created in Mono.
|
||||
|
||||
<p>Why use PostgreSQL? Because it is free software, has a client
|
||||
library that is easy to use, PostgreSQL is easy to install on
|
||||
@@ -94,7 +200,9 @@
|
||||
user "postgres".
|
||||
|
||||
<pre>
|
||||
"host=localhost;dbname=test;user=postgres"
|
||||
"Server=localhost;Database=test;User ID=postgres;Password=fun2db"
|
||||
(or)
|
||||
"host=localhost;dbname=test;user=postgres;password=fun2db"
|
||||
</pre>
|
||||
</ul>
|
||||
|
||||
@@ -179,9 +287,15 @@ create user postgres with password 'fun2db';
|
||||
* <p>Important notes from this file are:
|
||||
|
||||
<ul>
|
||||
<p><b>2.</b> - Install the latest <a href="http://www.neuro.gatech.edu/users/cwilson/cygutils/OBSOLETE/V1.1/cygipc/index.html">CygIPC</a> package.
|
||||
<p><b>2.</b> - Install the latest <a href="http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html">CygIPC</a> package.
|
||||
Cygwin includes a utility bunzip2 which can be used to unzip it. Now, change to
|
||||
the root directory by
|
||||
typing "cd /" then
|
||||
you can use "tar xvf cygipc.xxx.tar" to untar it
|
||||
in the root directory in cygwin.
|
||||
|
||||
<p>The cygipc package contains the ipc-daemon you will need
|
||||
<p>The cygipc package contains the support to run ipc-daemon
|
||||
that you will need
|
||||
to run before you can
|
||||
run the PostgreSQL DBMS Server daemon (postmaster) or run
|
||||
initdb which initializes the PostgreSQL database.
|
||||
@@ -267,34 +381,9 @@ create user postgres with password 'fun2db';
|
||||
</ul>
|
||||
|
||||
<p>In the path mcs/class/System.Data/Test
|
||||
there is a PostgreSQL test program named
|
||||
there is a test for Mono.Data.PostgreSqlClient named
|
||||
PostgreTest.cs. Thanks goes to Gonzalo for creating the original
|
||||
PostgreSQL test.
|
||||
|
||||
<p>To use it to test System.Data, you
|
||||
modify the file to your PostgreSQL database
|
||||
connection requirements:
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li><b>dbname</b> database, ie., test</li>
|
||||
<li><b>host</b> hostname of the PostgreSQL DBMS Server, ie., localhost</li>
|
||||
<li><b>user</b> username, ie., someuser</li>
|
||||
<li><b>password</b> password, ie., mypass1234</li>
|
||||
</ul>
|
||||
|
||||
<p>The connection string is in OLE-DB connection string format. Internally,
|
||||
SqlConnection converts this to the PostgreSQL connection string format.
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
OLE-DB: "host=localhost;dbname=test;user=joe;password=smoe"
|
||||
PostgreSQL: "host=localhost dbname=test user=joe password=smoe"
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Note that OLE-DB includes the semicolons while PostgreSQL's connection
|
||||
string does not.
|
||||
|
||||
<p>
|
||||
To compile the PostgresTest.cs program, do:
|
||||
@@ -310,7 +399,7 @@ PostgreSQL: "host=localhost dbname=test user=joe password=smoe"
|
||||
to PgSqlConnection, then you need to run mcs like:
|
||||
|
||||
<pre>
|
||||
mono f:/cygwin/home/DanielMorgan/mono/install/bin/mcs.exe \
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
PostgresTest.cs \
|
||||
-r System.Data.dll \
|
||||
-r Mono.Data.PostgreSqlClient.dll
|
||||
@@ -328,185 +417,162 @@ mint PostgresTest.exe
|
||||
To run using mono, do:
|
||||
<pre>
|
||||
mono PostgresTest.exe
|
||||
</pre>
|
||||
|
||||
<p>C# Example for Mono.Data.PostgreSqlClient:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.PostgreSqlClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=test;" +
|
||||
"User ID=postgres;" +
|
||||
"Password=fun2db;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new PgConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname" +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["firstname"];
|
||||
string LastName = reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Below, I show how the output from PostgresTest. I have omitted a lot
|
||||
of the meta data for the columns except two columns. The classes
|
||||
used were from Mono.Data.PostgreSqlClient and were used to connect to a
|
||||
PostgreSQL database and retrieve data.
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
|
||||
danmorg@DANPC ~/mono/mcs/class/System.Data/Test
|
||||
$ mcs PostgresTest.cs -r System.Data.dll
|
||||
|
||||
danmorg@DANPC ~/mono/mcs/class/System.Data/Test
|
||||
$ mono PostgresTest.exe
|
||||
Postgres provider specific tests...
|
||||
|
||||
Drop table:
|
||||
Error (don't worry about this one)SqlError:PGRES_FATAL_ERROR ERROR:
|
||||
table "mono_postgres_test" does not exist
|
||||
<Stack Trace>
|
||||
|
||||
Create table with all supported types:
|
||||
OK
|
||||
Insert values for all known types:
|
||||
OK
|
||||
Update values:
|
||||
OK
|
||||
Insert values for all known types:
|
||||
OK
|
||||
Aggregate: count(*)
|
||||
Agg Result: 2
|
||||
Aggregate: min(text_value)
|
||||
Agg Result: This is a text
|
||||
Aggregate: max(int4_value)
|
||||
Agg Result: 1048000
|
||||
Aggregate: sum(int4_value)
|
||||
Agg Result: 1048003
|
||||
Select values from the database:
|
||||
Result is from a SELECT SQL Query. Records Affected: -1
|
||||
Result Set 1...
|
||||
Total Columns: 28
|
||||
ColumnName = boolean_value
|
||||
ColumnOrdinal = 1
|
||||
ColumnSize = 1
|
||||
NumericPrecision = 0
|
||||
NumericScale = 0
|
||||
IsUnique = False
|
||||
IsKey =
|
||||
BaseCatalogName =
|
||||
BaseColumnName = boolean_value
|
||||
BaseSchemaName =
|
||||
BaseTableName =
|
||||
DataType = System.Boolean
|
||||
AllowDBNull = False
|
||||
ProviderType = 16
|
||||
IsAliased = False
|
||||
IsExpression = False
|
||||
IsIdentity = False
|
||||
IsAutoIncrement = False
|
||||
IsRowVersion = False
|
||||
IsHidden = False
|
||||
IsLong = False
|
||||
IsReadOnly = False
|
||||
|
||||
...
|
||||
|
||||
ColumnName = null_timestamp_value
|
||||
ColumnOrdinal = 28
|
||||
ColumnSize = 8
|
||||
NumericPrecision = 0
|
||||
NumericScale = 0
|
||||
IsUnique = False
|
||||
IsKey =
|
||||
BaseCatalogName =
|
||||
BaseColumnName = null_timestamp_value
|
||||
BaseSchemaName =
|
||||
BaseTableName =
|
||||
DataType = System.DateTime
|
||||
AllowDBNull = False
|
||||
ProviderType = 1184
|
||||
IsAliased = False
|
||||
IsExpression = False
|
||||
IsIdentity = False
|
||||
IsAutoIncrement = False
|
||||
IsRowVersion = False
|
||||
IsHidden = False
|
||||
IsLong = False
|
||||
IsReadOnly = False
|
||||
|
||||
Gonna do a Read() now...
|
||||
Row 0:
|
||||
Col 0: boolean_value: False
|
||||
Col 1: int2_value: 5
|
||||
Col 2: int4_value: 3
|
||||
Col 3: bigint_value: 9
|
||||
Col 4: float_value: 3.141590
|
||||
Col 5: double_value: 3.14159
|
||||
Col 6: numeric_value: 123456789012.345
|
||||
Col 7: char_value: Mono.Data!
|
||||
Col 8: varchar_value: It was not me!
|
||||
Col 9: text_value: We got data!
|
||||
Col 10: point_value: (1,0)
|
||||
Col 11: time_value: 01/01/1 21:13:14
|
||||
Col 12: date_value: 02/29/2000 00:00:00
|
||||
Col 13: timestamp_value: 02/29/2004 14:00:11
|
||||
Col 14: null_boolean_value is NULL
|
||||
Col 15: null_int2_value is NULL
|
||||
Col 16: null_int4_value is NULL
|
||||
Col 17: null_bigint_value is NULL
|
||||
Col 18: null_float_value is NULL
|
||||
Col 19: null_double_value is NULL
|
||||
Col 20: null_numeric_value is NULL
|
||||
Col 21: null_char_value is NULL
|
||||
Col 22: null_varchar_value is NULL
|
||||
Col 23: null_text_value is NULL
|
||||
Col 24: null_point_value is NULL
|
||||
Col 25: null_time_value is NULL
|
||||
Col 26: null_date_value is NULL
|
||||
Col 27: null_timestamp_value is NULL
|
||||
Row 1:
|
||||
Col 0: boolean_value: True
|
||||
Col 1: int2_value: -22
|
||||
Col 2: int4_value: 1048000
|
||||
Col 3: bigint_value: 123456789012345
|
||||
Col 4: float_value: 3.141590
|
||||
Col 5: double_value: 3.14159
|
||||
Col 6: numeric_value: 123456789012.345
|
||||
Col 7: char_value: This is a char
|
||||
Col 8: varchar_value: This is a varchar
|
||||
Col 9: text_value: This is a text
|
||||
Col 10: point_value: (1,0)
|
||||
Col 11: time_value: 01/01/1 21:13:14
|
||||
Col 12: date_value: 02/29/2000 00:00:00
|
||||
Col 13: timestamp_value: 02/29/2004 14:00:11
|
||||
Col 14: null_boolean_value is NULL
|
||||
Col 15: null_int2_value is NULL
|
||||
Col 16: null_int4_value is NULL
|
||||
Col 17: null_bigint_value is NULL
|
||||
Col 18: null_float_value is NULL
|
||||
Col 19: null_double_value is NULL
|
||||
Col 20: null_numeric_value is NULL
|
||||
Col 21: null_char_value is NULL
|
||||
Col 22: null_varchar_value is NULL
|
||||
Col 23: null_text_value is NULL
|
||||
Col 24: null_point_value is NULL
|
||||
Col 25: null_time_value is NULL
|
||||
Col 26: null_date_value is NULL
|
||||
Col 27: null_timestamp_value is NULL
|
||||
Total Rows Retrieved: 2
|
||||
Total Result sets: 1
|
||||
Call ExecuteReader with a SQL Command.
|
||||
(Not INSERT,UPDATE,DELETE
|
||||
).
|
||||
Result is from a SQL Command not (INSERT,UPDATE,DELETE).
|
||||
Records Affected: -1
|
||||
Total Result sets: 0
|
||||
Call ExecuteReader with a SQL Command.
|
||||
(Is INSERT,UPDATE,DELETE)
|
||||
.
|
||||
Result is from a SQL Command (INSERT,UPDATE,DELETE). Records Affected: 1
|
||||
Total Result sets: 0
|
||||
Calling stored procedure version()
|
||||
Result: PostgreSQL 7.2.1 on i686-pc-cygwin, compiled by GCC 2.95.3-5
|
||||
Database Server Version: PostgreSQL 7.2.1 on i686-pc-cygwin,
|
||||
compiled by GCC 2.9
|
||||
5.3-5
|
||||
Clean up...
|
||||
Drop table...
|
||||
OK
|
||||
RESULT: 0
|
||||
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Mono.Data.PostgreSqlClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Mono.Data.PostgreSqlClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Testing Npgsql
|
||||
|
||||
<p>Eventually replace the PostgreSQL data provider in Mono
|
||||
with <a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a>.
|
||||
Npgsql is a .Net Data Provider for PostgreSQL which implements
|
||||
the <a href="http://developer.postgresql.org/docs/postgres/protocol.html">PostgreSQL Frontend/Backend Protocol</a>.
|
||||
Npgsql is implemented in 100% C#. This provider was created by Francisco Figueiredo jr.
|
||||
and has many programmers developing the provider.
|
||||
<ul>
|
||||
<li>Have a working mono and mcs</li>
|
||||
|
||||
<li>Get <a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a>
|
||||
and make sure the binary assembly Npgsql.dll is installed in the same place that the
|
||||
mono class libraries are located.
|
||||
|
||||
<li>Read the Testing notes for Mono.Data.PostgreSqlClient too
|
||||
|
||||
<li>C# Example for Npgsql:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Npgsql;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=test;" +
|
||||
"User ID=postgres;" +
|
||||
"Password=fun2db;";
|
||||
IDbConnection dbcon;
|
||||
dbcon.Open();
|
||||
dbcon = new NpgsqlConnection(connectionString);
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["firstname"];
|
||||
string LastName = reader["lastname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Npgsql.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Npgsql.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Executable
+156
@@ -0,0 +1,156 @@
|
||||
* Provider Factory
|
||||
|
||||
<p>Brian Ritchie contributed a Provider Factory and Data Tools for Mono ADO.NET<br>
|
||||
which gives us a foundation for abstract data provider access within Mono
|
||||
|
||||
** Here are the deails:
|
||||
|
||||
<ul>
|
||||
<li>The Provider information is seperate from the connection string information.<br>
|
||||
This allows the list of providers to be stored in the machine.config file.</li>
|
||||
<li>Provider and ProviderCollection objects are available to access <br>
|
||||
the list of providers and modify them at runtime.</li>
|
||||
<li>The ProviderFactory object is used to create new connections, commands,<br>
|
||||
dataadapters, parameters, etc.</li>
|
||||
</ul>
|
||||
|
||||
** Overview of the ProviderFactory object model:
|
||||
|
||||
<ul>
|
||||
<li><b>ProviderFactory</b>: used to create new Connections, Commands,<br>
|
||||
DataAdapters, or Commands. All objects are returned using <br>
|
||||
the provider interfaces such as IDbConnection, IDbCommand,<br>
|
||||
IDbDataAdapter, or IDataParamter</li>
|
||||
|
||||
<li><b>DataTools</b>: static methods for doing <br>
|
||||
common tasks like filling a DataSet <br>
|
||||
with the contents of a select statement.</li>
|
||||
|
||||
<li><b>ProviderCollection</b>: list of providers configured <br>
|
||||
in the system. Initially loaded from app.config, but can <br>
|
||||
be modified at run-time.</li>
|
||||
|
||||
<li><b>Provider</b>: represents a given provider (factory) <br>
|
||||
and holds information needed to <br>
|
||||
create the types.</li>
|
||||
|
||||
<li><b>ProviderSectionHandler</b>: works behind the <br>
|
||||
scenes to load the list of <br>
|
||||
providers from the app.config into a ProviderCollection.</li>
|
||||
</ul>
|
||||
|
||||
** C# source code samples for creating a connection:
|
||||
|
||||
<pre>
|
||||
// Create connection using enhanced connection string
|
||||
// The factory attribute specifies which provider
|
||||
// to use. The factory attribute is parsed out, the
|
||||
// object is created, and then the rest of the
|
||||
// connection string is passed into the provider. The
|
||||
// providers are defined in
|
||||
// the app.config (or machine.config).
|
||||
IDbConnection conn;
|
||||
string connectionString =
|
||||
"factory=System.Data.SqlClient;" +
|
||||
"server=speedy;database=pubs;uid=sa";
|
||||
conn = ProviderFactory.CreateConnection(connectionString);
|
||||
|
||||
// Create connection specifying provider
|
||||
// and standard connection string
|
||||
IDbConnection conn;
|
||||
string provider = "System.Data.SqlClient";
|
||||
string connectionString = "server=speedy;database=pubs;uid=sa";
|
||||
conn = ProviderFactory.CreateConnection(provider,connectionString);
|
||||
|
||||
// Create connection using connection string stored
|
||||
// in app.config under <appSettings>
|
||||
IDbConnection conn;
|
||||
string appSetting = "PubsConnStr";
|
||||
conn = ProviderFactory.CreateConnectionFromConfig(appSetting);
|
||||
</pre>
|
||||
|
||||
|
||||
<p>C# Sample for Creating a DataAdapter and filling a DataSet.
|
||||
|
||||
<pre>
|
||||
// Create Connection
|
||||
IDbConnection conn =
|
||||
ProviderFactory.CreateConnectionFromConfig("PubsConnStr");
|
||||
|
||||
// Select command
|
||||
IDbCommand cmd=conn.CreateCommand();
|
||||
cmd.Text="select * from author";
|
||||
|
||||
// Data Adapter
|
||||
DataSet ds=new DataSet();
|
||||
IDbDataAdapter adapter=ProviderFactory.CreateDataAdapter(cmd);
|
||||
adapter.Fill(ds, "Table1");
|
||||
</pre>
|
||||
|
||||
<p>Creating a DataAdapter and filling a DataSet. <br>
|
||||
The super lazy method for people like me.
|
||||
<pre>
|
||||
// Create Connection
|
||||
IDbConnection conn =
|
||||
ProviderFactory.CreateConnectionFromConfig("TdsPubsConnStr");
|
||||
|
||||
// Data Adapter
|
||||
DataSet ds=DataTools.FillDataSet(conn, "select * from author");
|
||||
</pre>
|
||||
|
||||
|
||||
<p>Here's some sample code on displaying a list <br>
|
||||
of configured ADO.NET providers:
|
||||
<pre>
|
||||
Console.WriteLine("Configured Providers:");
|
||||
foreach (Provider p in ProviderFactory.Providers)
|
||||
Console.WriteLine(p.Description);
|
||||
</pre>
|
||||
|
||||
<p>A Super lazy overload to the FillDataSet method (in <br>
|
||||
DataTools.cs) that will fill a dataset in one line of code.
|
||||
|
||||
<pre>
|
||||
DataSet ds=DataTools.FillDataSet("PubsConnStr", "select * from authors");
|
||||
</pre>
|
||||
|
||||
** About Configuration Files
|
||||
|
||||
<p>Information about <a href="http://msdn.microsoft.com/library/en-us/vbcon/html/vboriintroductiontoapplicationsettingstorage.asp?frame=true">app.config</a> files
|
||||
can be found at <a href="http://msdn.microsoft.com/">MSDN</a>.
|
||||
|
||||
<p>See the mcs/class/Mono.Data/app.config for sample configuration file in<br>
|
||||
mcs source. Basically, if your application is named blah.exe, <br>
|
||||
you would create an app.config file named blah.exe.config
|
||||
|
||||
<p>Here's a sample app.config file showing the provider <br>
|
||||
declarations along with sample connection strings:
|
||||
|
||||
<pre>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="mono.data">
|
||||
<section name="providers" type="Mono.Data.ProviderSectionHandler,Mono.Data" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="PubsConnStr" value="factory=System.Data.SqlClient;server=speedy;database=pubs;uid=sa;pwd=" />
|
||||
</appSettings>
|
||||
<mono.data>
|
||||
<providers>
|
||||
<provider name="System.Data.SqlClient" connection="System.Data.SqlClient.SqlConnection" adapter="System.Data.SqlClient.SqlDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
|
||||
<provider name="System.Data.OleDb" connection="System.Data.OleDb.OleDbConnection" adapter="System.Data.OleDb.OleDbDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
|
||||
<provider name="System.Data.Odbc" connection="System.Data.Odbc.OdbcConnection" adapter="System.Data.OleDb.OdbcDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
|
||||
<provider name="Mono.Data.TdsClient" connection="Mono.Data.TdsClient.TdsConnection" adapter="Mono.Data.TdsClient.TdsDataAdapter" assembly="Mono.Data.TdsClient" />
|
||||
<provider name="Mono.Data.MySql" connection="Mono.Data.MySql.MySqlConnection" adapter="Mono.Data.MySql.MySqlDataAdapter" assembly="Mono.Data.MySql" />
|
||||
<provider name="Mono.Data.PostgreSqlClient" connection="Mono.Data.PostgreSqlClient.PgSqlConnection" adapter="Mono.Data.PostgreSqlClient.PgSqlDataAdapter" assembly="Mono.Data.PostgreSqlClient" />
|
||||
<provider name="Mono.Data.SqliteClient" connection="Mono.Data.SqliteClient.SqliteConnection" adapter="Mono.Data.SqliteClient.SqliteDataAdapter" assembly="Mono.Data.SqliteClient" />
|
||||
<provider name="Mono.Data.SybaseClient" connection="Mono.Data.SybaseClient.SybaseConnection" adapter="Mono.Data.SybaseClient.SybaseDataAdapter" assembly="Mono.Data.SybaseClient" />
|
||||
</providers>
|
||||
</mono.data>
|
||||
</configuration>
|
||||
|
||||
</pre>
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
* Screenshots
|
||||
|
||||
** Mono Debugger
|
||||
|
||||
Some shots of the <a href="jit-debug.html">Mono Debugger</a>
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="images/Screenshot-Debugger-1.png"><img src="images/Screenshot-Debugger-1-thumb.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Debugger showing the source code view.
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="images/Screenshot-Debugger-2.png"><img src="images/Screenshot-Debugger-2-thumb.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Debugger showing the CPU view.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** Mono Documentation Browser
|
||||
|
||||
The Mono Documentation Browser is available from <a
|
||||
href="anoncvs.html">CVS</a>, module `monodoc'.
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="images/Screenshot-B2.png"><img src="images/Screenshot-B2-thumb.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Mono Documentation Browser rendering a method description.
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="images/Screenshot-MethodSummary.png"><img src="images/Screenshot-MethodSummary-thumb.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Mono Documentation Browser rendering the class method summary
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** Mono Basic
|
||||
|
||||
The Mono Basic compiler ships with the Mono distribution.
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="images/gtk-vb.png"><img src="images/gtk-vb-thumb.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Mono Basic running a sample Gtk# application.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** Platano Media Player
|
||||
|
||||
Alp's <a href="http://www.atoker.com/platano/">Platano</a>
|
||||
Media Player is written with Gtk# (with GStreamer support):
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="images/platano_s.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Platano startup.
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="images/platano-playing_s.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
Platano playing the <a
|
||||
href="http://developer.ximian.com/projects/third_party/codemonkey/index.html">Code
|
||||
Monkey At Work</a> video.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** GSIRC
|
||||
|
||||
Alp's <a href="http://www.atoker.com/gsirc/">GSIRC</a>
|
||||
Gtk-Sharp IRC written with Gtk#
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://go-mono.com/images/gsirc-0.2a_overview.jpg"><img src="images/gsirc-0.2a_overview-thumb.jpg"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
GSIRC is shown with the preferences dialog and chatting on some channels (rooms).
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** SQL# For GTK#
|
||||
|
||||
Daniel Morgan's SQL query tool that runs on Mono on Linux and Windows. It is
|
||||
written in C# and allows you to connect to various Mono ADO.NET providers and
|
||||
enter SQL commands.
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="http://go-mono.com/images/sqlsharp.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
SQL# For GTK# is shown retrieving data from a Microsoft SQL Server 2000 database.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** SkyNET
|
||||
|
||||
SkyNET is written in C# and uses GTK# for displaying a star chart.
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="http://go-mono.com/images/skynet.png">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
** Windows.Forms
|
||||
|
||||
Windows.Forms running with Wine on Linux:
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://go-mono.com/images/WINESWF.JPG"><img src="http://go-mono.com/images/WINESWF-thumb.JPG"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
+180
-24
@@ -1,58 +1,214 @@
|
||||
* Microsoft SQL Server Provider
|
||||
|
||||
<ul>
|
||||
<li>ADO.NET Provider for Microsoft SQL Server 7/2000 databases
|
||||
<li>ADO.NET Provider for Microsoft SQL Server 7/2000 databases</li>
|
||||
|
||||
<li>Exists in namespace System.Data.SqlClient and assembly System.Data
|
||||
<li>Exists in namespace System.Data.SqlClient and assembly System.Data</li>
|
||||
|
||||
<li>Created by Tim Coleman
|
||||
<li>Created by Tim Coleman</li>
|
||||
|
||||
<li>Used the <a href="http://www.freetds.org/">FreeTDS</a> and
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.</li>
|
||||
|
||||
<li>Implemented in 100% C#
|
||||
<li>Implemented in 100% C#</li>
|
||||
|
||||
<li>Is similar to the Mono.Data.TdsClient and Mono.Data.SybaseClient providers.</li>
|
||||
|
||||
<li>Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.</li>
|
||||
|
||||
<li>Uses TDS Protocol Version 7.0</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
<li>Is similar to the Mono.Data.TdsClient and Mono.Data.SybaseClient providers.
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
|
||||
|
||||
** Current Status
|
||||
|
||||
|
||||
<ul>
|
||||
<li>Able to connect to Microsoft SQL Server 7/2000 databases
|
||||
<li>Able to connect to Microsoft SQL Server 7/2000 databases</li>
|
||||
|
||||
<li>Connection pooling works.
|
||||
<li>Connection pooling works.</li>
|
||||
|
||||
<li>Stored Procedures work
|
||||
<li>Stored Procedures work</li>
|
||||
|
||||
<li>Parameters work.
|
||||
<li>Parameters work.</li>
|
||||
|
||||
<li>Prepare works.
|
||||
<li>Prepare works.</li>
|
||||
|
||||
<li>SQL commands can be executed
|
||||
via ExecuteNonQuery() of a SqlCommand.
|
||||
via ExecuteNonQuery() of a SqlCommand.</li>
|
||||
|
||||
<li>SQL aggregates can be executed and a single row and single column
|
||||
result can be retrieved via ExecuteScalar() of a SqlCommand
|
||||
result can be retrieved via ExecuteScalar() of a SqlCommand</li>
|
||||
|
||||
<li>SQL queries can be executed via ExecuteReader() and results
|
||||
can be retrieved via SqlDataReader.
|
||||
can be retrieved via SqlDataReader.</li>
|
||||
|
||||
<li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
|
||||
in a SqlDataReader
|
||||
in a SqlDataReader</li>
|
||||
|
||||
<li>XML can be read via ExecuteXmlReader in a SqlCommand.
|
||||
<li>XML can be read via ExecuteXmlReader in a SqlCommand.</li>
|
||||
|
||||
<li>Data can be filled in a DataTable in a DataSet via a SqlDataAdapter
|
||||
<li>Data can be filled in a DataTable in a DataSet via a SqlDataAdapter</li>
|
||||
|
||||
<li>Uses TDS Protocol Version 7.0
|
||||
<li>Uses TDS Protocol Version 7.0</li>
|
||||
|
||||
<li><a href="http://www.go-mono.com/tds-providers.html">Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono</a>
|
||||
<li><a href="http://www.go-mono.com/tds-providers.html">Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono</a></li>
|
||||
|
||||
<li>Works in the SQL# command-line and GTK# GUI version</li>
|
||||
</ul>
|
||||
|
||||
* Action plan
|
||||
** Action plan
|
||||
|
||||
<ul>
|
||||
<li>Connection timeouts is being developed now.
|
||||
<li>Connection timeouts is being developed now</li>
|
||||
|
||||
<li>Needs more testing</li>
|
||||
|
||||
<li>Would like to figure out how to connect via Trusted_Connection or Integrated Security</li>
|
||||
|
||||
<li>Start work on TDS Protocol Version 8.0 support</li>
|
||||
|
||||
<li>TODO
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
<li>Have a working mono and mcs installed</li>
|
||||
|
||||
<li>Have access to a Microsoft SQL Server database
|
||||
or either download it:
|
||||
<ul>
|
||||
<li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>If using Microsoft SQL Server 2000, make sure
|
||||
you are using at least Service Pack 3 for Microsoft SQL Server 2000. If using
|
||||
MSDE 2000, make sure you have the special Service Pack 3 for MSDE 2000.</li>
|
||||
|
||||
<li>For those that only have MSDE installed. You can change the authentication mode
|
||||
from Windows Only Authentication to SQL Server and Windows Authentications (also knows as Mixed-mode authentication)
|
||||
via the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q322336&sd=tech#4">registry</a></li>. It is
|
||||
the LoginMode you need to change. By default,
|
||||
MSDE is installed with Windows Only Authentication. For SqlClient to work with MSDE, you will
|
||||
need to change the setting.</a>
|
||||
|
||||
<li>If using MSDE, you might need to create a new user with password. Give
|
||||
this user access to various databases in this MSDE instance. Also, for each
|
||||
database, give this new user at least SELECT access to the various tables you want
|
||||
to retrieve data from.</li>
|
||||
|
||||
<li>If you have Enterprise Manager, you can easily change the authentication mode
|
||||
for both MSDE and Microsoft SQL Server. To change the authentication mode in
|
||||
Enterprise Mananger, select the instance, right-click on it, and select properites.
|
||||
The SQL Server properties dialog for that instance will pop up. Choose the Security
|
||||
tab. Change the authentication from Windows Only to SQL Server and Windows. If
|
||||
the instance of your database does not show up in Enterprise Manager, Register first
|
||||
by selecting the Action menu and choosing New SQL Server Registration.</li>
|
||||
|
||||
<li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
|
||||
named SqlTest.cs and you could use this as a basis for your test.</li>
|
||||
|
||||
<li>Mono's SqlClient does not support trusted connections
|
||||
nor integrated security. You can not use this when connecting. You need
|
||||
to explicitly use a User ID and Password
|
||||
authenticated by SQL Server.</li>
|
||||
|
||||
<li>Has a connection string format:
|
||||
<pre>
|
||||
Server=hostname;Database=databaseName;User ID=userid;Password=password
|
||||
</pre>
|
||||
</li>
|
||||
<li>The Server part can be used three ways:
|
||||
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td><b>Server Definition</b></td> <td><b>Example</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>hostname</td> <td>Server=MYHOST</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>hostname,port</td> <td>Server=MYHOST,1433</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>hostname\\instance</td> <td>Server=MYHOST\\NETSDK</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=pubs;" +
|
||||
"User ID=myuserid;" +
|
||||
"Password=mypassword;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new SqlConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
string sql =
|
||||
"SELECT fname, lname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["fname"];
|
||||
string LastName = reader["lname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs -r System.Data.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+127
-12
@@ -1,28 +1,143 @@
|
||||
* SQL Lite Data Provider
|
||||
|
||||
<ul>
|
||||
<li>Exists in namespace and assembly Mono.Data.SqliteClient
|
||||
|
||||
<li>Created by Vladimir Vukicevic
|
||||
|
||||
<li><a href"http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a>
|
||||
<li>ADO.NET Data Provider for
|
||||
the <a href"http://www.hwaci.com/sw/sqlite/">SQL Lite</a> which
|
||||
is an embeddable SQL database engine</li>
|
||||
|
||||
<li>From the SQL Lite web page: SQLite is a C library that
|
||||
implements an embeddable SQL database engine. Programs that link with
|
||||
the SQLite library can have SQL database access without
|
||||
running a separate RDBMS process. The distribution
|
||||
comes with a standalone command-line access program (sqlite) that
|
||||
can be used to administer an SQLite database and which serves
|
||||
as an example of how to use the SQLite library. SQLite is not a client library
|
||||
used to connect to a big database server. SQLite is the server. The SQLite
|
||||
library reads and writes directly to and from the database files on disk.</li>
|
||||
|
||||
<li>SQL Lite can be downloaded
|
||||
from <a href"http://www.hwaci.com/sw/sqlite/download.html">here</a>.
|
||||
binaries exist for Linux and Windows. sqlite.dll on Windows
|
||||
and sqlite.so on Linux.
|
||||
and sqlite.so on Linux. The source code is available too.</li>
|
||||
|
||||
<li>Exists in namespace and assembly Mono.Data.SqliteClient</li>
|
||||
|
||||
<li>Created by Vladimir Vukicevic so he could have a database of
|
||||
thumbnail images for mPhoto. mPhoto is GUI application
|
||||
for cataloging images. mPhoto runs on Mono
|
||||
and uses <a href="http:www.go-mono.com/gtk-sharp.html">GTK#</a> for its GUI.</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Able to connect, execute commands, and retrieve data...
|
||||
<li>Able to connect, execute commands, and retrieve data...</li>
|
||||
|
||||
<li>Works in mPhoto
|
||||
<li>Works in mPhoto by providing access to a SQL Lite database to store images.</li>
|
||||
</ul>
|
||||
|
||||
* Action Plan
|
||||
** Action Plan
|
||||
|
||||
<ul>
|
||||
<li>Create a DataAdapter for SQL Lite named SqliteDataAdapter that can be used to
|
||||
Fill a DataTable in a DataSet
|
||||
Fill a DataTable in a DataSet</li>
|
||||
|
||||
<li>TODO
|
||||
<li>Get the method GetSchemaTable() in class SqliteDataReader to return a DataTable
|
||||
that works</li>
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
<li>Have a working mcs and mono</li>
|
||||
|
||||
<li>Make sure Mono.Data.SqliteClient.dll was built and is installed
|
||||
in the same place as the mono class libraries.</li>
|
||||
|
||||
<li>If you do not have <a href"http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a>,
|
||||
download it. There are binaries for Windows and Linux.</li>
|
||||
|
||||
<li>There is a test named SqliteTest.cs found at mcs/class/Mono.Data.SqliteTest/Test</li>
|
||||
|
||||
<li>Has a connection string format of "URI=file:some/path". For example,
|
||||
the connection string "URI=file:SqliteTest.db" will use the database file
|
||||
named SqliteTest.db, if it does not exist, the file will be created.</li>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.SqliteClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString = "URI=file:SqliteTest.db";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new MySQLConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader[0];
|
||||
string LastName = reader[1];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Mono.Data.SqliteClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll \
|
||||
-r Mono.Data.SqliteClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+124
-17
@@ -1,48 +1,155 @@
|
||||
* Sybase Data Provider
|
||||
|
||||
<ul>
|
||||
<li>ADO.NET Provider for Sybase SQL Server databases
|
||||
<li>ADO.NET Provider for Sybase SQL Server databases</li>
|
||||
|
||||
<li>Exists in namespace Mono.Data.SybaseClient and assembly Mono.Data.SybaseClient
|
||||
<li>Exists in namespace Mono.Data.SybaseClient and assembly Mono.Data.SybaseClient</li>
|
||||
|
||||
<li>Created by Tim Coleman
|
||||
<li>Created by Tim Coleman</li>
|
||||
|
||||
<li>Used the <a href="http://www.freetds.org/">FreeTDS</a> and
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.</li>
|
||||
|
||||
<li>Implemented in 100% C#
|
||||
<li>Implemented in 100% C#</li>
|
||||
|
||||
<li>Is similar to the Mono.Data.TdsClient and System.Data.SqlClient providers.
|
||||
<li>Is similar to the Mono.Data.TdsClient and System.Data.SqlClient providers.</li>
|
||||
|
||||
<li>Uses TDS Protocol Version 5.0
|
||||
<li>Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.</li>
|
||||
|
||||
<li><a href="http://www.go-mono.com/tds-providers.html">Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono</a>
|
||||
<li>Uses TDS Protocol Version 5.0</li>
|
||||
|
||||
<li>Does not support trusted connections</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
<ul>
|
||||
<li>Able to connect to Sybase databases
|
||||
<li>Able to connect to Sybase databases</li>
|
||||
|
||||
<li>SQL commands can be executed
|
||||
via ExecuteNonQuery() of a SybaseCommand.
|
||||
via ExecuteNonQuery() of a SybaseCommand.</li>
|
||||
|
||||
<li>SQL aggregates can be executed and a single row and single column
|
||||
result can be retrieved via ExecuteScalar() of a SybaseCommand
|
||||
result can be retrieved via ExecuteScalar() of a SybaseCommand</li>
|
||||
|
||||
<li>SQL queries can be executed via ExecuteReader() and results
|
||||
can be retrieved via SybaseDataReader.
|
||||
can be retrieved via SybaseDataReader.</li>
|
||||
|
||||
<li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
|
||||
in a SybaseDataReader
|
||||
in a SybaseDataReader</li>
|
||||
|
||||
<li>Data can be filled in a DataTable in a DataSet via a SybaseDataAdapter
|
||||
<li>Data can be filled in a DataTable in a DataSet via a SybaseDataAdapter</li>
|
||||
</ul>
|
||||
|
||||
* Action plan
|
||||
** Action plan
|
||||
|
||||
<ul>
|
||||
<li>Connection timeouts is being developed now.
|
||||
|
||||
<li>Needs more testing...
|
||||
|
||||
<li>TODO
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
<li>Have a working mono and mcs installed</li>
|
||||
|
||||
<li>Have access to a Sybase database
|
||||
or either download it:
|
||||
<ul>
|
||||
<li><a href="http://www.sybase.com/downloads">Sybase</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
|
||||
named SqlTest.cs and you could use this as a basis for your test.</li>
|
||||
|
||||
<li>Has a connection string format:
|
||||
<pre>
|
||||
Server=hostname;Database=databaseName;User ID=userid;Password=password
|
||||
</pre>
|
||||
</li>
|
||||
<li>The Server part can be used two ways:
|
||||
<ul>
|
||||
<li>hostname - "Server=MYHOST"</li>
|
||||
<li>hostname,port - "Server=MYHOST,1533"</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.SybaseClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=pubs;" +
|
||||
"User ID=myuserid;" +
|
||||
"Password=mypassword;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new SybaseConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
string sql =
|
||||
"SELECT fname, lname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["fname"];
|
||||
string LastName = reader["lname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Mono.Data.SybaseClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Mono.Data.SybaseClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
+127
-19
@@ -1,51 +1,159 @@
|
||||
* TDS Generic Provider
|
||||
|
||||
<ul>
|
||||
<li>ADO.NET Provider for older Sybase and Microsoft SQL Server databases
|
||||
<li>ADO.NET Provider for older Sybase and Microsoft SQL Server databases</li>
|
||||
|
||||
<li>Exists in namespace Mono.Data.TdsClient and assembly Mono.Data.TdsClient
|
||||
<li>Exists in namespace Mono.Data.TdsClient and assembly Mono.Data.TdsClient</li>
|
||||
|
||||
<li>Created by Tim Coleman
|
||||
<li>Created by Tim Coleman</li>
|
||||
|
||||
<li>Used the <a href="http://www.freetds.org/">FreeTDS</a> and
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.
|
||||
<a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.</li>
|
||||
|
||||
<li>Implemented in 100% C#
|
||||
<li>Implemented in 100% C#</li>
|
||||
|
||||
<li>Is similar to the Mono.Data.SybaseClient and System.Data.SqlClient providers.
|
||||
<li>Is similar to the Mono.Data.SybaseClient and System.Data.SqlClient providers.</li>
|
||||
|
||||
<li>Uses TDS Protocol Version 4.2 by default
|
||||
<li>Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.</li>
|
||||
|
||||
<li><a href="http://www.go-mono.com/tds-providers.html">Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono</a>
|
||||
<li>Uses TDS Protocol Version 4.2 by default</li>
|
||||
|
||||
<li>Does not support trusted connections</li>
|
||||
|
||||
<li>Bugs with Mono or the data provider should be reported
|
||||
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
|
||||
do not have Bugzilla user account, it is free
|
||||
and easy to
|
||||
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
* Current Status
|
||||
** Current Status
|
||||
|
||||
|
||||
<ul>
|
||||
<li>Only builds on Windows currently due to mcs does not support modules and mcs
|
||||
has problems with code that is internal.
|
||||
has problems with code that is internal.</li>
|
||||
|
||||
<li>Able to connect to Microsoft SQL Server and Sybase databases
|
||||
<li>Able to connect to Microsoft SQL Server and Sybase databases</li>
|
||||
|
||||
<li>SQL commands can be executed
|
||||
via ExecuteNonQuery() of a TdsCommand.
|
||||
via ExecuteNonQuery() of a TdsCommand.</li>
|
||||
|
||||
<li>SQL aggregates can be executed and a single row and single column
|
||||
result can be retrieved via ExecuteScalar() of a TdsCommand
|
||||
result can be retrieved via ExecuteScalar() of a TdsCommand</li>
|
||||
|
||||
<li>SQL queries can be executed via ExecuteReader() and results
|
||||
can be retrieved via TdsDataReader.
|
||||
can be retrieved via TdsDataReader.</li>
|
||||
|
||||
<li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
|
||||
in a TdsDataReader
|
||||
in a TdsDataReader</li>
|
||||
|
||||
<li>Data can be filled in a DataTable in a DataSet via a TdsDataAdapter
|
||||
<li>Data can be filled in a DataTable in a DataSet via a TdsDataAdapter</li>
|
||||
</ul>
|
||||
|
||||
* Action plan
|
||||
** Action plan
|
||||
|
||||
<ul>
|
||||
<li>Connection timeouts is being developed now.
|
||||
<li>Connection timeouts is being developed now.</li>
|
||||
|
||||
<li>TODO
|
||||
<li>TODO</li>
|
||||
</ul>
|
||||
|
||||
** Testing
|
||||
|
||||
<ul>
|
||||
<li>Have a working mono and mcs installed</li>
|
||||
|
||||
<li>Have access to a Sybase or Microsoft SQL Server database
|
||||
or either download it:
|
||||
<ul>
|
||||
<li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a></li>
|
||||
<li><a href="http://www.sybase.com/downloads">Sybase</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>If using Microsoft SQL Server 2000, make sure
|
||||
you are using at least Service Pack 3 for Microsoft SQL Server 2000</li>
|
||||
|
||||
<li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
|
||||
named SqlTest.cs and you could use this as a basis for your test.</li>
|
||||
|
||||
<li>Has a connection string format:
|
||||
<pre>
|
||||
Server=hostname;Database=databaseName;User ID=userid;Password=password
|
||||
</pre>
|
||||
</li>
|
||||
<li>The Server part can be used two ways:
|
||||
<ul>
|
||||
<li>hostname - "Server=MYHOST"</li>
|
||||
<li>hostname,port - "Server=MYHOST,1533"</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>C# Example:
|
||||
<pre>
|
||||
using System;
|
||||
using System.Data;
|
||||
using Mono.Data.TdsClient;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string connectionString =
|
||||
"Server=localhost;" +
|
||||
"Database=pubs;" +
|
||||
"User ID=myuserid;" +
|
||||
"Password=mypassword;";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new TdsConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
string sql =
|
||||
"SELECT fname, lname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
IDataReader reader = dbcmd.ExecuteReader();
|
||||
while(reader.Read()) {
|
||||
string FirstName = reader["fname"];
|
||||
string LastName = reader["lname"];
|
||||
Console.WriteLine("Name: " +
|
||||
FirstName + " " + LastName);
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</li>
|
||||
<li>Building C# Example:
|
||||
<ul>
|
||||
<li>Save the example to a file, such as, TestExample.cs</li>
|
||||
<li>Build on Linux:
|
||||
<pre>
|
||||
mcs TestExample.cs -r System.Data.dll \
|
||||
-r Mono.Data.TdsClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
<li>Build on Windows via Cygwin:
|
||||
<pre>
|
||||
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
|
||||
TestExample.cs \
|
||||
-lib:C:/cygwin/home/MyHome/mono/install/lib \
|
||||
-r System.Data.dll -r Mono.Data.TdsClient.dll
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Running the Example:
|
||||
<pre>
|
||||
mono TestExample.exe
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
+7
-1
@@ -1,5 +1,8 @@
|
||||
0,Home,index.html,index.src
|
||||
1,FAQ,faq.html,faq.src
|
||||
1,News archive,http://monoevo.sf.net/mwn/archives.html
|
||||
1,Screenshots,screenshots.html,screenshots.src
|
||||
1,Other sites,other.html,other.src
|
||||
0,Mono,rationale.html,rationale.src
|
||||
1,Runtime,runtime.html,runtime.src
|
||||
2,Embedding,embedded-api.html,embedded-api.src
|
||||
@@ -33,8 +36,9 @@
|
||||
1,Debugging,jit-debug.html,jit-debug.src
|
||||
0,Plans,plans.html,plans.src
|
||||
1,ADO.NET,ado-net.html,ado-net.src
|
||||
1,Crypto,crypto.html,crypto.src
|
||||
2,ProviderFactory,provider-factory.html,provider-factory.src
|
||||
2,Firebird Interbase,firebird.html,firebird.src
|
||||
2,IBM DB2,ibmdb2.html,ibmdb2.src
|
||||
2,Microsft SQL Server,sqlclient.html,sqlclient.src
|
||||
2,MySQL,mysql.html,mysql.src
|
||||
2,ODBC,odbc.html,odbc.src
|
||||
@@ -44,6 +48,7 @@
|
||||
2,SQL Lite,sqlite.html,sqlite.src
|
||||
2,Sybase,sybase.html,sybase.src
|
||||
2,TDS Generic,tdsclient.html,tdsclient.src
|
||||
1,Crypto,crypto.html,crypto.src
|
||||
1,Java,java.html,java.src
|
||||
1,Windows.Forms,winforms.html,winforms.src
|
||||
0,Class Status,class-status.html,class-status.src,cm/cormissing.css,cm/cormissing.js
|
||||
@@ -59,4 +64,5 @@
|
||||
1,EnterpriseServices,class-status-System.EnterpriseServices.html,class-status-System.EnterpriseServices.src,cm/cormissing.css,cm/cormissing.js
|
||||
1,Formatters.Soap,class-status-System.Runtime.Serialization.Formatters.Soap.html,class-status-System.Runtime.Serialization.Formatters.Soap.src,cm/cormissing.css,cm/cormissing.js
|
||||
1,Cscompmgd,class-status-Cscompmgd.html,class-status-Cscompmgd.src,cm/cormissing.css,cm/cormissing.js
|
||||
1,System.Security,class-status-System.Security.html,class-status-System.Security.src,cm/cormissing.css,cm/cormissing.js
|
||||
0,Contact,contact.html,contact.src
|
||||
@@ -212,7 +212,7 @@ function clickHandler (evt)
|
||||
if (evt.ctrlKey)
|
||||
{
|
||||
var strRoot = 'http://cvs.hispalinux.es/cgi-bin/cvsweb/mcs/class/';
|
||||
var strExtra = '?cvsroot=Mono';
|
||||
var strExtra = '?cvsroot=mono';
|
||||
|
||||
if (strAssembly)
|
||||
{
|
||||
|
||||
+46
-38
@@ -1,11 +1,12 @@
|
||||
CSCRIPT = $(SYSTEMROOT)/system32/cscript.exe
|
||||
ROOT=C:/WINNT
|
||||
CSCRIPT = $(ROOT)/system32/cscript.exe
|
||||
CSC=csc
|
||||
|
||||
CORCOMPARE=../../../mcs/tools/corcompare
|
||||
|
||||
OBJECTS= \
|
||||
deploy/ado-net.html \
|
||||
deploy/firebird.html \
|
||||
deploy/provider-factory.html \
|
||||
deploy/mysql.html \
|
||||
deploy/odbc.html \
|
||||
deploy/oledb.html \
|
||||
@@ -19,6 +20,44 @@ OBJECTS= \
|
||||
deploy/asp-net.html \
|
||||
deploy/books.html \
|
||||
deploy/contributing.html \
|
||||
deploy/contact.html \
|
||||
deploy/c-sharp.html \
|
||||
deploy/ccvs.html \
|
||||
deploy/documentation.html \
|
||||
deploy/download.html \
|
||||
deploy/crypto.html \
|
||||
deploy/embedded-api.html \
|
||||
deploy/faq.html \
|
||||
deploy/firebird.html \
|
||||
deploy/gcc-frontend.html \
|
||||
deploy/gtk-sharp.html \
|
||||
deploy/hackers.html \
|
||||
deploy/ideas.html \
|
||||
deploy/ibmdb2.html \
|
||||
deploy/index.html \
|
||||
deploy/java.html \
|
||||
deploy/jit-debug.html \
|
||||
deploy/languages.html \
|
||||
deploy/mailing-lists.html \
|
||||
deploy/mbas.html \
|
||||
deploy/mono-beginning.html \
|
||||
deploy/mono-contribution-howto.html \
|
||||
deploy/monodoc-xml.html \
|
||||
deploy/other.html \
|
||||
deploy/papers.html \
|
||||
deploy/passport.html \
|
||||
deploy/plans.html \
|
||||
deploy/porting.html \
|
||||
deploy/ppc.html \
|
||||
deploy/rationale.html \
|
||||
deploy/resources.html \
|
||||
deploy/roadmap.html \
|
||||
deploy/runtime.html \
|
||||
deploy/screenshots.html \
|
||||
deploy/status.html \
|
||||
deploy/testing.html \
|
||||
deploy/tools.html \
|
||||
deploy/winforms.html \
|
||||
deploy/class-status.html \
|
||||
deploy/class-status-corlib.html \
|
||||
deploy/class-status-System.html \
|
||||
@@ -30,45 +69,12 @@ OBJECTS= \
|
||||
deploy/class-status-Microsoft.VisualBasic.html \
|
||||
deploy/class-status-System.EnterpriseServices.html \
|
||||
deploy/class-status-System.Runtime.Serialization.Formatters.Soap.html \
|
||||
deploy/class-status-System.Security.html \
|
||||
deploy/class-status-System.Windows.Forms.html \
|
||||
deploy/class-status-Cscompmgd.html \
|
||||
deploy/class-library.html \
|
||||
deploy/classlib-doc.html \
|
||||
deploy/contact.html \
|
||||
deploy/c-sharp.html \
|
||||
deploy/mbas.html \
|
||||
deploy/ccvs.html \
|
||||
deploy/documentation.html \
|
||||
deploy/download.html \
|
||||
deploy/crypto.html \
|
||||
deploy/embedded-api.html \
|
||||
deploy/faq.html \
|
||||
deploy/gcc-frontend.html \
|
||||
deploy/hackers.html \
|
||||
deploy/index.html \
|
||||
deploy/ideas.html \
|
||||
deploy/java.html \
|
||||
deploy/jit-debug.html \
|
||||
deploy/jit-debug-sample.html \
|
||||
deploy/jit-debug-sample2.html \
|
||||
deploy/languages.html \
|
||||
deploy/mailing-lists.html \
|
||||
deploy/mono-beginning.html \
|
||||
deploy/mono-contribution-howto.html \
|
||||
deploy/monodoc-xml.html \
|
||||
deploy/papers.html \
|
||||
deploy/passport.html \
|
||||
deploy/plans.html \
|
||||
deploy/porting.html \
|
||||
deploy/ppc.html \
|
||||
deploy/rationale.html \
|
||||
deploy/resources.html \
|
||||
deploy/roadmap.html \
|
||||
deploy/runtime.html \
|
||||
deploy/status.html \
|
||||
deploy/testing.html \
|
||||
deploy/tools.html \
|
||||
deploy/winforms.html
|
||||
deploy/classlib-doc.html
|
||||
|
||||
#2,Configuration.Install,class-status-System.Configuration.Install.html,class-status-System.Configuration.Install.src,cm/cormissing.css,cm/cormissing.js
|
||||
#2,Runtime.Remoting,class-status-System.Runtime.Remoting.html,class-status-System.Runtime.Remoting.src,cm/cormissing.css,cm/cormissing.js
|
||||
|
||||
@@ -143,6 +149,8 @@ src/%.xml: ../../../mcs/class/lib/%.dll $(CORCOMPARE)/CorCompare.exe
|
||||
src/corlib.xml: ../../../mcs/class/lib/corlib_cmp.dll $(CORCOMPARE)/CorCompare.exe
|
||||
$(CORCOMPARE)/CorCompare.exe -f corlib -ms mscorlib -x $@ $<
|
||||
|
||||
src/System.Security.xml: ../../../mcs/class/lib/System.Security_cmp.dll $(CORCOMPARE)/CorCompare.exe
|
||||
$(CORCOMPARE)/CorCompare.exe -f System.Security -ms System.Security -x $@ $<
|
||||
|
||||
../class-status: ../class-status.in
|
||||
cp -f $< $@
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<!--
|
||||
body { font-family: "trebuchet ms", lucida, verdana, helvetica;
|
||||
|
||||
background-attachment: fixed; }
|
||||
}
|
||||
body, td, table { font-family: "trebuchet ms", lucida, verdana, helvetica;
|
||||
font-size: 14px; }
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
* System.Windows.Forms
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
System.Windows.Forms is currently being implemented using the
|
||||
Win32 API, we will be using <a
|
||||
href="http://www.winehq.com">WineLib</a> on Unix systems to
|
||||
@@ -19,6 +22,12 @@
|
||||
Gtk/FrameBuffer is an option. If you have suggestions or
|
||||
recommendations, please let us <a
|
||||
href="mailto:[email protected]">let us know</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="images/WINESWF.JPG"><img src="images/WINESWF-mini.JPG"></a>
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
* Contributing
|
||||
|
||||
|
||||
@@ -225,6 +225,15 @@
|
||||
It may not be possible to manage exceptions in that case,
|
||||
though. I need to think more about it.
|
||||
|
||||
** Threading issues
|
||||
|
||||
If your application creates threads on its own, and you want them to
|
||||
be able to call code into the CIL universe with Mono, you have to
|
||||
register the thread with Mono before issuing the call.
|
||||
|
||||
To do so, call the mono_thread_attach() function before you execute
|
||||
any managed code from the thread
|
||||
|
||||
* Samples
|
||||
|
||||
See the sample programs inmono/sample/embed for examples of
|
||||
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
|
||||
Threading in Mono
|
||||
=================
|
||||
|
||||
0. Terminology
|
||||
--------------
|
||||
|
||||
"Main thread" - The initial OS-native thread that the
|
||||
application started with.
|
||||
|
||||
"Helper thread" - A native thread created internally
|
||||
by the runtime, such as the finalizer thread, or an
|
||||
asynchronous delegate invocation thread. These
|
||||
threads can run managed code.
|
||||
|
||||
"Primary CLR thread" - The native thread that called
|
||||
the Main() method when executing an assembly.
|
||||
|
||||
"Secondary CLR thread" - A native thread created by a
|
||||
program that instantiates a System.Threading.Thread object
|
||||
and calls its Start() method.
|
||||
|
||||
1. Thread exit behaviour in the standalone mono runtime
|
||||
-------------------------------------------------------
|
||||
|
||||
The correct behaviour of the runtime should be:
|
||||
|
||||
a) If Main() returns, the runtime should wait for all
|
||||
foreground secondary CLR threads to finish. The
|
||||
wording in the class documentation states: "Once all
|
||||
foreground threads belonging to a process have
|
||||
terminated, the common language runtime ends the
|
||||
process by invoking Abort on any background threads
|
||||
that are still alive." Testing seems to indicate that
|
||||
the background thread can't cancel the Abort by
|
||||
catching the ThreadAbortException and calling
|
||||
ResetAbort here. Indeed, not even the finally block
|
||||
seems to be executed.
|
||||
|
||||
b) if any of the primary CLR thread, a secondary CLR
|
||||
thread or a helper thread calls
|
||||
System.Environment.Exit(), the application should
|
||||
terminate immediately without waiting for foreground
|
||||
primary or secondary CLR threads to finish.
|
||||
|
||||
c) if the primary CLR thread throws an uncaught
|
||||
exception, the application should terminate
|
||||
immediately without waiting for secondary CLR threads
|
||||
to finish. This might be implemented internally by
|
||||
pretending that all the running secondary CLR threads
|
||||
are background threads.
|
||||
|
||||
d) if a secondary CLR thread throws an uncaught
|
||||
exception that thread should terminate and all other
|
||||
threads should continue to execute.
|
||||
|
||||
e) if a helper thread throws an uncaught exception and
|
||||
that thread happens to be the GC finalizer thread,
|
||||
testing seems to indicate that the exception stack
|
||||
trace is displayed as normal, and the exception is
|
||||
then ignored (as though there is a try {} catch{}
|
||||
around all finalizers that just prints the stack
|
||||
trace.) Calling Abort() on the GC finalizer thread
|
||||
also does not cause it to exit: it behaves as though
|
||||
the ThreadAbortException is caught and ResetAbort is
|
||||
called. Asynchronous delegate helper threads should
|
||||
behave as secondary CLR threads, but uncaught
|
||||
exceptions should be rethrown on the thread that calls
|
||||
EndInvoke().
|
||||
|
||||
|
||||
The difficulties happen with cases b) and c):
|
||||
|
||||
The current implementation of
|
||||
System.Environment.Exit() calls exit(2) directly,
|
||||
which is rather unfriendly: it prevents any runtime
|
||||
cleanup, statistics gathering, etc. and is pretty
|
||||
obnoxious to embedded code.
|
||||
|
||||
The current exception handling code calls ExitThread()
|
||||
(emulated with pthread_exit() in the io-layer) if an
|
||||
exception is not caught.
|
||||
|
||||
When called from the main thread, both POSIX
|
||||
pthread_exit() and w32 ExitThread() block if there are
|
||||
other threads still running (in the w32 case, if there
|
||||
are other foreground threads still running; threads
|
||||
can set as background.) If the main thread is also
|
||||
the primary CLR thread, then the application will
|
||||
block until all other threads (including helper
|
||||
threads) terminate. Some helper threads will not
|
||||
terminate until specifically told to by the runtime:
|
||||
for example, the GC finalizer thread needs to run
|
||||
until all of the primary and secondary CLR threads
|
||||
have finished.
|
||||
|
||||
Also, if the main thread is also the primary CLR
|
||||
thread, the runtime loses the opportunity to do any
|
||||
cleaning up. Adding a special case to call exit(2)
|
||||
instead of ExitThread() in the primary CLR thread
|
||||
suffers from the same problems as
|
||||
System.Environment.Exit() calling exit(2).
|
||||
|
||||
|
||||
The simple solution is to run the primary CLR thread
|
||||
in a new native thread, leaving the main thread free
|
||||
for housekeeping duties. There still needs to be some
|
||||
special handling for the case where the primary CLR
|
||||
thread fails to catch an exception: the secondary CLR
|
||||
threads then need to be terminated.
|
||||
|
||||
When the primary and secondary CLR threads have all
|
||||
terminated, the helper threads can be killed off and
|
||||
the runtime can clean itself up and exit.
|
||||
|
||||
|
||||
|
||||
2. Thread initialisation
|
||||
------------------------
|
||||
|
||||
Threads have to undergo some initialisation before
|
||||
managed code can be executed. A
|
||||
System.Threading.Thread object must be created, and
|
||||
the thread details need to be stored so that the
|
||||
threads can be managed later. The JIT needs to record
|
||||
the last managed frame stack pointer in a TLS slot,
|
||||
and the current Thread object is also recorded.
|
||||
|
||||
New threads created by managed calls to
|
||||
System.Threading.Thread methods will have all needed
|
||||
initialisation performed. Threads created by the
|
||||
runtime with calls to mono_thread_create() will too.
|
||||
Existing threads can be passed to the runtime; these
|
||||
must call mono_thread_attach() before any CLR code can
|
||||
be executed on that thread.
|
||||
|
||||
|
||||
3. Constraints on embedding the Mono runtime
|
||||
--------------------------------------------
|
||||
|
||||
The discussion above concerning application behaviour
|
||||
in the event of threads terminating, whether by
|
||||
returning from the start function, throwing uncaught
|
||||
exceptions or by calling System.Environment.Exit(),
|
||||
only really applies to the standalone Mono runtime.
|
||||
|
||||
An embedding application should specify what behaviour
|
||||
is required when, for example,
|
||||
System.Environment.Exit() is called. The application
|
||||
is also responsible for its own thread management, and
|
||||
it should be prepared for any of the primary CLR
|
||||
thread or secondary CLR threads to terminate at any
|
||||
time. The application should also take into account
|
||||
that the runtime will create helper threads as needed,
|
||||
as this may cause pthread_exit() or ExitThread() to
|
||||
block indefinitely, as noted above.
|
||||
@@ -0,0 +1,42 @@
|
||||
.\"
|
||||
.\" cert2spc manual page.
|
||||
.\" Copyright 2002, 2003 Motus Technologies
|
||||
.\" Author:
|
||||
.\" Sebastien Pouliot ([email protected])
|
||||
.\"
|
||||
.TH Mono "cert2spc"
|
||||
.SH NAME
|
||||
cert2spc \- Transform multiple X.509 certificates to a Software
|
||||
Publisher Certificate
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
.B cert2spc certificate|crl [certificate|crl ...] outputfile.spc
|
||||
.SH DESCRIPTION
|
||||
Combine a list of X.509 certificates or X.509 CRL (Certificate
|
||||
Revocation List) into a Software Publisher Certificate (PKCS#7
|
||||
file). The SPC file is required for signing a PE file (like an
|
||||
assembly) using signcode.
|
||||
.SH PARAMETERS
|
||||
.TP
|
||||
.I "certificate"
|
||||
One (or more) X.509 certificate to add (space separated).
|
||||
.TP
|
||||
.I "crl"
|
||||
One (or more) X.509 CRL to add (space separated).
|
||||
.TP
|
||||
.I "output.spc"
|
||||
Software Publisher Certificate to output. If the specified file
|
||||
exists it will be overwritten.
|
||||
.SH AUTHOR
|
||||
Written by Sebastien Pouliot
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2002, 2003 Motus Technologies.
|
||||
Released under BSD license.
|
||||
.SH MAILING LISTS
|
||||
Visit http://mail.ximian.com/mailman/mono-list for details.
|
||||
.SH WEB SITE
|
||||
Visit: http://www.go-mono.com for details
|
||||
.SH SEE ALSO
|
||||
.BR makecert(1), signcode(1)
|
||||
|
||||
|
||||
@@ -136,6 +136,15 @@ Provides a search path to mono and mint where to look for library files.
|
||||
Directories are separated by the platform path separator (colons on unix). Example:
|
||||
.B /home/username/lib:/usr/local/mono/lib
|
||||
.PP
|
||||
.TP
|
||||
.I "MONO_DISABLE_SHM"
|
||||
If this variable is set, it disables the Windows I/O Emulation layer,
|
||||
and handles (files, events, mutexes, pipes) will not be shared across
|
||||
processes. This option is only available on Unix.
|
||||
.TP
|
||||
.I "MONO_CFG_DIR"
|
||||
If set, this variable overrides the default system configuration directory
|
||||
($PREFIX/etc). It's used to locate machine.config file.
|
||||
.SH FILES
|
||||
On Unix assemblies are loaded from the installation lib directory. If you set
|
||||
`prefix' to /usr, the assemblies will be located in /usr/lib. On
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
.\"
|
||||
.\" secutil manual page.
|
||||
.\" Copyright 2002, 2003 Motus Technologies
|
||||
.\" Author:
|
||||
.\" Sebastien Pouliot ([email protected])
|
||||
.\"
|
||||
.TH Mono "secutil"
|
||||
.SH NAME
|
||||
secutil \- Extract X.509 certificates and strongnames from assemblies.
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
.B secutil [options] filename
|
||||
.SH DESCRIPTION
|
||||
Extract X.509 certificates and strongnames from assemblies in a
|
||||
format that can be easily re-used in source code (C# or VB.NET syntax).
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.I "-s assembly", "-strongname assembly"
|
||||
Display strongname informations about the assembly.
|
||||
.TP
|
||||
.I "-x assembly", "-x509certificate assembly"
|
||||
Display the X509 Authenticode certificate for the assembly.
|
||||
.TP
|
||||
.I "-a", "-array"
|
||||
Display data in a decimal array (default).
|
||||
.TP
|
||||
.I "-v", "-vbmode"
|
||||
Display data in a VisualBasic friendly format.
|
||||
.TP
|
||||
.I "-c", "-cmode"
|
||||
Display data in a C/C++/C# friendly format (default).
|
||||
.TP
|
||||
.I "-help", "-h", "-?"
|
||||
Display help about this tool.
|
||||
.SH AUTHOR
|
||||
Written by Sebastien Pouliot
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2002, 2003 Motus Technologies.
|
||||
Released under BSD license.
|
||||
.SH MAILING LISTS
|
||||
Visit http://mail.ximian.com/mailman/mono-list for details.
|
||||
.SH WEB SITE
|
||||
Visit: http://www.go-mono.com for details
|
||||
.SH SEE ALSO
|
||||
.BR sn(1), signcode(1)
|
||||
+47
-11
@@ -342,16 +342,30 @@ ption defaulting to true.
|
||||
.SH PROVIDERS
|
||||
.nf
|
||||
|
||||
PROVIDER NAME NAMESPACE ASSEMBLY
|
||||
PROVIDER NAME NAMESPACE ASSEMBLY
|
||||
|
||||
OleDb OLE DB System.Data.OleDb System.Data
|
||||
SqlClient MS SQL 7/2000 System.Data.SqlClient System.Data
|
||||
Odbc ODBC System.Data.Odbc System.Data
|
||||
MySql MySQL Mono.Data.MySql Mono.Data.MySql
|
||||
Sqlite SQL Lite Mono.Data.SqliteClient Mono.Data.SqliteClient
|
||||
Sybase Sybase Mono.Data.SybaseClient Mono.Data.SybaseClient
|
||||
Tds TDS Generic Mono.Data.TdsClient Mono.Data.TdsClient
|
||||
PostgreSql PostgreSQL Mono.Data.PostgreSqlClient Mono.Data.PostgreSqlClient
|
||||
Internal
|
||||
--------
|
||||
|
||||
OleDb OLE DB System.Data.OleDb System.Data
|
||||
SqlClient MS SQL 7/2000 System.Data.SqlClient System.Data
|
||||
Odbc ODBC System.Data.Odbc System.Data
|
||||
|
||||
External to System.Data
|
||||
-----------------------
|
||||
MySql MySQL Mono.Data.MySql Mono.Data.MySql
|
||||
Sqlite SQL Lite Mono.Data.SqliteClient Mono.Data.SqliteClient
|
||||
Sybase Sybase Mono.Data.SybaseClient Mono.Data.SybaseClient
|
||||
Tds TDS Generic Mono.Data.TdsClient Mono.Data.TdsClient
|
||||
PostgreSql M PostgreSQL Mono.Data.PostgreSqlClient Mono.Data.PostgreSqlClient
|
||||
DB2 IBM DB2 Mono.Data.DB2Client Mono.Data.DB2Client
|
||||
Oracle Oracle 8i System.Data.OracleClient System.Data.OracleClient
|
||||
|
||||
External to Mono
|
||||
----------------
|
||||
|
||||
Npgsql NetPostgreSQL Npgsql Npgsql
|
||||
MySQLNet ByteFX MySQL ByteFX.Data.MySQL ByteFX.Data
|
||||
|
||||
.fi
|
||||
.SH CONNECTION STRING SAMPLES
|
||||
@@ -407,10 +421,32 @@ which connects to a PostgreSQL database:
|
||||
|
||||
Provider=PostgreSQL;Addr=127.0.0.1;Database=rodrigo
|
||||
|
||||
|
||||
Oracle via System.Data.OracleClient
|
||||
|
||||
Data Source=testdb;User ID=scott;Password=tiger
|
||||
|
||||
|
||||
IBM DB2 Universal Database via Mono.Data.DB2Client
|
||||
|
||||
DSN=sample;User ID=db2admin;Password=mysecret
|
||||
|
||||
|
||||
Npgsql (.NET PostgreSQL) from
|
||||
http://gborg.postgresql.org/project/npgsql/projdisplay.php
|
||||
|
||||
Server=localhost;Database=test;User ID=postgres;Password=fun2db
|
||||
|
||||
|
||||
MySQLNet (ByteFX MySQL) from
|
||||
http://sourceforge.net/projects/mysqlnet/
|
||||
|
||||
Server=localhost;Database=test;User ID=mysql;Password=
|
||||
|
||||
|
||||
.fi
|
||||
.SH DEBUGGING SUPPORT
|
||||
No debugging support.
|
||||
.SH TRACING SUPPORT
|
||||
No support for tracing right now.
|
||||
.SH AUTHORS
|
||||
The Mono SQL# Tool was written
|
||||
.nf
|
||||
|
||||
@@ -16,3 +16,4 @@ Class Libraries:
|
||||
John Barnette ([email protected])
|
||||
Daniel Morgan <[email protected]>
|
||||
Sebastien Pouliot <[email protected]>
|
||||
Per Arneng <[email protected]>
|
||||
@@ -1,3 +1,33 @@
|
||||
2003-03-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* makefile: added Mono.Posix and System.Management.
|
||||
|
||||
2003-02-16 Martin Baulig <[email protected]>
|
||||
|
||||
* docs/compiler: Added a few works about the new `Location' code.
|
||||
|
||||
2003-02-15 Nick Drochak <[email protected]>
|
||||
|
||||
* makefile.gnu: Add testcorlib target to run just the corlib unit tests.
|
||||
|
||||
2003-02-10 Nick Drochak <[email protected]>
|
||||
|
||||
* makefile: Add testcorlib target to run just the corlib unit tests.
|
||||
|
||||
2003-01-16 Nick Drochak <[email protected]>
|
||||
|
||||
* makefile.gnu: Add corlib target to just build that.
|
||||
|
||||
2003-01-14 Duncan Mak <[email protected]>
|
||||
|
||||
* ilasm/parser/ScannerAdapter.cs: Remove the cleanup method now that
|
||||
it's no longer in the interface.
|
||||
|
||||
2003-01-13 Duncan Mak <[email protected]>
|
||||
|
||||
* ilasm/parser/ScannerAdapter.cs: Implement the new cleanup method
|
||||
in the tokenizer. This fixes the build.
|
||||
|
||||
2003-01-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* README.building: New file.
|
||||
|
||||
@@ -1,3 +1,56 @@
|
||||
2003-03-06 Jackson Harper <[email protected]>
|
||||
|
||||
* makefile.gnu: Add PEAPI to the build
|
||||
|
||||
2003-03-06 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.build: added Mono.Security to build, test and clean.
|
||||
|
||||
2003-03-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* class/library.build:
|
||||
* class/makefile.gnu: added Mono.Posix and System.Management.
|
||||
|
||||
2003-03-02 Jackson Harper <[email protected]>
|
||||
|
||||
* mcs/class: Add PEAPI directory
|
||||
|
||||
2003-02-22 Martin Baulig <[email protected]>
|
||||
|
||||
* library.make: Pass `MCS_FLAGS' to MCS.
|
||||
|
||||
2003-02-15 Zoltan Varga <[email protected]>
|
||||
|
||||
* makefile.gnu (test): do not install .dbg files since mcs no longer
|
||||
generates them.
|
||||
|
||||
2003-02-13 Tim Coleman <[email protected]>
|
||||
* makefile.gnu: Add System.Data.OracleClient to linux build.
|
||||
|
||||
2003-02-10 Nick Drochak <[email protected]>
|
||||
|
||||
* library.build:
|
||||
* makefile: add testcorlib target to run unit tests just for corlib.
|
||||
|
||||
2003-02-05 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.build: added Mono.Security.Win32 to build, test and
|
||||
clean. There's no makefile.gnu for this assembly as it is
|
||||
specific to Win32.
|
||||
|
||||
2003-01-23 Nick Drochak <[email protected]>
|
||||
|
||||
* makefile: install the .dbg files too so the debugger can use them.
|
||||
|
||||
2003-01-17 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* library.build: added System.Security to build, test and clean.
|
||||
There's no makefile.gnu yet for this assembly.
|
||||
|
||||
2003-01-16 Rodrigo Moya <[email protected]>
|
||||
|
||||
* makefile.gnu: added Mono.Data.DB2Client directory.
|
||||
|
||||
2003-01-08 Gaurav Vaish <gvaish_mono AT lycos.com>
|
||||
|
||||
* System.Web.Mobile : Added new directory
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2003-02-23 Jackson Harper <[email protected]>
|
||||
|
||||
* CompilerError.cs: Use fields not properties, and remove unneeded finalizer
|
||||
|
||||
2002-12-15 Jackson Harper <[email protected]>
|
||||
|
||||
* CompilerError.cs ErrorLevel.cs: Moved ErrorLevel enum into its own file
|
||||
|
||||
@@ -13,64 +13,23 @@ namespace Microsoft.CSharp {
|
||||
|
||||
public class CompilerError {
|
||||
|
||||
private ErrorLevel level = ErrorLevel.None;
|
||||
private string message = null;
|
||||
private string file = null;
|
||||
private int number = 0;
|
||||
private int column = 0;
|
||||
private int line = 0;
|
||||
public ErrorLevel ErrorLevel;
|
||||
public string ErrorMessage;
|
||||
public string SourceFile;
|
||||
public int ErrorNumber;
|
||||
public int SourceColumn;
|
||||
public int SourceLine;
|
||||
|
||||
public CompilerError()
|
||||
public CompilerError ()
|
||||
{
|
||||
ErrorLevel = ErrorLevel.None;
|
||||
ErrorMessage = String.Empty;
|
||||
SourceFile = String.Empty;
|
||||
ErrorNumber = 0;
|
||||
SourceColumn = 0;
|
||||
SourceLine = 0;
|
||||
}
|
||||
|
||||
~CompilerError()
|
||||
{
|
||||
message = null;
|
||||
file = null;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public Properties
|
||||
//
|
||||
|
||||
public ErrorLevel ErrorLevel {
|
||||
get { return level; }
|
||||
set { level = value; }
|
||||
}
|
||||
|
||||
public string ErrorMessage {
|
||||
get {
|
||||
return (null == message ? String.Empty : message);
|
||||
}
|
||||
set {
|
||||
message = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ErrorNumber {
|
||||
get { return number; }
|
||||
set { number = value; }
|
||||
}
|
||||
|
||||
public int SourceColumn {
|
||||
get { return column; }
|
||||
set { column = value; }
|
||||
}
|
||||
|
||||
public string SourceFile {
|
||||
get {
|
||||
return (null == file ? String.Empty : file);
|
||||
}
|
||||
set { file = value; }
|
||||
}
|
||||
|
||||
public int SourceLine {
|
||||
get { return line; }
|
||||
set { line = value; }
|
||||
}
|
||||
|
||||
//
|
||||
// Public Methods
|
||||
//
|
||||
@@ -92,6 +51,7 @@ namespace Microsoft.CSharp {
|
||||
return builder.ToString ();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Private Properties
|
||||
//
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// AssemblyInfo.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("SharpZipLibrary")]
|
||||
[assembly: AssemblyDescription("free C# zlib implementation")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("#ZipLibrary")]
|
||||
[assembly: AssemblyCopyright("(c) Mike Krueger 2001-2002")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: AssemblyVersion("0.31.0.0")]
|
||||
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("SharpZipLib.key")]
|
||||
@@ -0,0 +1,98 @@
|
||||
// BZip2.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// Does all the compress and decompress pre-operation stuff.
|
||||
/// Sets up the streams and file header characters.
|
||||
/// Uses multiply overloaded methods to call for the compress/decompress.
|
||||
/// </summary>
|
||||
public sealed class BZip2
|
||||
{
|
||||
public static void Decompress(Stream instream, Stream outstream)
|
||||
{
|
||||
BufferedStream bos = new BufferedStream(outstream);
|
||||
BufferedStream bis = new BufferedStream(instream);
|
||||
int b = bis.ReadByte();
|
||||
if (b != 'B') {
|
||||
return;
|
||||
}
|
||||
b = bis.ReadByte();
|
||||
if (b != 'Z') {
|
||||
return;
|
||||
}
|
||||
BZip2InputStream bzis = new BZip2InputStream(bis);
|
||||
int ch = bzis.ReadByte();
|
||||
while (ch != -1) {
|
||||
bos.WriteByte((byte)ch);
|
||||
ch = bzis.ReadByte();
|
||||
}
|
||||
bos.Flush();
|
||||
}
|
||||
|
||||
public static void Compress(Stream instream, Stream outstream, int blockSize)
|
||||
{
|
||||
BufferedStream bos = new BufferedStream(outstream);
|
||||
bos.WriteByte((byte)'B');
|
||||
bos.WriteByte((byte)'Z');
|
||||
BufferedStream bis = new BufferedStream(instream);
|
||||
int ch = bis.ReadByte();
|
||||
BZip2OutputStream bzos = new BZip2OutputStream(bos);
|
||||
while(ch != -1) {
|
||||
bzos.WriteByte((byte)ch);
|
||||
ch = bis.ReadByte();
|
||||
}
|
||||
bis.Close();
|
||||
bzos.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* derived from a file which contained this license :
|
||||
* Copyright (c) 1999-2001 Keiron Liddle, Aftex Software
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,155 @@
|
||||
// BZip2Constants.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// Base class for both the compress and decompress classes.
|
||||
/// Holds common arrays, and static data.
|
||||
/// </summary>
|
||||
public sealed class BZip2Constants
|
||||
{
|
||||
public readonly static int[] rNums = {
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
|
||||
public readonly static int baseBlockSize = 100000;
|
||||
|
||||
public readonly static int MAX_ALPHA_SIZE = 258;
|
||||
public readonly static int MAX_CODE_LEN = 23;
|
||||
|
||||
public readonly static int RUNA = 0;
|
||||
public readonly static int RUNB = 1;
|
||||
|
||||
public readonly static int N_GROUPS = 6;
|
||||
public readonly static int G_SIZE = 50;
|
||||
public readonly static int N_ITERS = 4;
|
||||
|
||||
public readonly static int MAX_SELECTORS = (2 + (900000 / G_SIZE));
|
||||
|
||||
public readonly static int NUM_OVERSHOOT_BYTES = 20;
|
||||
}
|
||||
}
|
||||
|
||||
/* This file was derived from a file containing under this license:
|
||||
*
|
||||
* This file is a part of bzip2 and/or libbzip2, a program and
|
||||
* library for lossless, block-sorting data compression.
|
||||
*
|
||||
* Copyright (C) 1996-1998 Julian R Seward. 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. The origin of this software must not be misrepresented; you must
|
||||
* not claim that you wrote the original software. If you use this
|
||||
* software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 3. Altered source versions must be plainly marked as such, and must
|
||||
* not be misrepresented as being the original software.
|
||||
*
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* Java version ported by Keiron Liddle, Aftex Software <[email protected]> 1999-2001
|
||||
*/
|
||||
@@ -0,0 +1,945 @@
|
||||
// BZip2InputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.BZip2 {
|
||||
|
||||
/// <summary>
|
||||
/// An input stream that decompresses from the BZip2 format (without the file
|
||||
/// header chars) to be read as any other stream.
|
||||
/// </summary>
|
||||
public class BZip2InputStream : Stream
|
||||
{
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return baseStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return baseStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return baseStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length {
|
||||
get {
|
||||
return baseStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position {
|
||||
get {
|
||||
return baseStream.Position;
|
||||
}
|
||||
set {
|
||||
baseStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the baseInputStream
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
if (baseStream != null) {
|
||||
baseStream.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return baseStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void SetLength(long val)
|
||||
{
|
||||
baseStream.SetLength(val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void Write(byte[] array, int offset, int count)
|
||||
{
|
||||
baseStream.Write(array, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void WriteByte(byte val)
|
||||
{
|
||||
baseStream.WriteByte(val);
|
||||
}
|
||||
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int rb = ReadByte();
|
||||
if (rb == -1) {
|
||||
return i;
|
||||
}
|
||||
b[off + i] = (byte)rb;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the input stream
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
if (baseStream != null) {
|
||||
baseStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
static void Cadvise()
|
||||
{
|
||||
Console.WriteLine("CRC Error");
|
||||
//throw new CCoruptionError();
|
||||
}
|
||||
|
||||
static void BadBGLengths()
|
||||
{
|
||||
Console.WriteLine("bad BG lengths");
|
||||
}
|
||||
|
||||
static void bitStreamEOF()
|
||||
{
|
||||
Console.WriteLine("bit stream eof");
|
||||
}
|
||||
|
||||
static void CompressedStreamEOF()
|
||||
{
|
||||
Console.WriteLine("compressed stream eof");
|
||||
}
|
||||
|
||||
void MakeMaps()
|
||||
{
|
||||
nInUse = 0;
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
if (inUse[i]) {
|
||||
seqToUnseq[nInUse] = (byte)i;
|
||||
unseqToSeq[i] = (byte)nInUse;
|
||||
nInUse++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--
|
||||
index of the last char in the block, so
|
||||
the block size == last + 1.
|
||||
--*/
|
||||
int last;
|
||||
|
||||
/*--
|
||||
index in zptr[] of original string after sorting.
|
||||
--*/
|
||||
int origPtr;
|
||||
|
||||
/*--
|
||||
always: in the range 0 .. 9.
|
||||
The current block size is 100000 * this number.
|
||||
--*/
|
||||
int blockSize100k;
|
||||
|
||||
bool blockRandomised;
|
||||
|
||||
// private int bytesIn;
|
||||
// private int bytesOut;
|
||||
int bsBuff;
|
||||
int bsLive;
|
||||
IChecksum mCrc = new StrangeCRC();
|
||||
|
||||
bool[] inUse = new bool[256];
|
||||
int nInUse;
|
||||
|
||||
byte[] seqToUnseq = new byte[256];
|
||||
byte[] unseqToSeq = new byte[256];
|
||||
|
||||
byte[] selector = new byte[BZip2Constants.MAX_SELECTORS];
|
||||
byte[] selectorMtf = new byte[BZip2Constants.MAX_SELECTORS];
|
||||
|
||||
int[] tt;
|
||||
byte[] ll8;
|
||||
|
||||
/*--
|
||||
freq table collected to save a pass over the data
|
||||
during decompression.
|
||||
--*/
|
||||
int[] unzftab = new int[256];
|
||||
|
||||
int[][] limit = new int[BZip2Constants.N_GROUPS][];
|
||||
int[][] baseArray = new int[BZip2Constants.N_GROUPS][];
|
||||
int[][] perm = new int[BZip2Constants.N_GROUPS][];
|
||||
int[] minLens = new int[BZip2Constants.N_GROUPS];
|
||||
|
||||
Stream baseStream;
|
||||
bool streamEnd = false;
|
||||
|
||||
int currentChar = -1;
|
||||
|
||||
const int START_BLOCK_STATE = 1;
|
||||
const int RAND_PART_A_STATE = 2;
|
||||
const int RAND_PART_B_STATE = 3;
|
||||
const int RAND_PART_C_STATE = 4;
|
||||
const int NO_RAND_PART_A_STATE = 5;
|
||||
const int NO_RAND_PART_B_STATE = 6;
|
||||
const int NO_RAND_PART_C_STATE = 7;
|
||||
|
||||
int currentState = START_BLOCK_STATE;
|
||||
|
||||
int storedBlockCRC, storedCombinedCRC;
|
||||
int computedBlockCRC;
|
||||
uint computedCombinedCRC;
|
||||
|
||||
int count, chPrev, ch2;
|
||||
int tPos;
|
||||
int rNToGo = 0;
|
||||
int rTPos = 0;
|
||||
int i2, j2;
|
||||
byte z;
|
||||
|
||||
public BZip2InputStream(Stream zStream)
|
||||
{
|
||||
// init arrays
|
||||
for (int i = 0; i < BZip2Constants.N_GROUPS; ++i) {
|
||||
limit[i] = new int[BZip2Constants.MAX_ALPHA_SIZE];
|
||||
baseArray[i] = new int[BZip2Constants.MAX_ALPHA_SIZE];
|
||||
perm[i] = new int[BZip2Constants.MAX_ALPHA_SIZE];
|
||||
}
|
||||
|
||||
ll8 = null;
|
||||
tt = null;
|
||||
BsSetStream(zStream);
|
||||
Initialize();
|
||||
InitBlock();
|
||||
SetupBlock();
|
||||
}
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (streamEnd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int retChar = currentChar;
|
||||
switch (currentState) {
|
||||
case RAND_PART_B_STATE:
|
||||
SetupRandPartB();
|
||||
break;
|
||||
case RAND_PART_C_STATE:
|
||||
SetupRandPartC();
|
||||
break;
|
||||
case NO_RAND_PART_B_STATE:
|
||||
SetupNoRandPartB();
|
||||
break;
|
||||
case NO_RAND_PART_C_STATE:
|
||||
SetupNoRandPartC();
|
||||
break;
|
||||
case START_BLOCK_STATE:
|
||||
case NO_RAND_PART_A_STATE:
|
||||
case RAND_PART_A_STATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return retChar;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
char magic3 = BsGetUChar();
|
||||
char magic4 = BsGetUChar();
|
||||
|
||||
if (magic3 != 'h' || magic4 < '1' || magic4 > '9') {
|
||||
streamEnd = true;
|
||||
return;
|
||||
}
|
||||
|
||||
SetDecompressStructureSizes(magic4 - '0');
|
||||
computedCombinedCRC = 0;
|
||||
}
|
||||
|
||||
void InitBlock()
|
||||
{
|
||||
char magic1 = BsGetUChar();
|
||||
char magic2 = BsGetUChar();
|
||||
char magic3 = BsGetUChar();
|
||||
char magic4 = BsGetUChar();
|
||||
char magic5 = BsGetUChar();
|
||||
char magic6 = BsGetUChar();
|
||||
|
||||
if (magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 && magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90) {
|
||||
Complete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 || magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59) {
|
||||
BadBlockHeader();
|
||||
streamEnd = true;
|
||||
return;
|
||||
}
|
||||
|
||||
storedBlockCRC = BsGetInt32();
|
||||
|
||||
blockRandomised = (BsR(1) == 1);
|
||||
|
||||
// currBlockNo++;
|
||||
GetAndMoveToFrontDecode();
|
||||
|
||||
mCrc.Reset();
|
||||
currentState = START_BLOCK_STATE;
|
||||
}
|
||||
|
||||
void EndBlock()
|
||||
{
|
||||
computedBlockCRC = (int)mCrc.Value;
|
||||
|
||||
/*-- A bad CRC is considered a fatal error. --*/
|
||||
if (storedBlockCRC != computedBlockCRC) {
|
||||
CrcError();
|
||||
}
|
||||
|
||||
// 1528150659
|
||||
computedCombinedCRC = ((computedCombinedCRC << 1) & 0xFFFFFFFF) | (computedCombinedCRC >> 31);
|
||||
computedCombinedCRC = computedCombinedCRC ^ (uint)computedBlockCRC;
|
||||
}
|
||||
|
||||
void Complete()
|
||||
{
|
||||
storedCombinedCRC = BsGetInt32();
|
||||
if (storedCombinedCRC != (int)computedCombinedCRC) {
|
||||
CrcError();
|
||||
}
|
||||
|
||||
streamEnd = true;
|
||||
}
|
||||
|
||||
static void BlockOverrun()
|
||||
{
|
||||
Console.WriteLine("Block overrun");
|
||||
}
|
||||
|
||||
static void BadBlockHeader()
|
||||
{
|
||||
Console.WriteLine("Bad block header");
|
||||
}
|
||||
|
||||
static void CrcError()
|
||||
{
|
||||
Console.WriteLine("crc error");
|
||||
}
|
||||
|
||||
|
||||
void BsSetStream(Stream f)
|
||||
{
|
||||
baseStream = f;
|
||||
bsLive = 0;
|
||||
bsBuff = 0;
|
||||
}
|
||||
|
||||
void FillBuffer()
|
||||
{
|
||||
int thech = 0;
|
||||
|
||||
try {
|
||||
thech = baseStream.ReadByte();
|
||||
} catch (Exception) {
|
||||
CompressedStreamEOF();
|
||||
}
|
||||
|
||||
if (thech == -1) {
|
||||
CompressedStreamEOF();
|
||||
}
|
||||
|
||||
bsBuff = (bsBuff << 8) | (thech & 0xFF);
|
||||
bsLive += 8;
|
||||
}
|
||||
|
||||
int BsR(int n)
|
||||
{
|
||||
while (bsLive < n) {
|
||||
FillBuffer();
|
||||
}
|
||||
|
||||
int v = (bsBuff >> (bsLive - n)) & ((1 << n) - 1);
|
||||
bsLive -= n;
|
||||
return v;
|
||||
}
|
||||
|
||||
char BsGetUChar()
|
||||
{
|
||||
return (char)BsR(8);
|
||||
}
|
||||
|
||||
int BsGetint()
|
||||
{
|
||||
int u = 0;
|
||||
u = (u << 8) | BsR(8);
|
||||
u = (u << 8) | BsR(8);
|
||||
u = (u << 8) | BsR(8);
|
||||
u = (u << 8) | BsR(8);
|
||||
return u;
|
||||
}
|
||||
|
||||
int BsGetIntVS(int numBits)
|
||||
{
|
||||
return (int)BsR(numBits);
|
||||
}
|
||||
|
||||
int BsGetInt32()
|
||||
{
|
||||
return (int)BsGetint();
|
||||
}
|
||||
|
||||
void HbCreateDecodeTables(int[] limit, int[] baseArray, int[] perm, char[] length, int minLen, int maxLen, int alphaSize)
|
||||
{
|
||||
int pp = 0;
|
||||
|
||||
for (int i = minLen; i <= maxLen; ++i) {
|
||||
for (int j = 0; j < alphaSize; ++j) {
|
||||
if (length[j] == i) {
|
||||
perm[pp] = j;
|
||||
++pp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < BZip2Constants.MAX_CODE_LEN; i++) {
|
||||
baseArray[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < alphaSize; i++) {
|
||||
++baseArray[length[i] + 1];
|
||||
}
|
||||
|
||||
for (int i = 1; i < BZip2Constants.MAX_CODE_LEN; i++) {
|
||||
baseArray[i] += baseArray[i - 1];
|
||||
}
|
||||
|
||||
for (int i = 0; i < BZip2Constants.MAX_CODE_LEN; i++) {
|
||||
limit[i] = 0;
|
||||
}
|
||||
|
||||
int vec = 0;
|
||||
|
||||
for (int i = minLen; i <= maxLen; i++) {
|
||||
vec += (baseArray[i + 1] - baseArray[i]);
|
||||
limit[i] = vec - 1;
|
||||
vec <<= 1;
|
||||
}
|
||||
|
||||
for (int i = minLen + 1; i <= maxLen; i++) {
|
||||
baseArray[i] = ((limit[i - 1] + 1) << 1) - baseArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
void RecvDecodingTables()
|
||||
{
|
||||
char[][] len = new char[BZip2Constants.N_GROUPS][];
|
||||
for (int i = 0; i < BZip2Constants.N_GROUPS; ++i) {
|
||||
len[i] = new char[BZip2Constants.MAX_ALPHA_SIZE];
|
||||
}
|
||||
|
||||
bool[] inUse16 = new bool[16];
|
||||
|
||||
/*--- Receive the mapping table ---*/
|
||||
for (int i = 0; i < 16; i++) {
|
||||
inUse16[i] = (BsR(1) == 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (inUse16[i]) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
inUse[i * 16 + j] = (BsR(1) == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MakeMaps();
|
||||
int alphaSize = nInUse + 2;
|
||||
|
||||
/*--- Now the selectors ---*/
|
||||
int nGroups = BsR(3);
|
||||
int nSelectors = BsR(15);
|
||||
|
||||
for (int i = 0; i < nSelectors; i++) {
|
||||
int j = 0;
|
||||
while (BsR(1) == 1) {
|
||||
j++;
|
||||
}
|
||||
selectorMtf[i] = (byte)j;
|
||||
}
|
||||
|
||||
/*--- Undo the MTF values for the selectors. ---*/
|
||||
byte[] pos = new byte[BZip2Constants.N_GROUPS];
|
||||
for (int v = 0; v < nGroups; v++) {
|
||||
pos[v] = (byte)v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nSelectors; i++) {
|
||||
int v = selectorMtf[i];
|
||||
byte tmp = pos[v];
|
||||
while (v > 0) {
|
||||
pos[v] = pos[v - 1];
|
||||
v--;
|
||||
}
|
||||
pos[0] = tmp;
|
||||
selector[i] = tmp;
|
||||
}
|
||||
|
||||
/*--- Now the coding tables ---*/
|
||||
for (int t = 0; t < nGroups; t++) {
|
||||
int curr = BsR(5);
|
||||
for (int i = 0; i < alphaSize; i++) {
|
||||
while (BsR(1) == 1) {
|
||||
if (BsR(1) == 0) {
|
||||
curr++;
|
||||
} else {
|
||||
curr--;
|
||||
}
|
||||
}
|
||||
len[t][i] = (char)curr;
|
||||
}
|
||||
}
|
||||
|
||||
/*--- Create the Huffman decoding tables ---*/
|
||||
for (int t = 0; t < nGroups; t++) {
|
||||
int minLen = 32;
|
||||
int maxLen = 0;
|
||||
for (int i = 0; i < alphaSize; i++) {
|
||||
maxLen = Math.Max(maxLen, len[t][i]);
|
||||
minLen = Math.Min(minLen, len[t][i]);
|
||||
}
|
||||
HbCreateDecodeTables(limit[t], baseArray[t], perm[t], len[t], minLen, maxLen, alphaSize);
|
||||
minLens[t] = minLen;
|
||||
}
|
||||
}
|
||||
|
||||
void GetAndMoveToFrontDecode()
|
||||
{
|
||||
byte[] yy = new byte[256];
|
||||
int nextSym;
|
||||
|
||||
int limitLast = BZip2Constants.baseBlockSize * blockSize100k;
|
||||
origPtr = BsGetIntVS(24);
|
||||
|
||||
RecvDecodingTables();
|
||||
int EOB = nInUse+1;
|
||||
int groupNo = -1;
|
||||
int groupPos = 0;
|
||||
|
||||
/*--
|
||||
Setting up the unzftab entries here is not strictly
|
||||
necessary, but it does save having to do it later
|
||||
in a separate pass, and so saves a block's worth of
|
||||
cache misses.
|
||||
--*/
|
||||
for (int i = 0; i <= 255; i++) {
|
||||
unzftab[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 255; i++) {
|
||||
yy[i] = (byte)i;
|
||||
}
|
||||
|
||||
last = -1;
|
||||
|
||||
if (groupPos == 0) {
|
||||
groupNo++;
|
||||
groupPos = BZip2Constants.G_SIZE;
|
||||
}
|
||||
|
||||
groupPos--;
|
||||
int zt = selector[groupNo];
|
||||
int zn = minLens[zt];
|
||||
int zvec = BsR(zn);
|
||||
int zj;
|
||||
|
||||
while (zvec > limit[zt][zn]) {
|
||||
zn++;
|
||||
while (bsLive < 1) {
|
||||
FillBuffer();
|
||||
}
|
||||
zj = (bsBuff >> (bsLive-1)) & 1;
|
||||
bsLive--;
|
||||
zvec = (zvec << 1) | zj;
|
||||
}
|
||||
nextSym = perm[zt][zvec - baseArray[zt][zn]];
|
||||
|
||||
while (true) {
|
||||
|
||||
if (nextSym == EOB) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nextSym == BZip2Constants.RUNA || nextSym == BZip2Constants.RUNB) {
|
||||
int s = -1;
|
||||
int n = 1;
|
||||
do {
|
||||
if (nextSym == BZip2Constants.RUNA) {
|
||||
s += (0+1) * n;
|
||||
} else if (nextSym == BZip2Constants.RUNB) {
|
||||
s += (1+1) * n;
|
||||
}
|
||||
|
||||
n <<= 1;
|
||||
|
||||
if (groupPos == 0) {
|
||||
groupNo++;
|
||||
groupPos = BZip2Constants.G_SIZE;
|
||||
}
|
||||
|
||||
groupPos--;
|
||||
|
||||
zt = selector[groupNo];
|
||||
zn = minLens[zt];
|
||||
zvec = BsR(zn);
|
||||
|
||||
while (zvec > limit[zt][zn]) {
|
||||
zn++;
|
||||
while (bsLive < 1) {
|
||||
FillBuffer();
|
||||
}
|
||||
zj = (bsBuff >> (bsLive - 1)) & 1;
|
||||
bsLive--;
|
||||
zvec = (zvec << 1) | zj;
|
||||
}
|
||||
nextSym = perm[zt][zvec - baseArray[zt][zn]];
|
||||
} while (nextSym == BZip2Constants.RUNA || nextSym == BZip2Constants.RUNB);
|
||||
|
||||
s++;
|
||||
byte ch = seqToUnseq[yy[0]];
|
||||
unzftab[ch] += s;
|
||||
|
||||
while (s > 0) {
|
||||
last++;
|
||||
ll8[last] = ch;
|
||||
s--;
|
||||
}
|
||||
|
||||
if (last >= limitLast) {
|
||||
BlockOverrun();
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
last++;
|
||||
if (last >= limitLast) {
|
||||
BlockOverrun();
|
||||
}
|
||||
|
||||
byte tmp = yy[nextSym - 1];
|
||||
unzftab[seqToUnseq[tmp]]++;
|
||||
ll8[last] = seqToUnseq[tmp];
|
||||
|
||||
for (int j = nextSym-1; j > 0; --j) {
|
||||
yy[j] = yy[j - 1];
|
||||
}
|
||||
yy[0] = tmp;
|
||||
|
||||
if (groupPos == 0) {
|
||||
groupNo++;
|
||||
groupPos = BZip2Constants.G_SIZE;
|
||||
}
|
||||
|
||||
groupPos--;
|
||||
zt = selector[groupNo];
|
||||
zn = minLens[zt];
|
||||
zvec = BsR(zn);
|
||||
while (zvec > limit[zt][zn]) {
|
||||
zn++;
|
||||
while (bsLive < 1) {
|
||||
FillBuffer();
|
||||
}
|
||||
zj = (bsBuff >> (bsLive-1)) & 1;
|
||||
bsLive--;
|
||||
zvec = (zvec << 1) | zj;
|
||||
}
|
||||
nextSym = perm[zt][zvec - baseArray[zt][zn]];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetupBlock()
|
||||
{
|
||||
int[] cftab = new int[257];
|
||||
|
||||
cftab[0] = 0;
|
||||
Array.Copy(unzftab, 0, cftab, 1, 256);
|
||||
|
||||
for (int i = 1; i <= 256; i++) {
|
||||
cftab[i] += cftab[i - 1];
|
||||
}
|
||||
|
||||
for (int i = 0; i <= last; i++) {
|
||||
byte ch = ll8[i];
|
||||
tt[cftab[ch]] = i;
|
||||
cftab[ch]++;
|
||||
}
|
||||
|
||||
cftab = null;
|
||||
|
||||
tPos = tt[origPtr];
|
||||
|
||||
count = 0;
|
||||
i2 = 0;
|
||||
ch2 = 256; /*-- not a char and not EOF --*/
|
||||
|
||||
if (blockRandomised) {
|
||||
rNToGo = 0;
|
||||
rTPos = 0;
|
||||
SetupRandPartA();
|
||||
} else {
|
||||
SetupNoRandPartA();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupRandPartA()
|
||||
{
|
||||
if(i2 <= last) {
|
||||
chPrev = ch2;
|
||||
ch2 = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
if (rNToGo == 0) {
|
||||
rNToGo = BZip2Constants.rNums[rTPos];
|
||||
rTPos++;
|
||||
if(rTPos == 512) {
|
||||
rTPos = 0;
|
||||
}
|
||||
}
|
||||
rNToGo--;
|
||||
ch2 ^= (int)((rNToGo == 1) ? 1 : 0);
|
||||
i2++;
|
||||
|
||||
currentChar = ch2;
|
||||
currentState = RAND_PART_B_STATE;
|
||||
mCrc.Update(ch2);
|
||||
} else {
|
||||
EndBlock();
|
||||
InitBlock();
|
||||
SetupBlock();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupNoRandPartA()
|
||||
{
|
||||
if (i2 <= last) {
|
||||
chPrev = ch2;
|
||||
ch2 = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
i2++;
|
||||
|
||||
currentChar = ch2;
|
||||
currentState = NO_RAND_PART_B_STATE;
|
||||
mCrc.Update(ch2);
|
||||
} else {
|
||||
EndBlock();
|
||||
InitBlock();
|
||||
SetupBlock();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupRandPartB()
|
||||
{
|
||||
if (ch2 != chPrev) {
|
||||
currentState = RAND_PART_A_STATE;
|
||||
count = 1;
|
||||
SetupRandPartA();
|
||||
} else {
|
||||
count++;
|
||||
if (count >= 4) {
|
||||
z = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
if (rNToGo == 0) {
|
||||
rNToGo = BZip2Constants.rNums[rTPos];
|
||||
rTPos++;
|
||||
if (rTPos == 512) {
|
||||
rTPos = 0;
|
||||
}
|
||||
}
|
||||
rNToGo--;
|
||||
z ^= (byte)((rNToGo == 1) ? 1 : 0);
|
||||
j2 = 0;
|
||||
currentState = RAND_PART_C_STATE;
|
||||
SetupRandPartC();
|
||||
} else {
|
||||
currentState = RAND_PART_A_STATE;
|
||||
SetupRandPartA();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetupRandPartC()
|
||||
{
|
||||
if (j2 < (int)z) {
|
||||
currentChar = ch2;
|
||||
mCrc.Update(ch2);
|
||||
j2++;
|
||||
} else {
|
||||
currentState = RAND_PART_A_STATE;
|
||||
i2++;
|
||||
count = 0;
|
||||
SetupRandPartA();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupNoRandPartB()
|
||||
{
|
||||
if (ch2 != chPrev) {
|
||||
currentState = NO_RAND_PART_A_STATE;
|
||||
count = 1;
|
||||
SetupNoRandPartA();
|
||||
} else {
|
||||
count++;
|
||||
if (count >= 4) {
|
||||
z = ll8[tPos];
|
||||
tPos = tt[tPos];
|
||||
currentState = NO_RAND_PART_C_STATE;
|
||||
j2 = 0;
|
||||
SetupNoRandPartC();
|
||||
} else {
|
||||
currentState = NO_RAND_PART_A_STATE;
|
||||
SetupNoRandPartA();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetupNoRandPartC()
|
||||
{
|
||||
if (j2 < (int)z) {
|
||||
currentChar = ch2;
|
||||
mCrc.Update(ch2);
|
||||
j2++;
|
||||
} else {
|
||||
currentState = NO_RAND_PART_A_STATE;
|
||||
i2++;
|
||||
count = 0;
|
||||
SetupNoRandPartA();
|
||||
}
|
||||
}
|
||||
|
||||
void SetDecompressStructureSizes(int newSize100k)
|
||||
{
|
||||
if (!(0 <= newSize100k && newSize100k <= 9 &&
|
||||
0 <= blockSize100k && blockSize100k <= 9)) {
|
||||
throw new ApplicationException("Invalid block size");
|
||||
}
|
||||
|
||||
blockSize100k = newSize100k;
|
||||
|
||||
if (newSize100k == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int n = BZip2Constants.baseBlockSize * newSize100k;
|
||||
ll8 = new byte[n];
|
||||
tt = new int[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
/* This file was derived from a file containing under this license:
|
||||
*
|
||||
* This file is a part of bzip2 and/or libbzip2, a program and
|
||||
* library for lossless, block-sorting data compression.
|
||||
*
|
||||
* Copyright (C) 1996-1998 Julian R Seward. 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. The origin of this software must not be misrepresented; you must
|
||||
* not claim that you wrote the original software. If you use this
|
||||
* software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 3. Altered source versions must be plainly marked as such, and must
|
||||
* not be misrepresented as being the original software.
|
||||
*
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* Java version ported by Keiron Liddle, Aftex Software <[email protected]> 1999-2001
|
||||
*/
|
||||
+1746
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,199 @@
|
||||
// Adler32.cs - Computes Adler32 data checksum of a data stream
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 1999, 2000, 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Computes Adler32 checksum for a stream of data. An Adler32
|
||||
/// checksum is not as reliable as a CRC32 checksum, but a lot faster to
|
||||
/// compute.
|
||||
///
|
||||
/// The specification for Adler32 may be found in RFC 1950.
|
||||
/// ZLIB Compressed Data Format Specification version 3.3)
|
||||
///
|
||||
///
|
||||
/// From that document:
|
||||
///
|
||||
/// "ADLER32 (Adler-32 checksum)
|
||||
/// This contains a checksum value of the uncompressed data
|
||||
/// (excluding any dictionary data) computed according to Adler-32
|
||||
/// algorithm. This algorithm is a 32-bit extension and improvement
|
||||
/// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073
|
||||
/// standard.
|
||||
///
|
||||
/// Adler-32 is composed of two sums accumulated per byte: s1 is
|
||||
/// the sum of all bytes, s2 is the sum of all s1 values. Both sums
|
||||
/// are done modulo 65521. s1 is initialized to 1, s2 to zero. The
|
||||
/// Adler-32 checksum is stored as s2*65536 + s1 in most-
|
||||
/// significant-byte first (network) order."
|
||||
///
|
||||
/// "8.2. The Adler-32 algorithm
|
||||
///
|
||||
/// The Adler-32 algorithm is much faster than the CRC32 algorithm yet
|
||||
/// still provides an extremely low probability of undetected errors.
|
||||
///
|
||||
/// The modulo on unsigned long accumulators can be delayed for 5552
|
||||
/// bytes, so the modulo operation time is negligible. If the bytes
|
||||
/// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position
|
||||
/// and order sensitive, unlike the first sum, which is just a
|
||||
/// checksum. That 65521 is prime is important to avoid a possible
|
||||
/// large class of two-byte errors that leave the check unchanged.
|
||||
/// (The Fletcher checksum uses 255, which is not prime and which also
|
||||
/// makes the Fletcher check insensitive to single byte changes 0 -
|
||||
/// 255.)
|
||||
///
|
||||
/// The sum s1 is initialized to 1 instead of zero to make the length
|
||||
/// of the sequence part of s2, so that the length does not have to be
|
||||
/// checked separately. (Any sequence of zeroes has a Fletcher
|
||||
/// checksum of zero.)"
|
||||
/// </summary>
|
||||
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream"/>
|
||||
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream"/>
|
||||
public sealed class Adler32 : IChecksum
|
||||
{
|
||||
/// <summary>
|
||||
/// largest prime smaller than 65536
|
||||
/// </summary>
|
||||
readonly static uint BASE = 65521;
|
||||
|
||||
uint checksum;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Adler32 data checksum computed so far.
|
||||
/// </summary>
|
||||
public long Value {
|
||||
get {
|
||||
return checksum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <code>Adler32</code> class.
|
||||
/// The checksum starts off with a value of 1.
|
||||
/// </summary>
|
||||
public Adler32()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the Adler32 checksum to the initial value.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
checksum = 1; //Initialize to 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the checksum with the byte b.
|
||||
/// </summary>
|
||||
/// <param name="bval">
|
||||
/// the data value to add. The high byte of the int is ignored.
|
||||
/// </param>
|
||||
public void Update(int bval)
|
||||
{
|
||||
//We could make a length 1 byte array and call update again, but I
|
||||
//would rather not have that overhead
|
||||
uint s1 = checksum & 0xFFFF;
|
||||
uint s2 = checksum >> 16;
|
||||
|
||||
s1 = (s1 + ((uint)bval & 0xFF)) % BASE;
|
||||
s2 = (s1 + s2) % BASE;
|
||||
|
||||
checksum = (s2 << 16) + s1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the checksum with the bytes taken from the array.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// buffer an array of bytes
|
||||
/// </param>
|
||||
public void Update(byte[] buffer)
|
||||
{
|
||||
Update(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the checksum with the bytes taken from the array.
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// an array of bytes
|
||||
/// </param>
|
||||
/// <param name="off">
|
||||
/// the start of the data used for this update
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the number of bytes to use for this update
|
||||
/// </param>
|
||||
public void Update(byte[] buf, int off, int len)
|
||||
{
|
||||
if (buf == null) {
|
||||
throw new ArgumentNullException("buf");
|
||||
}
|
||||
|
||||
if (off < 0 || len < 0 || off + len > buf.Length) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
//(By Per Bothner)
|
||||
uint s1 = checksum & 0xFFFF;
|
||||
uint s2 = checksum >> 16;
|
||||
|
||||
while (len > 0) {
|
||||
// We can defer the modulo operation:
|
||||
// s1 maximally grows from 65521 to 65521 + 255 * 3800
|
||||
// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
|
||||
int n = 3800;
|
||||
if (n > len) {
|
||||
n = len;
|
||||
}
|
||||
len -= n;
|
||||
while (--n >= 0) {
|
||||
s1 = s1 + (uint)(buf[off++] & 0xFF);
|
||||
s2 = s2 + s1;
|
||||
}
|
||||
s1 %= BASE;
|
||||
s2 %= BASE;
|
||||
}
|
||||
|
||||
checksum = (s2 << 16) | s1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
// CRC32.cs - Computes CRC32 data checksum of a data stream
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 1999, 2000, 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
|
||||
/// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
|
||||
///
|
||||
/// Polynomials over GF(2) are represented in binary, one bit per coefficient,
|
||||
/// with the lowest powers in the most significant bit. Then adding polynomials
|
||||
/// is just exclusive-or, and multiplying a polynomial by x is a right shift by
|
||||
/// one. If we call the above polynomial p, and represent a byte as the
|
||||
/// polynomial q, also with the lowest power in the most significant bit (so the
|
||||
/// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
|
||||
/// where a mod b means the remainder after dividing a by b.
|
||||
///
|
||||
/// This calculation is done using the shift-register method of multiplying and
|
||||
/// taking the remainder. The register is initialized to zero, and for each
|
||||
/// incoming bit, x^32 is added mod p to the register if the bit is a one (where
|
||||
/// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
|
||||
/// x (which is shifting right by one and adding x^32 mod p if the bit shifted
|
||||
/// out is a one). We start with the highest power (least significant bit) of
|
||||
/// q and repeat for all eight bits of q.
|
||||
///
|
||||
/// The table is simply the CRC of all possible eight bit values. This is all
|
||||
/// the information needed to generate CRC's on data a byte at a time for all
|
||||
/// combinations of CRC register values and incoming bytes.
|
||||
/// </summary>
|
||||
public sealed class Crc32 : IChecksum
|
||||
{
|
||||
readonly static uint CrcSeed = 0xFFFFFFFF;
|
||||
|
||||
readonly static uint[] CrcTable = new uint[] {
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419,
|
||||
0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4,
|
||||
0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07,
|
||||
0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856,
|
||||
0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
|
||||
0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4,
|
||||
0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3,
|
||||
0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A,
|
||||
0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599,
|
||||
0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190,
|
||||
0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
|
||||
0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E,
|
||||
0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED,
|
||||
0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
|
||||
0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3,
|
||||
0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A,
|
||||
0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5,
|
||||
0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010,
|
||||
0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17,
|
||||
0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6,
|
||||
0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615,
|
||||
0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344,
|
||||
0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
|
||||
0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A,
|
||||
0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1,
|
||||
0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C,
|
||||
0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF,
|
||||
0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE,
|
||||
0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31,
|
||||
0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C,
|
||||
0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B,
|
||||
0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
|
||||
0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1,
|
||||
0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278,
|
||||
0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7,
|
||||
0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66,
|
||||
0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605,
|
||||
0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8,
|
||||
0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B,
|
||||
0x2D02EF8D
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The crc data checksum so far.
|
||||
/// </summary>
|
||||
uint crc = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the CRC32 data checksum computed so far.
|
||||
/// </summary>
|
||||
public long Value {
|
||||
get {
|
||||
return (long)crc;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the CRC32 data checksum as if no update was ever called.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
crc = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the checksum with the int bval.
|
||||
/// </summary>
|
||||
/// <param name = "bval">
|
||||
/// the byte is taken as the lower 8 bits of bval
|
||||
/// </param>
|
||||
public void Update(int bval)
|
||||
{
|
||||
crc ^= CrcSeed;
|
||||
crc = CrcTable[(crc ^ bval) & 0xFF] ^ (crc >> 8);
|
||||
crc ^= CrcSeed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the checksum with the bytes taken from the array.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// buffer an array of bytes
|
||||
/// </param>
|
||||
public void Update(byte[] buffer)
|
||||
{
|
||||
Update(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the byte array to the data checksum.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// the buffer which contains the data
|
||||
/// </param>
|
||||
/// <param name = "off">
|
||||
/// the offset in the buffer where the data starts
|
||||
/// </param>
|
||||
/// <param name = "len">
|
||||
/// the length of the data
|
||||
/// </param>
|
||||
public void Update(byte[] buf, int off, int len)
|
||||
{
|
||||
if (buf == null) {
|
||||
throw new ArgumentNullException("buf");
|
||||
}
|
||||
|
||||
if (off < 0 || len < 0 || off + len > buf.Length) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
crc ^= CrcSeed;
|
||||
|
||||
while (--len >= 0) {
|
||||
crc = CrcTable[(crc ^ buf[off++]) & 0xFF] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
crc ^= CrcSeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// IChecksum.cs - Interface to compute a data checksum
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 1999, 2000, 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
/// <summary>
|
||||
/// Interface to compute a data checksum used by checked input/output streams.
|
||||
/// A data checksum can be updated by one byte or with a byte array. After each
|
||||
/// update the value of the current checksum can be returned by calling
|
||||
/// <code>getValue</code>. The complete checksum object can also be reset
|
||||
/// so it can be used again with new data.
|
||||
/// </summary>
|
||||
public interface IChecksum
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the data checksum computed so far.
|
||||
/// </summary>
|
||||
long Value {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the data checksum as if no update was ever called.
|
||||
/// </summary>
|
||||
void Reset();
|
||||
|
||||
/// <summary>
|
||||
/// Adds one byte to the data checksum.
|
||||
/// </summary>
|
||||
/// <param name = "bval">
|
||||
/// the data value to add. The high byte of the int is ignored.
|
||||
/// </param>
|
||||
void Update(int bval);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the data checksum with the bytes taken from the array.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// buffer an array of bytes
|
||||
/// </param>
|
||||
void Update(byte[] buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the byte array to the data checksum.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// the buffer which contains the data
|
||||
/// </param>
|
||||
/// <param name = "off">
|
||||
/// the offset in the buffer where the data starts
|
||||
/// </param>
|
||||
/// <param name = "len">
|
||||
/// the length of the data
|
||||
/// </param>
|
||||
void Update(byte[] buf, int off, int len);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// StrangeCRC.cs - computes a crc used in the bziplib ... I don't think that
|
||||
// this is the 'standard' crc, please correct me, if I'm wrong
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 1999, 2000, 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Checksums {
|
||||
|
||||
public class StrangeCRC : IChecksum
|
||||
{
|
||||
readonly static uint[] crc32Table = {
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
||||
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
||||
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
|
||||
0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
||||
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
|
||||
0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
||||
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
||||
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
||||
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81,
|
||||
0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
||||
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49,
|
||||
0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
||||
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
|
||||
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
||||
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae,
|
||||
0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
||||
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
|
||||
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
||||
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
|
||||
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
||||
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066,
|
||||
0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
||||
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
|
||||
0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
||||
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
|
||||
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
||||
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
|
||||
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
||||
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686,
|
||||
0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
||||
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
|
||||
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
||||
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
|
||||
0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
||||
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
|
||||
0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
||||
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
||||
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
||||
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
|
||||
0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
||||
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
|
||||
0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
||||
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
|
||||
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
||||
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
|
||||
0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
||||
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
|
||||
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
||||
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
|
||||
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
||||
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
|
||||
0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
||||
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
|
||||
0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
||||
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
|
||||
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
||||
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
||||
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
||||
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
|
||||
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
||||
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
||||
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
||||
};
|
||||
int globalCrc;
|
||||
|
||||
public StrangeCRC()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
globalCrc = -1;
|
||||
}
|
||||
|
||||
public long Value {
|
||||
get {
|
||||
return ~globalCrc;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(int inCh)
|
||||
{
|
||||
int temp = (globalCrc >> 24) ^ inCh;
|
||||
if (temp < 0) {
|
||||
temp = 256 + temp;
|
||||
}
|
||||
globalCrc = (int)((globalCrc << 8) ^ crc32Table[temp]);
|
||||
}
|
||||
|
||||
public void Update(byte[] buf)
|
||||
{
|
||||
Update(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
public void Update(byte[] buf, int off, int len)
|
||||
{
|
||||
if (buf == null) {
|
||||
throw new ArgumentNullException("buf");
|
||||
}
|
||||
|
||||
if (off < 0 || len < 0 || off + len > buf.Length) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Update(buf[off++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// GZIPConstants.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for gzip.
|
||||
/// </summary>
|
||||
public class GZipConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// Magic number found at start of GZIP header
|
||||
/// </summary>
|
||||
public static readonly int GZIP_MAGIC = 0x1F8B;
|
||||
|
||||
/* The flag byte is divided into individual bits as follows:
|
||||
|
||||
bit 0 FTEXT
|
||||
bit 1 FHCRC
|
||||
bit 2 FEXTRA
|
||||
bit 3 FNAME
|
||||
bit 4 FCOMMENT
|
||||
bit 5 reserved
|
||||
bit 6 reserved
|
||||
bit 7 reserved
|
||||
*/
|
||||
public const int FTEXT = 0x1;
|
||||
public const int FHCRC = 0x2;
|
||||
public const int FEXTRA = 0x4;
|
||||
public const int FNAME = 0x8;
|
||||
public const int FCOMMENT = 0x10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
// GzipInputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to decompress a "GZIP" format stream.
|
||||
/// The "GZIP" format is described baseInputStream RFC 1952.
|
||||
///
|
||||
/// author of the original java version : John Leuner
|
||||
/// </summary>
|
||||
/// <example> This sample shows how to unzip a gzipped file
|
||||
/// <code>
|
||||
/// using System;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.GZip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
/// public static void Main(string[] args)
|
||||
/// {
|
||||
/// Stream s = new GZipInputStream(File.OpenRead(args[0]));
|
||||
/// FileStream fs = File.Create(Path.GetFileNameWithoutExtension(args[0]));
|
||||
/// int size = 2048;
|
||||
/// byte[] writeData = new byte[2048];
|
||||
/// while (true) {
|
||||
/// size = s.Read(writeData, 0, size);
|
||||
/// if (size > 0) {
|
||||
/// fs.Write(writeData, 0, size);
|
||||
/// } else {
|
||||
/// break;
|
||||
/// }
|
||||
/// }
|
||||
/// s.Close();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class GZipInputStream : InflaterInputStream
|
||||
{
|
||||
|
||||
//Variables
|
||||
|
||||
/// <summary>
|
||||
/// CRC-32 value for uncompressed data
|
||||
/// </summary>
|
||||
protected Crc32 crc = new Crc32();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates end of stream
|
||||
/// </summary>
|
||||
protected bool eos;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GzipInputStream with the default buffer size
|
||||
/// </summary>
|
||||
/// <param name="baseInputStream">
|
||||
/// The stream to read compressed data from (baseInputStream GZIP format)
|
||||
/// </param>
|
||||
public GZipInputStream(Stream baseInputStream) : this(baseInputStream, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GZIPInputStream with the specified buffer size
|
||||
/// </summary>
|
||||
/// <param name="baseInputStream">
|
||||
/// The stream to read compressed data from (baseInputStream GZIP format)
|
||||
/// </param>
|
||||
/// <param name="size">
|
||||
/// Size of the buffer to use
|
||||
/// </param>
|
||||
public GZipInputStream(Stream baseInputStream, int size) : base(baseInputStream, new Inflater(true), size)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads uncompressed data into an array of bytes
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// the buffer to read uncompressed data into
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// the offset indicating where the data should be placed
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the number of uncompressed bytes to be read
|
||||
/// </param>
|
||||
public override int Read(byte[] buf, int offset, int len)
|
||||
{
|
||||
// We first have to slurp baseInputStream the GZIP header, then we feed all the
|
||||
// rest of the data to the superclass.
|
||||
//
|
||||
// As we do that we continually update the CRC32. Once the data is
|
||||
// finished, we check the CRC32
|
||||
//
|
||||
// This means we don't need our own buffer, as everything is done
|
||||
// baseInputStream the superclass.
|
||||
if (!readGZIPHeader) {
|
||||
ReadHeader();
|
||||
}
|
||||
|
||||
if (eos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// System.err.println("GZIPIS.read(byte[], off, len ... " + offset + " and len " + len);
|
||||
//We don't have to read the header, so we just grab data from the superclass
|
||||
int numRead = base.Read(buf, offset, len);
|
||||
if (numRead > 0) {
|
||||
crc.Update(buf, offset, numRead);
|
||||
}
|
||||
|
||||
if (inf.IsFinished) {
|
||||
ReadFooter();
|
||||
}
|
||||
return numRead;
|
||||
}
|
||||
|
||||
private void ReadHeader()
|
||||
{
|
||||
/* 1. Check the two magic bytes */
|
||||
Crc32 headCRC = new Crc32();
|
||||
int magic = baseInputStream.ReadByte();
|
||||
if (magic < 0) {
|
||||
eos = true;
|
||||
return;
|
||||
}
|
||||
headCRC.Update(magic);
|
||||
if (magic != (GZipConstants.GZIP_MAGIC >> 8)) {
|
||||
throw new IOException("Error baseInputStream GZIP header, first byte doesn't match");
|
||||
}
|
||||
|
||||
magic = baseInputStream.ReadByte();
|
||||
if (magic != (GZipConstants.GZIP_MAGIC & 0xFF)) {
|
||||
throw new IOException("Error baseInputStream GZIP header, second byte doesn't match");
|
||||
}
|
||||
headCRC.Update(magic);
|
||||
|
||||
/* 2. Check the compression type (must be 8) */
|
||||
int CM = baseInputStream.ReadByte();
|
||||
if (CM != 8) {
|
||||
throw new IOException("Error baseInputStream GZIP header, data not baseInputStream deflate format");
|
||||
}
|
||||
headCRC.Update(CM);
|
||||
|
||||
/* 3. Check the flags */
|
||||
int flags = baseInputStream.ReadByte();
|
||||
if (flags < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(flags);
|
||||
|
||||
/* This flag byte is divided into individual bits as follows:
|
||||
|
||||
bit 0 FTEXT
|
||||
bit 1 FHCRC
|
||||
bit 2 FEXTRA
|
||||
bit 3 FNAME
|
||||
bit 4 FCOMMENT
|
||||
bit 5 reserved
|
||||
bit 6 reserved
|
||||
bit 7 reserved
|
||||
*/
|
||||
|
||||
/* 3.1 Check the reserved bits are zero */
|
||||
|
||||
if ((flags & 0xd0) != 0) {
|
||||
throw new IOException("Reserved flag bits baseInputStream GZIP header != 0");
|
||||
}
|
||||
|
||||
/* 4.-6. Skip the modification time, extra flags, and OS type */
|
||||
for (int i=0; i< 6; i++) {
|
||||
int readByte = baseInputStream.ReadByte();
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
|
||||
/* 7. Read extra field */
|
||||
if ((flags & GZipConstants.FEXTRA) != 0) {
|
||||
/* Skip subfield id */
|
||||
for (int i=0; i< 2; i++) {
|
||||
int readByte = baseInputStream.ReadByte();
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
if (baseInputStream.ReadByte() < 0 || baseInputStream.ReadByte() < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
|
||||
int len1, len2, extraLen;
|
||||
len1 = baseInputStream.ReadByte();
|
||||
len2 = baseInputStream.ReadByte();
|
||||
if ((len1 < 0) || (len2 < 0)) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(len1);
|
||||
headCRC.Update(len2);
|
||||
|
||||
extraLen = (len1 << 8) | len2;
|
||||
for (int i = 0; i < extraLen;i++) {
|
||||
int readByte = baseInputStream.ReadByte();
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
}
|
||||
|
||||
/* 8. Read file name */
|
||||
if ((flags & GZipConstants.FNAME) != 0) {
|
||||
int readByte;
|
||||
while ( (readByte = baseInputStream.ReadByte()) > 0) {
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP file name");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
|
||||
/* 9. Read comment */
|
||||
if ((flags & GZipConstants.FCOMMENT) != 0) {
|
||||
int readByte;
|
||||
while ( (readByte = baseInputStream.ReadByte()) > 0) {
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
|
||||
if (readByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP comment");
|
||||
}
|
||||
headCRC.Update(readByte);
|
||||
}
|
||||
|
||||
/* 10. Read header CRC */
|
||||
if ((flags & GZipConstants.FHCRC) != 0) {
|
||||
int tempByte;
|
||||
int crcval = baseInputStream.ReadByte();
|
||||
if (crcval < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
|
||||
tempByte = baseInputStream.ReadByte();
|
||||
if (tempByte < 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP header");
|
||||
}
|
||||
|
||||
crcval = (crcval << 8) | tempByte;
|
||||
if (crcval != ((int) headCRC.Value & 0xffff)) {
|
||||
throw new IOException("Header CRC value mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
readGZIPHeader = true;
|
||||
//System.err.println("Read GZIP header");
|
||||
}
|
||||
|
||||
private void ReadFooter()
|
||||
{
|
||||
byte[] footer = new byte[8];
|
||||
int avail = inf.RemainingInput;
|
||||
if (avail > 8) {
|
||||
avail = 8;
|
||||
}
|
||||
System.Array.Copy(buf, len - inf.RemainingInput, footer, 0, avail);
|
||||
int needed = 8 - avail;
|
||||
while (needed > 0) {
|
||||
int count = baseInputStream.Read(footer, 8-needed, needed);
|
||||
if (count <= 0) {
|
||||
throw new Exception("Early EOF baseInputStream GZIP footer");
|
||||
}
|
||||
needed -= count; //Jewel Jan 16
|
||||
}
|
||||
int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) | ((footer[2] & 0xff) << 16) | (footer[3] << 24);
|
||||
if (crcval != (int) crc.Value) {
|
||||
throw new IOException("GZIP crc sum mismatch, theirs \"" + crcval + "\" and ours \"" + (int) crc.Value);
|
||||
}
|
||||
int total = (footer[4] & 0xff) | ((footer[5] & 0xff) << 8) | ((footer[6] & 0xff) << 16) | (footer[7] << 24);
|
||||
if (total != inf.TotalOut) {
|
||||
throw new IOException("Number of bytes mismatch");
|
||||
}
|
||||
/* XXX Should we support multiple members.
|
||||
* Difficult, since there may be some bytes still baseInputStream buf
|
||||
*/
|
||||
eos = true;
|
||||
}
|
||||
|
||||
/* Have we read the GZIP header yet? */
|
||||
private bool readGZIPHeader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
// GzipOutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to compress a stream into a "GZIP" stream.
|
||||
/// The "GZIP" format is described in RFC 1952.
|
||||
///
|
||||
/// author of the original java version : John Leuner
|
||||
/// </summary>
|
||||
/// <example> This sample shows how to gzip a file
|
||||
/// <code>
|
||||
/// using System;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.GZip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
/// public static void Main(string[] args)
|
||||
/// {
|
||||
/// Stream s = new GZipOutputStream(File.Create(args[0] + ".gz"));
|
||||
/// FileStream fs = File.OpenRead(args[0]);
|
||||
/// byte[] writeData = new byte[fs.Length];
|
||||
/// fs.Read(writeData, 0, (int)fs.Length);
|
||||
/// s.Write(writeData, 0, writeData.Length);
|
||||
/// s.Close();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class GZipOutputStream : DeflaterOutputStream
|
||||
{
|
||||
//Variables
|
||||
|
||||
/// <summary>
|
||||
/// CRC-32 value for uncompressed data
|
||||
/// </summary>
|
||||
protected Crc32 crc = new Crc32();
|
||||
|
||||
// Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GzipOutputStream with the default buffer size
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// The stream to read data (to be compressed) from
|
||||
/// </param>
|
||||
public GZipOutputStream(Stream baseOutputStream) : this(baseOutputStream, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GZIPOutputStream with the specified buffer size
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// The stream to read data (to be compressed) from
|
||||
/// </param>
|
||||
/// <param name="size">
|
||||
/// Size of the buffer to use
|
||||
/// </param>
|
||||
public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size)
|
||||
{
|
||||
// TODO : find out correctness, orgininally this was : (int) (System.currentTimeMillis() / 1000L);
|
||||
int mod_time = (int)(DateTime.Now.Ticks / 10000L); // Ticks give back 100ns intervals
|
||||
byte[] gzipHeader = {
|
||||
/* The two magic bytes */
|
||||
(byte) (GZipConstants.GZIP_MAGIC >> 8), (byte) GZipConstants.GZIP_MAGIC,
|
||||
|
||||
/* The compression type */
|
||||
(byte) Deflater.DEFLATED,
|
||||
|
||||
/* The flags (not set) */
|
||||
0,
|
||||
|
||||
/* The modification time */
|
||||
(byte) mod_time, (byte) (mod_time >> 8),
|
||||
(byte) (mod_time >> 16), (byte) (mod_time >> 24),
|
||||
|
||||
/* The extra flags */
|
||||
0,
|
||||
|
||||
/* The OS type (unknown) */
|
||||
(byte) 255
|
||||
};
|
||||
|
||||
baseOutputStream.Write(gzipHeader, 0, gzipHeader.Length);
|
||||
// System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )");
|
||||
}
|
||||
|
||||
public override void Write(byte[] buf, int off, int len)
|
||||
{
|
||||
crc.Update(buf, off, len);
|
||||
base.Write(buf, off, len);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes remaining compressed output data to the output stream
|
||||
/// and closes it.
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
Finish();
|
||||
baseOutputStream.Close();
|
||||
}
|
||||
|
||||
public override void Finish()
|
||||
{
|
||||
base.Finish();
|
||||
|
||||
int totalin = def.TotalIn;
|
||||
int crcval = (int) (crc.Value & 0xffffffff);
|
||||
|
||||
// System.err.println("CRC val is " + Integer.toHexString( crcval ) + " and length " + Integer.toHexString(totalin));
|
||||
|
||||
byte[] gzipFooter = {
|
||||
(byte) crcval, (byte) (crcval >> 8),
|
||||
(byte) (crcval >> 16), (byte) (crcval >> 24),
|
||||
|
||||
(byte) totalin, (byte) (totalin >> 8),
|
||||
(byte) (totalin >> 16), (byte) (totalin >> 24)
|
||||
};
|
||||
|
||||
baseOutputStream.Write(gzipFooter, 0, gzipFooter.Length);
|
||||
// System.err.println("wrote GZIP trailer (" + gzipFooter.length + " bytes )");
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// BZip2OutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// This exception is used to indicate that there is a problem
|
||||
/// with a TAR archive header.
|
||||
/// </summary>
|
||||
public class InvalidHeaderException : System.IO.IOException
|
||||
{
|
||||
public InvalidHeaderException()
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidHeaderException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,693 @@
|
||||
// TarInputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
public delegate void ProgressMessageHandler(TarArchive archive, string message);
|
||||
|
||||
/// <summary>
|
||||
/// The TarArchive class implements the concept of a
|
||||
/// tar archive. A tar archive is a series of entries, each of
|
||||
/// which represents a file system object. Each entry in
|
||||
/// the archive consists of a header record. Directory entries
|
||||
/// consist only of the header record, and are followed by entries
|
||||
/// for the directory's contents. File entries consist of a
|
||||
/// header record followed by the number of records needed to
|
||||
/// contain the file's contents. All entries are written on
|
||||
/// record boundaries. Records are 512 bytes long.
|
||||
///
|
||||
/// TarArchives are instantiated in either read or write mode,
|
||||
/// based upon whether they are instantiated with an InputStream
|
||||
/// or an OutputStream. Once instantiated TarArchives read/write
|
||||
/// mode can not be changed.
|
||||
///
|
||||
/// There is currently no support for random access to tar archives.
|
||||
/// However, it seems that subclassing TarArchive, and using the
|
||||
/// TarBuffer.getCurrentRecordNum() and TarBuffer.getCurrentBlockNum()
|
||||
/// methods, this would be rather trvial.
|
||||
/// </summary>
|
||||
public class TarArchive
|
||||
{
|
||||
protected bool verbose;
|
||||
protected bool debug;
|
||||
protected bool keepOldFiles;
|
||||
protected bool asciiTranslate;
|
||||
|
||||
protected int userId;
|
||||
protected string userName;
|
||||
protected int groupId;
|
||||
protected string groupName;
|
||||
|
||||
protected string rootPath;
|
||||
protected string pathPrefix;
|
||||
|
||||
protected int recordSize;
|
||||
protected byte[] recordBuf;
|
||||
|
||||
protected TarInputStream tarIn;
|
||||
protected TarOutputStream tarOut;
|
||||
|
||||
public event ProgressMessageHandler ProgressMessageEvent;
|
||||
|
||||
protected virtual void OnProgressMessageEvent(string message)
|
||||
{
|
||||
if (ProgressMessageEvent != null) {
|
||||
ProgressMessageEvent(this, message);
|
||||
}
|
||||
}
|
||||
|
||||
protected TarArchive()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The InputStream based constructors create a TarArchive for the
|
||||
/// purposes of e'x'tracting or lis't'ing a tar archive. Thus, use
|
||||
/// these constructors when you wish to extract files from or list
|
||||
/// the contents of an existing tar archive.
|
||||
/// </summary>
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarArchive(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockSize)
|
||||
{
|
||||
return CreateInputTarArchive(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateInputTarArchive(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarIn = new TarInputStream(inputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The OutputStream based constructors create a TarArchive for the
|
||||
/// purposes of 'c'reating a tar archive. Thus, use these constructors
|
||||
/// when you wish to create a new tar archive and write files into it.
|
||||
/// </summary>
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarArchive(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockSize)
|
||||
{
|
||||
return CreateOutputTarArchive(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
|
||||
public static TarArchive CreateOutputTarArchive(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarArchive archive = new TarArchive();
|
||||
archive.tarOut = new TarOutputStream(outputStream, blockSize, recordSize);
|
||||
archive.Initialize(recordSize);
|
||||
return archive;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Common constructor initialization code.
|
||||
/// </summary>
|
||||
void Initialize(int recordSize)
|
||||
{
|
||||
this.rootPath = null;
|
||||
this.pathPrefix = null;
|
||||
|
||||
// this.tempPath = System.getProperty( "user.dir" );
|
||||
|
||||
this.userId = 0;
|
||||
this.userName = String.Empty;
|
||||
this.groupId = 0;
|
||||
this.groupName = String.Empty;
|
||||
|
||||
this.debug = false;
|
||||
this.verbose = false;
|
||||
this.keepOldFiles = false;
|
||||
|
||||
this.recordBuf = new byte[RecordSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the debugging flag.
|
||||
*
|
||||
* @param debugF The new debug setting.
|
||||
*/
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugF;
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.SetDebug(debugF);
|
||||
}
|
||||
if (this.tarOut != null) {
|
||||
this.tarOut.SetDebug(debugF);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set the verbosity setting.
|
||||
/// </summary>
|
||||
public bool IsVerbose {
|
||||
get {
|
||||
return verbose;
|
||||
}
|
||||
set {
|
||||
verbose = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the flag that determines whether existing files are
|
||||
/// kept, or overwritten during extraction.
|
||||
/// </summary>
|
||||
/// <param name="keepOldFiles">
|
||||
/// If true, do not overwrite existing files.
|
||||
/// </param>
|
||||
public void SetKeepOldFiles(bool keepOldFiles)
|
||||
{
|
||||
this.keepOldFiles = keepOldFiles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the ascii file translation flag. If ascii file translatio
|
||||
/// is true, then the MIME file type will be consulted to determine
|
||||
/// if the file is of type 'text/*'. If the MIME type is not found,
|
||||
/// then the TransFileTyper is consulted if it is not null. If
|
||||
/// either of these two checks indicates the file is an ascii text
|
||||
/// file, it will be translated. The translation converts the local
|
||||
/// operating system's concept of line ends into the UNIX line end,
|
||||
/// '\n', which is the defacto standard for a TAR archive. This makes
|
||||
/// text files compatible with UNIX, and since most tar implementations
|
||||
/// text files compatible with UNIX, and since most tar implementations
|
||||
/// </summary>
|
||||
/// <param name= "asciiTranslate">
|
||||
/// If true, translate ascii text files.
|
||||
/// </param>
|
||||
public void SetAsciiTranslation(bool asciiTranslate)
|
||||
{
|
||||
this.asciiTranslate = asciiTranslate;
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Set the object that will determine if a file is of type
|
||||
/// ascii text for translation purposes.
|
||||
/// </summary>
|
||||
/// <param name="transTyper">
|
||||
/// The new TransFileTyper object.
|
||||
/// </param>
|
||||
public void SetTransFileTyper(TarTransFileTyper transTyper)
|
||||
{
|
||||
this.transTyper = transTyper;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Set user and group information that will be used to fill in the
|
||||
/// tar archive's entry headers. Since Java currently provides no means
|
||||
/// of determining a user name, user id, group name, or group id for
|
||||
/// a given File, TarArchive allows the programmer to specify values
|
||||
/// to be used in their place.
|
||||
/// </summary>
|
||||
/// <param name="userId">
|
||||
/// The user Id to use in the headers.
|
||||
/// </param>
|
||||
/// <param name="userName">
|
||||
/// The user name to use in the headers.
|
||||
/// </param>
|
||||
/// <param name="groupId">
|
||||
/// The group id to use in the headers.
|
||||
/// </param>
|
||||
/// <param name="groupName">
|
||||
/// The group name to use in the headers.
|
||||
/// </param>
|
||||
public void SetUserInfo(int userId, string userName, int groupId, string groupName)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.userName = userName;
|
||||
this.groupId = groupId;
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the user id being used for archive entry headers.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current user id.
|
||||
/// </returns>
|
||||
public int UserId {
|
||||
get {
|
||||
return this.userId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the user name being used for archive entry headers.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current user name.
|
||||
/// </returns>
|
||||
public string UserName {
|
||||
get {
|
||||
return this.userName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the group id being used for archive entry headers.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current group id.
|
||||
/// </returns>
|
||||
public int GroupId {
|
||||
get {
|
||||
return this.groupId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the group name being used for archive entry headers.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current group name.
|
||||
/// </returns>
|
||||
public string GroupName {
|
||||
get {
|
||||
return this.groupName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the archive's record size. Because of its history, tar
|
||||
/// supports the concept of buffered IO consisting of BLOCKS of
|
||||
/// RECORDS. This allowed tar to match the IO characteristics of
|
||||
/// the physical device being used. Of course, in the Java world,
|
||||
/// this makes no sense, WITH ONE EXCEPTION - archives are expected
|
||||
/// to be propertly "blocked". Thus, all of the horrible TarBuffer
|
||||
/// support boils down to simply getting the "boundaries" correct.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The record size this archive is using.
|
||||
/// </returns>
|
||||
public int RecordSize {
|
||||
get {
|
||||
if (this.tarIn != null) {
|
||||
return this.tarIn.GetRecordSize();
|
||||
} else if (this.tarOut != null) {
|
||||
return this.tarOut.GetRecordSize();
|
||||
}
|
||||
return TarBuffer.DEFAULT_RCDSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the archive. This simply calls the underlying
|
||||
/// tar stream's close() method.
|
||||
/// </summary>
|
||||
public void CloseArchive()
|
||||
{
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.Close();
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.Flush();
|
||||
this.tarOut.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform the "list" command and list the contents of the archive.
|
||||
///
|
||||
/// NOTE That this method uses the progress display to actually list
|
||||
/// the conents. If the progress display is not set, nothing will be
|
||||
/// listed!
|
||||
/// </summary>
|
||||
public void ListContents()
|
||||
{
|
||||
while (true) {
|
||||
TarEntry entry = this.tarIn.GetNextEntry();
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
}
|
||||
break;
|
||||
}
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform the "extract" command and extract the contents of the archive.
|
||||
/// </summary>
|
||||
/// <param name="destDir">
|
||||
/// The destination directory into which to extract.
|
||||
/// </param>
|
||||
public void ExtractContents(string destDir)
|
||||
{
|
||||
while (true) {
|
||||
TarEntry entry = this.tarIn.GetNextEntry();
|
||||
|
||||
if (entry == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ EOF RECORD");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.ExtractEntry(destDir, entry);
|
||||
}
|
||||
}
|
||||
|
||||
void EnsureDirectoryExists(string directoryName)
|
||||
{
|
||||
if (!Directory.Exists(directoryName)) {
|
||||
try {
|
||||
Directory.CreateDirectory(directoryName);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("error making directory path '" + directoryName + "', " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsBinary(string filename)
|
||||
{
|
||||
FileStream fs = File.OpenRead(filename);
|
||||
|
||||
byte[] content = new byte[fs.Length];
|
||||
|
||||
fs.Read(content, 0, (int)fs.Length);
|
||||
fs.Close();
|
||||
|
||||
// assume that ascii 0 or
|
||||
// ascii 255 are only found in non text files.
|
||||
// and that all non text files contain 0 and 255
|
||||
foreach (byte b in content) {
|
||||
if (b == 0 || b == 255) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract an entry from the archive. This method assumes that the
|
||||
/// tarIn stream has been properly set with a call to getNextEntry().
|
||||
/// </summary>
|
||||
/// <param name="destDir">
|
||||
/// The destination directory into which to extract.
|
||||
/// </param>
|
||||
/// <param name="entry">
|
||||
/// The TarEntry returned by tarIn.getNextEntry().
|
||||
/// </param>
|
||||
void ExtractEntry(string destDir, TarEntry entry)
|
||||
{
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
|
||||
string name = entry.Name;
|
||||
name = name.Replace('/', Path.DirectorySeparatorChar);
|
||||
|
||||
if (!destDir.EndsWith(Path.DirectorySeparatorChar.ToString())) {
|
||||
destDir += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
string destFile = destDir + name;
|
||||
|
||||
if (entry.IsDirectory) {
|
||||
EnsureDirectoryExists(destFile);
|
||||
} else {
|
||||
string parentDirectory = Path.GetDirectoryName(destFile);
|
||||
EnsureDirectoryExists(parentDirectory);
|
||||
|
||||
if (this.keepOldFiles && File.Exists(destFile)) {
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent("not overwriting " + entry.Name);
|
||||
}
|
||||
} else {
|
||||
bool asciiTrans = false;
|
||||
Stream outputStream = File.Create(destFile);
|
||||
if (this.asciiTranslate) {
|
||||
asciiTrans = !IsBinary(destFile);
|
||||
// original java sourcecode :
|
||||
// MimeType mime = null;
|
||||
// string contentType = null;
|
||||
// try {
|
||||
// contentType = FileTypeMap.getDefaultFileTypeMap().getContentType( destFile );
|
||||
//
|
||||
// mime = new MimeType(contentType);
|
||||
//
|
||||
// if (mime.getPrimaryType().equalsIgnoreCase( "text" )) {
|
||||
// asciiTrans = true;
|
||||
// } else if ( this.transTyper != null ) {
|
||||
// if ( this.transTyper.isAsciiFile( entry.getName() ) ) {
|
||||
// asciiTrans = true;
|
||||
// }
|
||||
// }
|
||||
// } catch (MimeTypeParseException ex) {
|
||||
// }
|
||||
//
|
||||
// if (this.debug) {
|
||||
// Console.Error.WriteLine(("EXTRACT TRANS? '" + asciiTrans + "' ContentType='" + contentType + "' PrimaryType='" + mime.getPrimaryType() + "'" );
|
||||
// }
|
||||
}
|
||||
|
||||
StreamWriter outw = null;
|
||||
if (asciiTrans) {
|
||||
outw = new StreamWriter(outputStream);
|
||||
}
|
||||
|
||||
byte[] rdbuf = new byte[32 * 1024];
|
||||
|
||||
while (true) {
|
||||
int numRead = this.tarIn.Read(rdbuf, 0, rdbuf.Length);
|
||||
|
||||
if (numRead <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (asciiTrans) {
|
||||
for (int off = 0, b = 0; b < numRead; ++b) {
|
||||
if (rdbuf[b] == 10) {
|
||||
string s = Encoding.ASCII.GetString(rdbuf, off, (b - off));
|
||||
outw.WriteLine(s);
|
||||
off = b + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
outputStream.Write(rdbuf, 0, numRead);
|
||||
}
|
||||
}
|
||||
|
||||
if (asciiTrans) {
|
||||
outw.Close();
|
||||
} else {
|
||||
outputStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an entry to the archive. This method will call the putNextEntry
|
||||
/// and then write the contents of the entry, and finally call closeEntry()()
|
||||
/// for entries that are files. For directories, it will call putNextEntry(),
|
||||
/// and then, if the recurse flag is true, process each entry that is a
|
||||
/// child of the directory.
|
||||
/// </summary>
|
||||
/// <param name="entry">
|
||||
/// The TarEntry representing the entry to write to the archive.
|
||||
/// </param>
|
||||
/// <param name="recurse">
|
||||
/// If true, process the children of directory entries.
|
||||
/// </param>
|
||||
public void WriteEntry(TarEntry entry, bool recurse)
|
||||
{
|
||||
bool asciiTrans = false;
|
||||
|
||||
string tempFileName = null;
|
||||
string eFile = entry.File;
|
||||
|
||||
// Work on a copy of the entry so we can manipulate it.
|
||||
// Note that we must distinguish how the entry was constructed.
|
||||
//
|
||||
if (eFile == null || eFile.Length == 0) {
|
||||
entry = TarEntry.CreateTarEntry(entry.Name);
|
||||
} else {
|
||||
//
|
||||
// The user may have explicitly set the entry's name to
|
||||
// something other than the file's path, so we must save
|
||||
// and restore it. This should work even when the name
|
||||
// was set from the File's name.
|
||||
//
|
||||
string saveName = entry.Name;
|
||||
entry = TarEntry.CreateEntryFromFile(eFile);
|
||||
entry.Name = saveName;
|
||||
}
|
||||
|
||||
if (this.verbose) {
|
||||
OnProgressMessageEvent(entry.Name);
|
||||
}
|
||||
|
||||
if (this.asciiTranslate && !entry.IsDirectory) {
|
||||
asciiTrans = !IsBinary(eFile);
|
||||
// original java source :
|
||||
// MimeType mime = null;
|
||||
// string contentType = null;
|
||||
//
|
||||
// try {
|
||||
// contentType = FileTypeMap.getDefaultFileTypeMap(). getContentType( eFile );
|
||||
//
|
||||
// mime = new MimeType( contentType );
|
||||
//
|
||||
// if ( mime.getPrimaryType().
|
||||
// equalsIgnoreCase( "text" ) )
|
||||
// {
|
||||
// asciiTrans = true;
|
||||
// }
|
||||
// else if ( this.transTyper != null )
|
||||
// {
|
||||
// if ( this.transTyper.isAsciiFile( eFile ) )
|
||||
// {
|
||||
// asciiTrans = true;
|
||||
// }
|
||||
// }
|
||||
// } catch ( MimeTypeParseException ex )
|
||||
// {
|
||||
// // IGNORE THIS ERROR...
|
||||
// }
|
||||
//
|
||||
// if (this.debug) {
|
||||
// Console.Error.WriteLine("CREATE TRANS? '" + asciiTrans + "' ContentType='" + contentType + "' PrimaryType='" + mime.getPrimaryType()+ "'" );
|
||||
// }
|
||||
|
||||
if (asciiTrans) {
|
||||
tempFileName = Path.GetTempFileName();
|
||||
|
||||
StreamReader inStream = File.OpenText(eFile);
|
||||
Stream outStream = new BufferedStream(File.Create(tempFileName));
|
||||
|
||||
while (true) {
|
||||
string line = inStream.ReadLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
byte[] data = Encoding.ASCII.GetBytes(line);
|
||||
outStream.Write(data, 0, data.Length);
|
||||
outStream.WriteByte((byte)'\n');
|
||||
}
|
||||
|
||||
inStream.Close();
|
||||
outStream.Flush();
|
||||
outStream.Close();
|
||||
|
||||
entry.Size = new FileInfo(tempFileName).Length;
|
||||
|
||||
eFile = tempFileName;
|
||||
}
|
||||
}
|
||||
|
||||
string newName = null;
|
||||
|
||||
if (this.rootPath != null) {
|
||||
if (entry.Name.StartsWith(this.rootPath)) {
|
||||
newName = entry.Name.Substring(this.rootPath.Length + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pathPrefix != null) {
|
||||
newName = (newName == null) ? this.pathPrefix + "/" + entry.Name : this.pathPrefix + "/" + newName;
|
||||
}
|
||||
|
||||
if (newName != null) {
|
||||
entry.Name = newName;
|
||||
}
|
||||
|
||||
this.tarOut.PutNextEntry(entry);
|
||||
|
||||
if (entry.IsDirectory) {
|
||||
if (recurse) {
|
||||
TarEntry[] list = entry.GetDirectoryEntries();
|
||||
for (int i = 0; i < list.Length; ++i) {
|
||||
this.WriteEntry(list[i], recurse);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Stream inputStream = File.OpenRead(eFile);
|
||||
int numWritten = 0;
|
||||
byte[] eBuf = new byte[32 * 1024];
|
||||
while (true) {
|
||||
int numRead = inputStream.Read(eBuf, 0, eBuf.Length);
|
||||
|
||||
if (numRead <=0) {
|
||||
break;
|
||||
}
|
||||
|
||||
this.tarOut.Write(eBuf, 0, numRead);
|
||||
numWritten += numRead;
|
||||
}
|
||||
Console.WriteLine("written " + numWritten + " bytes");
|
||||
|
||||
inputStream.Close();
|
||||
|
||||
if (tempFileName != null && tempFileName.Length > 0) {
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
|
||||
this.tarOut.CloseEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The original Java file had this header:
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
@@ -0,0 +1,437 @@
|
||||
// TarBuffer.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarBuffer class implements the tar archive concept
|
||||
/// of a buffered input stream. This concept goes back to the
|
||||
/// days of blocked tape drives and special io devices. In the
|
||||
/// C# universe, the only real function that this class
|
||||
/// performs is to ensure that files have the correct "block"
|
||||
/// size, or other tars will complain.
|
||||
/// <p>
|
||||
/// You should never have a need to access this class directly.
|
||||
/// TarBuffers are created by Tar IO Streams.
|
||||
/// </p>
|
||||
/// </summary>
|
||||
public class TarBuffer
|
||||
{
|
||||
public static readonly int DEFAULT_RCDSIZE = 512;
|
||||
public static readonly int DEFAULT_BLKSIZE = DEFAULT_RCDSIZE * 20;
|
||||
|
||||
Stream inputStream;
|
||||
Stream outputStream;
|
||||
|
||||
byte[] blockBuffer;
|
||||
int currBlkIdx;
|
||||
int currRecIdx;
|
||||
int blockSize;
|
||||
int recordSize;
|
||||
int recsPerBlock;
|
||||
|
||||
bool debug;
|
||||
|
||||
protected TarBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream)
|
||||
{
|
||||
return CreateInputTarBuffer(inputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockSize )
|
||||
{
|
||||
return CreateInputTarBuffer(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
public static TarBuffer CreateInputTarBuffer(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = inputStream;
|
||||
tarBuffer.outputStream = null;
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream)
|
||||
{
|
||||
return CreateOutputTarBuffer(outputStream, TarBuffer.DEFAULT_BLKSIZE);
|
||||
}
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockSize )
|
||||
{
|
||||
return CreateOutputTarBuffer(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
|
||||
}
|
||||
public static TarBuffer CreateOutputTarBuffer(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
TarBuffer tarBuffer = new TarBuffer();
|
||||
tarBuffer.inputStream = null;
|
||||
tarBuffer.outputStream = outputStream;
|
||||
tarBuffer.Initialize(blockSize, recordSize);
|
||||
|
||||
return tarBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization common to all constructors.
|
||||
/// </summary>
|
||||
void Initialize(int blockSize, int recordSize)
|
||||
{
|
||||
this.debug = false;
|
||||
this.blockSize = blockSize;
|
||||
this.recordSize = recordSize;
|
||||
this.recsPerBlock = this.blockSize / this.recordSize;
|
||||
this.blockBuffer = new byte[this.blockSize];
|
||||
|
||||
if (inputStream != null) {
|
||||
this.currBlkIdx = -1;
|
||||
this.currRecIdx = this.recsPerBlock;
|
||||
} else {
|
||||
this.currBlkIdx = 0;
|
||||
this.currRecIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the TAR Buffer's block size. Blocks consist of multiple records.
|
||||
/// </summary>
|
||||
public int GetBlockSize()
|
||||
{
|
||||
return this.blockSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the TAR Buffer's record size.
|
||||
/// </summary>
|
||||
public int GetRecordSize()
|
||||
{
|
||||
return this.recordSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the debugging flag for the buffer.
|
||||
/// </summary>
|
||||
public void SetDebug(bool debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an archive record indicate End of Archive. End of
|
||||
/// archive is indicated by a record that consists entirely of null bytes.
|
||||
/// </summary>
|
||||
/// <param name = "record">
|
||||
/// The record data to check.
|
||||
/// </param>
|
||||
public bool IsEOFRecord(byte[] record)
|
||||
{
|
||||
for (int i = 0, sz = this.GetRecordSize(); i < sz; ++i) {
|
||||
if (record[i] != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip over a record on the input stream.
|
||||
/// </summary>
|
||||
public void SkipRecord()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("SkipRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
return; // UNDONE
|
||||
}
|
||||
}
|
||||
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a record from the input stream and return the data.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The record data.
|
||||
/// </returns>
|
||||
public byte[] ReadRecord()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
if (!this.ReadBlock()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] result = new byte[this.recordSize];
|
||||
|
||||
Array.Copy(this.blockBuffer, (this.currRecIdx * this.recordSize), result, 0, this.recordSize );
|
||||
this.currRecIdx++;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <returns>
|
||||
/// false if End-Of-File, else true
|
||||
/// </returns>
|
||||
bool ReadBlock()
|
||||
{
|
||||
Console.WriteLine(this.debug);
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.inputStream == null) {
|
||||
throw new System.IO.IOException("no input stream stream defined");
|
||||
}
|
||||
|
||||
this.currRecIdx = 0;
|
||||
|
||||
int offset = 0;
|
||||
int bytesNeeded = this.blockSize;
|
||||
for (; bytesNeeded > 0 ;) {
|
||||
long numBytes = this.inputStream.Read(this.blockBuffer, offset, bytesNeeded);
|
||||
|
||||
//
|
||||
// NOTE
|
||||
// We have fit EOF, and the block is not full!
|
||||
//
|
||||
// This is a broken archive. It does not follow the standard
|
||||
// blocking algorithm. However, because we are generous, and
|
||||
// it requires little effort, we will simply ignore the error
|
||||
// and continue as if the entire block were read. This does
|
||||
// not appear to break anything upstream. We used to return
|
||||
// false in this case.
|
||||
//
|
||||
// Thanks to '[email protected]' for this fix.
|
||||
//
|
||||
if (numBytes <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
offset += (int)numBytes;
|
||||
bytesNeeded -= (int)numBytes;
|
||||
if (numBytes != this.blockSize) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("ReadBlock: INCOMPLETE READ " + numBytes + " of " + this.blockSize + " bytes read.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.currBlkIdx++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current block number, zero based.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based block number.
|
||||
/// </returns>
|
||||
public int GetCurrentBlockNum()
|
||||
{
|
||||
return this.currBlkIdx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the current record number, within the current block, zero based.
|
||||
/// Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The current zero based record number.
|
||||
/// </returns>
|
||||
public int GetCurrentRecordNum()
|
||||
{
|
||||
return this.currRecIdx - 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an archive record to the archive.
|
||||
/// </summary>
|
||||
/// <param name="record">
|
||||
/// The record data to write to the archive.
|
||||
/// </param>
|
||||
///
|
||||
public void WriteRecord(byte[] record)
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
}
|
||||
|
||||
if (record.Length != this.recordSize) {
|
||||
throw new IOException("record to write has length '" + record.Length + "' which is not the record size of '" + this.recordSize + "'" );
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
Array.Copy(record, 0, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an archive record to the archive, where the record may be
|
||||
/// inside of a larger array buffer. The buffer must be "offset plus
|
||||
/// record size" long.
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// The buffer containing the record data to write.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// The offset of the record data within buf.
|
||||
/// </param>
|
||||
public void WriteRecord(byte[] buf, int offset)
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx );
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream stream defined");
|
||||
}
|
||||
|
||||
if ((offset + this.recordSize) > buf.Length) {
|
||||
throw new IOException("record has length '" + buf.Length + "' with offset '" + offset + "' which is less than the record size of '" + this.recordSize + "'" );
|
||||
}
|
||||
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
|
||||
Array.Copy(buf, offset, this.blockBuffer, (this.currRecIdx * this.recordSize), this.recordSize );
|
||||
|
||||
this.currRecIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a TarBuffer block to the archive.
|
||||
/// </summary>
|
||||
void WriteBlock()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("WriteBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output stream defined");
|
||||
}
|
||||
|
||||
this.outputStream.Write(this.blockBuffer, 0, this.blockSize);
|
||||
this.outputStream.Flush();
|
||||
|
||||
this.currRecIdx = 0;
|
||||
this.currBlkIdx++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush the current data block if it has any data in it.
|
||||
/// </summary>
|
||||
void Flush()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.FlushBlock() called.");
|
||||
}
|
||||
|
||||
if (this.outputStream == null) {
|
||||
throw new System.IO.IOException("no output base stream defined");
|
||||
}
|
||||
|
||||
if (this.currRecIdx > 0) {
|
||||
this.WriteBlock();
|
||||
}
|
||||
outputStream.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the TarBuffer. If this is an output buffer, also flush the
|
||||
/// current block before closing.
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarBuffer.Close().");
|
||||
}
|
||||
|
||||
if (outputStream != null ) {
|
||||
Flush();
|
||||
|
||||
// if ( this.outStream != System.out
|
||||
// && this.outStream != System.err ) {
|
||||
outputStream.Close();
|
||||
outputStream = null;
|
||||
} else if (inputStream != null) {
|
||||
// if (this.inStream != System.in ) {
|
||||
inputStream.Close();
|
||||
inputStream = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
@@ -0,0 +1,672 @@
|
||||
// TarEntry.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// This class represents an entry in a Tar archive. It consists
|
||||
/// of the entry's header, as well as the entry's File. Entries
|
||||
/// can be instantiated in one of three ways, depending on how
|
||||
/// they are to be used.
|
||||
/// <p>
|
||||
/// TarEntries that are created from the header bytes read from
|
||||
/// an archive are instantiated with the TarEntry( byte[] )
|
||||
/// constructor. These entries will be used when extracting from
|
||||
/// or listing the contents of an archive. These entries have their
|
||||
/// header filled in using the header bytes. They also set the File
|
||||
/// to null, since they reference an archive entry not a file.</p>
|
||||
/// <p>
|
||||
/// TarEntries that are created from Files that are to be written
|
||||
/// into an archive are instantiated with the TarEntry( File )
|
||||
/// constructor. These entries have their header filled in using
|
||||
/// the File's information. They also keep a reference to the File
|
||||
/// for convenience when writing entries.</p>
|
||||
/// <p>
|
||||
/// Finally, TarEntries can be constructed from nothing but a name.
|
||||
/// This allows the programmer to construct the entry by hand, for
|
||||
/// instance when only an InputStream is available for writing to
|
||||
/// the archive, and the header information is constructed from
|
||||
/// other information. In this case the header fields are set to
|
||||
/// defaults and the File is set to null.</p>
|
||||
///
|
||||
/// <p>
|
||||
/// The C structure for a Tar Entry's header is:
|
||||
/// <pre>
|
||||
/// struct header {
|
||||
/// char name[NAMSIZ];
|
||||
/// char mode[8];
|
||||
/// char uid[8];
|
||||
/// char gid[8];
|
||||
/// char size[12];
|
||||
/// char mtime[12];
|
||||
/// char chksum[8];
|
||||
/// char linkflag;
|
||||
/// char linkname[NAMSIZ];
|
||||
/// char magic[8];
|
||||
/// char uname[TUNMLEN];
|
||||
/// char gname[TGNMLEN];
|
||||
/// char devmajor[8];
|
||||
/// char devminor[8];
|
||||
/// } header;
|
||||
/// </pre>
|
||||
/// </p>
|
||||
/// <see cref="TarHeader"/>
|
||||
/// </summary>
|
||||
public class TarEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// If this entry represents a File, this references it.
|
||||
/// </summary>
|
||||
protected string file;
|
||||
|
||||
/// <summary>
|
||||
/// This is the entry's header information.
|
||||
/// </summary>
|
||||
protected TarHeader header;
|
||||
|
||||
/// <summary>
|
||||
/// Only Create Entries with the static CreateXYZ methods or a headerBuffer.
|
||||
/// </summary>
|
||||
private TarEntry()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an entry from an archive's header bytes. File is set
|
||||
/// to null.
|
||||
/// </summary>
|
||||
/// <param name = "headerBuf">
|
||||
/// The header bytes from a tar archive entry.
|
||||
/// </param>
|
||||
public TarEntry(byte[] headerBuf)
|
||||
{
|
||||
this.Initialize();
|
||||
this.ParseTarHeader(this.header, headerBuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Construct an entry with only a name. This allows the programmer
|
||||
/// to construct the entry's header "by hand". File is set to null.
|
||||
/// </summary>
|
||||
public static TarEntry CreateTarEntry(string name)
|
||||
{
|
||||
TarEntry entry = new TarEntry();
|
||||
entry.Initialize();
|
||||
entry.NameTarHeader(entry.header, name);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an entry for a file. File is set to file, and the
|
||||
/// header is constructed from information from the file.
|
||||
/// </summary>
|
||||
/// <param name = "fileName">
|
||||
/// The file that the entry represents.
|
||||
/// </param>
|
||||
public static TarEntry CreateEntryFromFile(string fileName)
|
||||
{
|
||||
TarEntry entry = new TarEntry();
|
||||
entry.Initialize();
|
||||
entry.GetFileTarHeader(entry.header, fileName);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialization code common to all constructors.
|
||||
/// </summary>
|
||||
void Initialize()
|
||||
{
|
||||
this.file = null;
|
||||
this.header = new TarHeader();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the two entries are equal. Equality is determined
|
||||
/// by the header names being equal.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True if the entries are equal.
|
||||
/// </returns>
|
||||
public override bool Equals(object it)
|
||||
{
|
||||
if (!(it is TarEntry)) {
|
||||
return false;
|
||||
}
|
||||
return this.header.name.ToString().Equals(((TarEntry)it).header.name.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Must be overridden when you override Equals.
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.header.name.ToString().GetHashCode();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the given entry is a descendant of this entry.
|
||||
/// Descendancy is determined by the name of the descendant
|
||||
/// starting with this entry's name.
|
||||
/// </summary>
|
||||
/// <param name = "desc">
|
||||
/// Entry to be checked as a descendent of this.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// True if entry is a descendant of this.
|
||||
/// </returns>
|
||||
public bool IsDescendent(TarEntry desc)
|
||||
{
|
||||
return desc.header.name.ToString().StartsWith(this.header.name.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get this entry's header.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// This entry's TarHeader.
|
||||
/// </returns>
|
||||
public TarHeader TarHeader {
|
||||
get {
|
||||
return this.header;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set this entry's name.
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get {
|
||||
return this.header.name.ToString();
|
||||
}
|
||||
set {
|
||||
this.header.name = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set this entry's user id.
|
||||
/// </summary>
|
||||
public int UserId {
|
||||
get {
|
||||
return this.header.userId;
|
||||
}
|
||||
set {
|
||||
this.header.userId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set this entry's group id.
|
||||
/// </summary>
|
||||
public int GroupId {
|
||||
get {
|
||||
return this.header.groupId;
|
||||
}
|
||||
set {
|
||||
this.header.groupId = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set this entry's user name.
|
||||
/// </summary>
|
||||
public string UserName {
|
||||
get {
|
||||
return this.header.userName.ToString();
|
||||
}
|
||||
set {
|
||||
this.header.userName = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set this entry's group name.
|
||||
/// </summary>
|
||||
public string GroupName {
|
||||
get {
|
||||
return this.header.groupName.ToString();
|
||||
}
|
||||
set {
|
||||
this.header.groupName = new StringBuilder(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convenience method to set this entry's group and user ids.
|
||||
/// </summary>
|
||||
/// <param name="userId">
|
||||
/// This entry's new user id.
|
||||
/// </param>
|
||||
/// <param name="groupId">
|
||||
/// This entry's new group id.
|
||||
/// </param>
|
||||
public void SetIds(int userId, int groupId)
|
||||
{
|
||||
UserId = userId;
|
||||
GroupId = groupId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convenience method to set this entry's group and user names.
|
||||
/// </summary>
|
||||
/// <param name="userName">
|
||||
/// This entry's new user name.
|
||||
/// </param>
|
||||
/// <param name="groupName">
|
||||
/// This entry's new group name.
|
||||
/// </param>
|
||||
public void SetNames(string userName, string groupName)
|
||||
{
|
||||
UserName = userName;
|
||||
GroupName = groupName;
|
||||
}
|
||||
|
||||
// TODO :
|
||||
// /**
|
||||
// * Set this entry's modification time. The parameter passed
|
||||
// * to this method is in "Java time".
|
||||
// *
|
||||
// * @param time This entry's new modification time.
|
||||
// */
|
||||
// public void setModTime( long time )
|
||||
// {
|
||||
// this.header.modTime = time / 1000;
|
||||
// }
|
||||
|
||||
/// Convert time to DateTimes
|
||||
/**
|
||||
* Get/Set this entry's modification time.
|
||||
*
|
||||
* @param time This entry's new modification time.
|
||||
*/
|
||||
public DateTime ModTime {
|
||||
get {
|
||||
return this.header.modTime;
|
||||
}
|
||||
set {
|
||||
this.header.modTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get this entry's file.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// This entry's file.
|
||||
/// </returns>
|
||||
public string File {
|
||||
get {
|
||||
return this.file;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/set this entry's file size.
|
||||
/// </summary>
|
||||
public long Size {
|
||||
get {
|
||||
return this.header.size;
|
||||
}
|
||||
set {
|
||||
this.header.size = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convenience method that will modify an entry's name directly
|
||||
/// in place in an entry header buffer byte array.
|
||||
/// </summary>
|
||||
/// <param name="outbuf">
|
||||
/// The buffer containing the entry header to modify.
|
||||
/// </param>
|
||||
/// <param name="newName">
|
||||
/// The new name to place into the header buffer.
|
||||
/// </param>
|
||||
public void AdjustEntryName(byte[] outbuf, string newName)
|
||||
{
|
||||
int offset = 0;
|
||||
offset = TarHeader.GetNameBytes(new StringBuilder(newName), outbuf, offset, TarHeader.NAMELEN);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return whether or not this entry represents a directory.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True if this entry is a directory.
|
||||
/// </returns>
|
||||
public bool IsDirectory
|
||||
{
|
||||
get {
|
||||
if (this.file != null) {
|
||||
return Directory.Exists(file);
|
||||
}
|
||||
|
||||
if (this.header != null) {
|
||||
if (this.header.linkFlag == TarHeader.LF_DIR || this.header.name.ToString().EndsWith( "/" )) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill in a TarHeader with information from a File.
|
||||
/// </summary>
|
||||
/// <param name="hdr">
|
||||
/// The TarHeader to fill in.
|
||||
/// </param>
|
||||
/// <param name="file">
|
||||
/// The file from which to get the header information.
|
||||
/// </param>
|
||||
public void GetFileTarHeader(TarHeader hdr, string file)
|
||||
{
|
||||
this.file = file;
|
||||
|
||||
string name = Path.GetDirectoryName(file);
|
||||
|
||||
if (Path.DirectorySeparatorChar == '\\') { // check if the OS is a windows
|
||||
// Strip off drive letters!
|
||||
if (name.Length > 2) {
|
||||
char ch1 = name[0];
|
||||
char ch2 = name[1];
|
||||
|
||||
if (ch2 == ':' && Char.IsLetter(ch1)) {
|
||||
name = name.Substring(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
name = name.Replace(Path.DirectorySeparatorChar, '/');
|
||||
|
||||
// No absolute pathnames
|
||||
// Windows (and Posix?) paths can start with "\\NetworkDrive\",
|
||||
// so we loop on starting /'s.
|
||||
while (name.StartsWith("/")) {
|
||||
name = name.Substring(1);
|
||||
}
|
||||
|
||||
hdr.linkName = new StringBuilder(String.Empty);
|
||||
hdr.name = new StringBuilder(name);
|
||||
|
||||
if (Directory.Exists(file)) {
|
||||
hdr.mode = 040755; // TODO : what does this magic number ?? Mike
|
||||
hdr.linkFlag = TarHeader.LF_DIR;
|
||||
if (hdr.name[hdr.name.Length - 1] != '/') {
|
||||
hdr.name.Append("/");
|
||||
}
|
||||
hdr.size = 0;
|
||||
} else {
|
||||
hdr.mode = 0100644; // TODO : again a magic number
|
||||
hdr.linkFlag = TarHeader.LF_NORMAL;
|
||||
Console.WriteLine(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.size = new FileInfo(file.Replace('/', Path.DirectorySeparatorChar)).Length;
|
||||
}
|
||||
|
||||
// UNDONE When File lets us get the userName, use it!
|
||||
hdr.modTime = System.IO.File.GetLastAccessTime(file.Replace('/', Path.DirectorySeparatorChar));
|
||||
hdr.checkSum = 0;
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If this entry represents a file, and the file is a directory, return
|
||||
/// an array of TarEntries for this entry's children.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An array of TarEntry's for this entry's children.
|
||||
/// </returns>
|
||||
public TarEntry[] GetDirectoryEntries()
|
||||
{
|
||||
if (this.file == null || !Directory.Exists(this.file)) {
|
||||
return new TarEntry[0];
|
||||
}
|
||||
|
||||
string[] list = Directory.GetFileSystemEntries(this.file);
|
||||
TarEntry[] result = new TarEntry[list.Length];
|
||||
|
||||
string dirName = file;
|
||||
if (!dirName.EndsWith(Path.DirectorySeparatorChar.ToString())) {
|
||||
dirName += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Length; ++i) {
|
||||
result[i] = TarEntry.CreateEntryFromFile(list[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute the checksum of a tar entry header.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// The tar entry's header buffer.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The computed checksum.
|
||||
/// </returns>
|
||||
public long ComputeCheckSum(byte[] buf)
|
||||
{
|
||||
long sum = 0;
|
||||
for (int i = 0; i < buf.Length; ++i) {
|
||||
sum += 255 & buf[i]; // TODO : I think the 255 & x isn't neccessary += buf[i] should be enough. CHECK IT!
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an entry's header information to a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "outbuf">
|
||||
/// The tar entry header buffer to fill in.
|
||||
/// </param>
|
||||
public void WriteEntryHeader(byte[] outbuf)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
offset = TarHeader.GetNameBytes(this.header.name, outbuf, offset, TarHeader.NAMELEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.mode, outbuf, offset, TarHeader.MODELEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.userId, outbuf, offset, TarHeader.UIDLEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.groupId, outbuf, offset, TarHeader.GIDLEN);
|
||||
|
||||
long size = this.header.size;
|
||||
|
||||
offset = TarHeader.GetLongOctalBytes(size, outbuf, offset, TarHeader.SIZELEN);
|
||||
offset = TarHeader.GetLongOctalBytes(GetCTime(this.header.modTime), outbuf, offset, TarHeader.MODTIMELEN);
|
||||
|
||||
int csOffset = offset;
|
||||
for (int c = 0; c < TarHeader.CHKSUMLEN; ++c) {
|
||||
outbuf[offset++] = (byte)' ';
|
||||
}
|
||||
|
||||
outbuf[offset++] = this.header.linkFlag;
|
||||
|
||||
offset = TarHeader.GetNameBytes(this.header.linkName, outbuf, offset, TarHeader.NAMELEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.magic, outbuf, offset, TarHeader.MAGICLEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.userName, outbuf, offset, TarHeader.UNAMELEN);
|
||||
offset = TarHeader.GetNameBytes(this.header.groupName, outbuf, offset, TarHeader.GNAMELEN);
|
||||
|
||||
offset = TarHeader.GetOctalBytes(this.header.devMajor, outbuf, offset, TarHeader.DEVLEN);
|
||||
offset = TarHeader.GetOctalBytes(this.header.devMinor, outbuf, offset, TarHeader.DEVLEN);
|
||||
|
||||
for (; offset < outbuf.Length;) {
|
||||
outbuf[offset++] = 0;
|
||||
}
|
||||
|
||||
long checkSum = this.ComputeCheckSum(outbuf);
|
||||
|
||||
TarHeader.GetCheckSumOctalBytes(checkSum, outbuf, csOffset, TarHeader.CHKSUMLEN);
|
||||
}
|
||||
|
||||
// time conversion functions
|
||||
readonly static long timeConversionFactor = 10000000L;
|
||||
readonly static DateTime datetTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
|
||||
static int GetCTime(System.DateTime dateTime)
|
||||
{
|
||||
return (int)((dateTime.Ticks - datetTime1970.Ticks) / timeConversionFactor);
|
||||
}
|
||||
|
||||
static DateTime GetDateTimeFromCTime(long ticks)
|
||||
{
|
||||
return new DateTime(datetTime1970.Ticks + ticks * timeConversionFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an entry's TarHeader information from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name ="hdr">
|
||||
/// Parse an entry's TarHeader information from a header buffer.
|
||||
/// </param>
|
||||
/// <param name = "header">
|
||||
/// The tar entry header buffer to get information from.
|
||||
/// </param>
|
||||
public void ParseTarHeader(TarHeader hdr, byte[] header)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
hdr.name = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
hdr.mode = (int)TarHeader.ParseOctal(header, offset, TarHeader.MODELEN);
|
||||
|
||||
offset += TarHeader.MODELEN;
|
||||
|
||||
hdr.userId = (int)TarHeader.ParseOctal(header, offset, TarHeader.UIDLEN);
|
||||
|
||||
offset += TarHeader.UIDLEN;
|
||||
|
||||
hdr.groupId = (int)TarHeader.ParseOctal(header, offset, TarHeader.GIDLEN);
|
||||
|
||||
offset += TarHeader.GIDLEN;
|
||||
|
||||
hdr.size = TarHeader.ParseOctal(header, offset, TarHeader.SIZELEN);
|
||||
|
||||
offset += TarHeader.SIZELEN;
|
||||
|
||||
hdr.modTime = GetDateTimeFromCTime(TarHeader.ParseOctal(header, offset, TarHeader.MODTIMELEN));
|
||||
|
||||
offset += TarHeader.MODTIMELEN;
|
||||
|
||||
hdr.checkSum = (int)TarHeader.ParseOctal(header, offset, TarHeader.CHKSUMLEN);
|
||||
|
||||
offset += TarHeader.CHKSUMLEN;
|
||||
|
||||
hdr.linkFlag = header[ offset++ ];
|
||||
|
||||
hdr.linkName = TarHeader.ParseName(header, offset, TarHeader.NAMELEN);
|
||||
|
||||
offset += TarHeader.NAMELEN;
|
||||
|
||||
hdr.magic = TarHeader.ParseName(header, offset, TarHeader.MAGICLEN);
|
||||
|
||||
offset += TarHeader.MAGICLEN;
|
||||
|
||||
hdr.userName = TarHeader.ParseName(header, offset, TarHeader.UNAMELEN);
|
||||
|
||||
offset += TarHeader.UNAMELEN;
|
||||
|
||||
hdr.groupName = TarHeader.ParseName(header, offset, TarHeader.GNAMELEN);
|
||||
|
||||
offset += TarHeader.GNAMELEN;
|
||||
|
||||
hdr.devMajor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
|
||||
offset += TarHeader.DEVLEN;
|
||||
|
||||
hdr.devMinor = (int)TarHeader.ParseOctal(header, offset, TarHeader.DEVLEN);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill in a TarHeader given only the entry's name.
|
||||
/// </summary>
|
||||
/// <param name="hdr">
|
||||
/// The TarHeader to fill in.
|
||||
/// </param>
|
||||
/// <param name="name">
|
||||
/// The tar entry name.
|
||||
/// </param>
|
||||
public void NameTarHeader(TarHeader hdr, string name)
|
||||
{
|
||||
bool isDir = name.EndsWith("/");
|
||||
|
||||
hdr.checkSum = 0;
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
|
||||
hdr.name = new StringBuilder(name);
|
||||
hdr.mode = isDir ? 040755 : 0100644; // TODO : I think I've seen these magics before ...
|
||||
hdr.userId = 0;
|
||||
hdr.groupId = 0;
|
||||
hdr.size = 0;
|
||||
hdr.checkSum = 0;
|
||||
|
||||
hdr.modTime = DateTime.Now;//(new java.util.Date()).getTime() / 1000;
|
||||
|
||||
hdr.linkFlag = isDir ? TarHeader.LF_DIR : TarHeader.LF_NORMAL;
|
||||
|
||||
hdr.linkName = new StringBuilder(String.Empty);
|
||||
hdr.userName = new StringBuilder(String.Empty);
|
||||
hdr.groupName = new StringBuilder(String.Empty);
|
||||
|
||||
hdr.devMajor = 0;
|
||||
hdr.devMinor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
@@ -0,0 +1,500 @@
|
||||
// TarHeader.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This class encapsulates the Tar Entry Header used in Tar Archives.
|
||||
/// The class also holds a number of tar constants, used mostly in headers.
|
||||
/// </summary>
|
||||
public class TarHeader : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// The length of the name field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int NAMELEN = 100;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the mode field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int MODELEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the user id field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int UIDLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the group id field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int GIDLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the checksum field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int CHKSUMLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the size field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int SIZELEN = 12;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the magic field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int MAGICLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the modification time field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int MODTIMELEN = 12;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the user name field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int UNAMELEN = 32;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the group name field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int GNAMELEN = 32;
|
||||
|
||||
/// <summary>
|
||||
/// The length of the devices field in a header buffer.
|
||||
/// </summary>
|
||||
public readonly static int DEVLEN = 8;
|
||||
|
||||
/// <summary>
|
||||
/// LF_ constants represent the "link flag" of an entry, or more commonly,
|
||||
/// the "entry type". This is the "old way" of indicating a normal file.
|
||||
/// </summary>
|
||||
public readonly static byte LF_OLDNORM = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Normal file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_NORMAL = (byte) '0';
|
||||
|
||||
/// <summary>
|
||||
/// Link file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_LINK = (byte) '1';
|
||||
|
||||
/// <summary>
|
||||
/// Symbolic link file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_SYMLINK = (byte) '2';
|
||||
|
||||
/// <summary>
|
||||
/// Character device file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_CHR = (byte) '3';
|
||||
|
||||
/// <summary>
|
||||
/// Block device file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_BLK = (byte) '4';
|
||||
|
||||
/// <summary>
|
||||
/// Directory file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_DIR = (byte) '5';
|
||||
|
||||
/// <summary>
|
||||
/// FIFO (pipe) file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_FIFO = (byte) '6';
|
||||
|
||||
/// <summary>
|
||||
/// Contiguous file type.
|
||||
/// </summary>
|
||||
public readonly static byte LF_CONTIG = (byte) '7';
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing a POSIX tar archive.
|
||||
/// </summary>
|
||||
public readonly static string TMAGIC = "ustar";
|
||||
|
||||
/// <summary>
|
||||
/// The magic tag representing a GNU tar archive.
|
||||
/// </summary>
|
||||
public readonly static string GNU_TMAGIC = "ustar ";
|
||||
|
||||
/// <summary>
|
||||
/// The entry's name.
|
||||
/// </summary>
|
||||
public StringBuilder name;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's permission mode.
|
||||
/// </summary>
|
||||
public int mode;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's user id.
|
||||
/// </summary>
|
||||
public int userId;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's group id.
|
||||
/// </summary>
|
||||
public int groupId;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's size.
|
||||
/// </summary>
|
||||
public long size;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's modification time.
|
||||
/// </summary>
|
||||
public DateTime modTime;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's checksum.
|
||||
/// </summary>
|
||||
public int checkSum;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's link flag.
|
||||
/// </summary>
|
||||
public byte linkFlag;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's link name.
|
||||
/// </summary>
|
||||
public StringBuilder linkName;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's magic tag.
|
||||
/// </summary>
|
||||
public StringBuilder magic;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's user name.
|
||||
/// </summary>
|
||||
public StringBuilder userName;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's group name.
|
||||
/// </summary>
|
||||
public StringBuilder groupName;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's major device number.
|
||||
/// </summary>
|
||||
public int devMajor;
|
||||
|
||||
/// <summary>
|
||||
/// The entry's minor device number.
|
||||
/// </summary>
|
||||
public int devMinor;
|
||||
|
||||
public TarHeader()
|
||||
{
|
||||
this.magic = new StringBuilder(TarHeader.TMAGIC);
|
||||
|
||||
this.name = new StringBuilder();
|
||||
this.linkName = new StringBuilder();
|
||||
|
||||
string user = Environment.UserName;
|
||||
|
||||
if (user.Length > 31) {
|
||||
user = user.Substring(0, 31);
|
||||
}
|
||||
|
||||
this.userId = 0;
|
||||
this.groupId = 0;
|
||||
this.userName = new StringBuilder(user);
|
||||
this.groupName = new StringBuilder(String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TarHeaders can be cloned.
|
||||
/// </summary>
|
||||
public object Clone()
|
||||
{
|
||||
TarHeader hdr = new TarHeader();
|
||||
|
||||
hdr.name = (this.name == null) ? null : new StringBuilder(this.name.ToString());
|
||||
hdr.mode = this.mode;
|
||||
hdr.userId = this.userId;
|
||||
hdr.groupId = this.groupId;
|
||||
hdr.size = this.size;
|
||||
hdr.modTime = this.modTime;
|
||||
hdr.checkSum = this.checkSum;
|
||||
hdr.linkFlag = this.linkFlag;
|
||||
hdr.linkName = (this.linkName == null) ? null : new StringBuilder(this.linkName.ToString());
|
||||
hdr.magic = (this.magic == null) ? null : new StringBuilder(this.magic.ToString());
|
||||
hdr.userName = (this.userName == null) ? null : new StringBuilder(this.userName.ToString());
|
||||
hdr.groupName = (this.groupName == null) ? null : new StringBuilder(this.groupName.ToString());
|
||||
hdr.devMajor = this.devMajor;
|
||||
hdr.devMinor = this.devMinor;
|
||||
|
||||
return hdr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of this entry.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The entry's name.
|
||||
/// </returns>
|
||||
public string GetName()
|
||||
{
|
||||
return this.name.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an octal string from a header buffer. This is used for the
|
||||
/// file permission mode value.
|
||||
/// </summary>
|
||||
/// <param name = "header">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The long value of the octal string.
|
||||
/// </returns>
|
||||
public static long ParseOctal(byte[] header, int offset, int length)
|
||||
{
|
||||
long result = 0;
|
||||
bool stillPadding = true;
|
||||
|
||||
int end = offset + length;
|
||||
for (int i = offset; i < end ; ++i) {
|
||||
if (header[i] == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (header[i] == (byte)' ' || header[i] == '0') {
|
||||
if (stillPadding) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header[i] == (byte)' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stillPadding = false;
|
||||
|
||||
result = (result << 3) + (header[i] - '0');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an entry name from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name="header">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The header's entry name.
|
||||
/// </returns>
|
||||
public static StringBuilder ParseName(byte[] header, int offset, int length)
|
||||
{
|
||||
StringBuilder result = new StringBuilder(length);
|
||||
|
||||
for (int i = offset; i < offset + length; ++i) {
|
||||
if (header[i] == 0) {
|
||||
break;
|
||||
}
|
||||
result.Append((char)header[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the number of bytes in an entry name.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// </param>
|
||||
/// <param name="buf">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The number of bytes in a header's entry name.
|
||||
/// </returns>
|
||||
public static int GetNameBytes(StringBuilder name, byte[] buf, int offset, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < length && i < name.Length; ++i) {
|
||||
buf[offset + i] = (byte)name[i];
|
||||
}
|
||||
|
||||
for (; i < length ; ++i) {
|
||||
buf[offset + i] = 0;
|
||||
}
|
||||
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an octal integer from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "val">
|
||||
/// </param>
|
||||
/// <param name = "buf">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The integer value of the octal bytes.
|
||||
/// </returns>
|
||||
public static int GetOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
byte[] result = new byte[length];
|
||||
|
||||
int idx = length - 1;
|
||||
|
||||
buf[offset + idx] = 0;
|
||||
--idx;
|
||||
buf[offset + idx] = (byte)' ';
|
||||
--idx;
|
||||
|
||||
if (val == 0) {
|
||||
buf[offset + idx] = (byte)'0';
|
||||
--idx;
|
||||
} else {
|
||||
for (long v = val; idx >= 0 && v > 0; --idx) {
|
||||
buf[offset + idx] = (byte)((byte)'0' + (byte)(v & 7));
|
||||
v >>= 3;
|
||||
}
|
||||
}
|
||||
|
||||
for (; idx >= 0; --idx) {
|
||||
buf[offset + idx] = (byte)' ';
|
||||
}
|
||||
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an octal long integer from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "val">
|
||||
/// </param>
|
||||
/// <param name = "buf">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The long value of the octal bytes.
|
||||
/// </returns>
|
||||
public static int GetLongOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
byte[] temp = new byte[length + 1];
|
||||
TarHeader.GetOctalBytes(val, temp, 0, length + 1);
|
||||
Array.Copy(temp, 0, buf, offset, length);
|
||||
return offset + length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse the checksum octal integer from a header buffer.
|
||||
/// </summary>
|
||||
/// <param name = "val">
|
||||
/// </param>
|
||||
/// <param name = "buf">
|
||||
/// The header buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "offset">
|
||||
/// The offset into the buffer from which to parse.
|
||||
/// </param>
|
||||
/// <param name = "length">
|
||||
/// The number of header bytes to parse.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The integer value of the entry's checksum.
|
||||
/// </returns>
|
||||
public static int GetCheckSumOctalBytes(long val, byte[] buf, int offset, int length)
|
||||
{
|
||||
TarHeader.GetOctalBytes(val, buf, offset, length);
|
||||
buf[offset + length - 1] = (byte)' ';
|
||||
buf[offset + length - 2] = 0;
|
||||
return offset + length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
*
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
@@ -0,0 +1,522 @@
|
||||
// TarInputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarInputStream reads a UNIX tar archive as an InputStream.
|
||||
/// methods are provided to position at each successive entry in
|
||||
/// the archive, and the read each entry as a normal input stream
|
||||
/// using read().
|
||||
/// </summary>
|
||||
public class TarInputStream : Stream
|
||||
{
|
||||
protected bool debug;
|
||||
protected bool hasHitEOF;
|
||||
|
||||
protected int entrySize;
|
||||
protected int entryOffset;
|
||||
|
||||
protected byte[] readBuf;
|
||||
|
||||
protected TarBuffer buffer;
|
||||
protected TarEntry currEntry;
|
||||
protected IEntryFactory eFactory;
|
||||
|
||||
Stream inputStream;
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return inputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return inputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return inputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length {
|
||||
get {
|
||||
return inputStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position {
|
||||
get {
|
||||
return inputStream.Position;
|
||||
}
|
||||
set {
|
||||
inputStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the baseInputStream
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
inputStream.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return inputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void SetLength(long val)
|
||||
{
|
||||
inputStream.SetLength(val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void Write(byte[] array, int offset, int count)
|
||||
{
|
||||
inputStream.Write(array, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void WriteByte(byte val)
|
||||
{
|
||||
inputStream.WriteByte(val);
|
||||
}
|
||||
|
||||
|
||||
public TarInputStream(Stream inputStream) : this(inputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockSize) : this(inputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarInputStream(Stream inputStream, int blockSize, int recordSize)
|
||||
{
|
||||
this.inputStream = inputStream;
|
||||
this.buffer = TarBuffer.CreateInputTarBuffer(inputStream, blockSize, recordSize);
|
||||
|
||||
this.readBuf = null;
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.eFactory = null;
|
||||
}
|
||||
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
}
|
||||
public void SetBufferDebug(bool debug)
|
||||
{
|
||||
this.buffer.SetDebug(debug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetEntryFactory(IEntryFactory factory)
|
||||
{
|
||||
this.eFactory = factory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes this stream. Calls the TarBuffer's close() method.
|
||||
/// The underlying stream is closed by the TarBuffer.
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
this.buffer.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the record size being used by this stream's TarBuffer.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// TarBuffer record size.
|
||||
/// </returns>
|
||||
public int GetRecordSize()
|
||||
{
|
||||
return this.buffer.GetRecordSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the available data that can be read from the current
|
||||
/// entry in the archive. This does not indicate how much data
|
||||
/// is left in the entire archive, only in the current entry.
|
||||
/// This value is determined from the entry's size header field
|
||||
/// and the amount of data already read from the current entry.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The number of available bytes for the current entry.
|
||||
/// </returns>
|
||||
public int Available {
|
||||
get {
|
||||
return this.entrySize - this.entryOffset;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip bytes in the input buffer. This skips bytes in the
|
||||
/// current entry's data, not the entire archive, and will
|
||||
/// stop at the end of the current entry's data if the number
|
||||
/// to skip extends beyond that point.
|
||||
/// </summary>
|
||||
/// <param name="numToSkip">
|
||||
/// The number of bytes to skip.
|
||||
/// </param>
|
||||
public void Skip(int numToSkip)
|
||||
{
|
||||
// REVIEW
|
||||
// This is horribly inefficient, but it ensures that we
|
||||
// properly skip over bytes via the TarBuffer...
|
||||
//
|
||||
byte[] skipBuf = new byte[8 * 1024];
|
||||
|
||||
for (int num = numToSkip; num > 0;){
|
||||
int numRead = this.Read(skipBuf, 0, (num > skipBuf.Length ? skipBuf.Length : num));
|
||||
|
||||
if (numRead == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
num -= numRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Since we do not support marking just yet, we return false.
|
||||
/// </summary>
|
||||
public bool IsMarkSupported {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Since we do not support marking just yet, we do nothing.
|
||||
/// </summary>
|
||||
/// <param name ="markLimit">
|
||||
/// The limit to mark.
|
||||
/// </param>
|
||||
public void Mark(int markLimit)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Since we do not support marking just yet, we do nothing.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the next entry in this tar archive. This will skip
|
||||
/// over any remaining data in the current entry, if there
|
||||
/// is one, and place the input stream at the header of the
|
||||
/// next entry, and read the header and instantiate a new
|
||||
/// TarEntry from the header bytes and return that entry.
|
||||
/// If there are no more entries in the archive, null will
|
||||
/// be returned to indicate that the end of the archive has
|
||||
/// been reached.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The next TarEntry in the archive, or null.
|
||||
/// </returns>
|
||||
public TarEntry GetNextEntry()
|
||||
{
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.currEntry != null) {
|
||||
int numToSkip = this.entrySize - this.entryOffset;
|
||||
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarInputStream: SKIP currENTRY '" + this.currEntry.Name + "' SZ " + this.entrySize + " OFF " + this.entryOffset + " skipping " + numToSkip + " bytes");
|
||||
}
|
||||
|
||||
if (numToSkip > 0) {
|
||||
this.Skip(numToSkip);
|
||||
}
|
||||
|
||||
this.readBuf = null;
|
||||
}
|
||||
|
||||
byte[] headerBuf = this.buffer.ReadRecord();
|
||||
|
||||
if (headerBuf == null) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("READ NULL RECORD");
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
} else if (this.buffer.IsEOFRecord(headerBuf)) {
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine( "READ EOF RECORD" );
|
||||
}
|
||||
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
if (this.eFactory == null) {
|
||||
this.currEntry = new TarEntry(headerBuf);
|
||||
} else {
|
||||
this.currEntry = this.eFactory.CreateEntry(headerBuf);
|
||||
}
|
||||
|
||||
if (!(headerBuf[257] == 'u' && headerBuf[258] == 's' && headerBuf[259] == 't' && headerBuf[260] == 'a' && headerBuf[261] == 'r')) {
|
||||
throw new InvalidHeaderException("header magic is not 'ustar', but '" + headerBuf[257] + headerBuf[258] + headerBuf[259] + headerBuf[260] + headerBuf[261] +
|
||||
"', or (dec) " + ((int)headerBuf[257]) + ", " + ((int)headerBuf[258]) + ", " + ((int)headerBuf[259]) + ", " + ((int)headerBuf[260]) + ", " + ((int)headerBuf[261]));
|
||||
}
|
||||
|
||||
if (this.debug) {
|
||||
Console.Error.WriteLine("TarInputStream: SET CURRENTRY '" + this.currEntry.Name + "' size = " + this.currEntry.Size);
|
||||
}
|
||||
|
||||
this.entryOffset = 0;
|
||||
|
||||
// REVIEW How do we resolve this discrepancy?!
|
||||
this.entrySize = (int) this.currEntry.Size;
|
||||
} catch (InvalidHeaderException ex) {
|
||||
this.entrySize = 0;
|
||||
this.entryOffset = 0;
|
||||
this.currEntry = null;
|
||||
throw new InvalidHeaderException("bad header in block " + this.buffer.GetCurrentBlockNum() + " record " + this.buffer.GetCurrentRecordNum() + ", " + ex.Message);
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte from the current tar archive entry.
|
||||
/// This method simply calls read(byte[], int, int).
|
||||
/// </summary>
|
||||
public override int ReadByte()
|
||||
{
|
||||
byte[] oneByteBuffer = new byte[1];
|
||||
int num = this.Read(oneByteBuffer, 0, 1);
|
||||
if (num <= 0) { // return -1 to indicate that no byte was read.
|
||||
return -1;
|
||||
}
|
||||
return (int)oneByteBuffer[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads bytes from the current tar archive entry.
|
||||
///
|
||||
/// This method is aware of the boundaries of the current
|
||||
/// entry in the archive and will deal with them as if they
|
||||
/// entry in the archive and will deal with them as if they
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// The buffer into which to place bytes read.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// The offset at which to place bytes read.
|
||||
/// </param>
|
||||
/// <param name="numToRead">
|
||||
/// The number of bytes to read.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The number of bytes read, or -1 at EOF.
|
||||
/// </returns>
|
||||
public override int Read(byte[] buf, int offset, int numToRead)
|
||||
{
|
||||
int totalRead = 0;
|
||||
|
||||
if (this.entryOffset >= this.entrySize) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((numToRead + this.entryOffset) > this.entrySize) {
|
||||
numToRead = this.entrySize - this.entryOffset;
|
||||
}
|
||||
|
||||
if (this.readBuf != null) {
|
||||
int sz = (numToRead > this.readBuf.Length) ? this.readBuf.Length : numToRead;
|
||||
|
||||
Array.Copy(this.readBuf, 0, buf, offset, sz);
|
||||
|
||||
if (sz >= this.readBuf.Length) {
|
||||
this.readBuf = null;
|
||||
} else {
|
||||
int newLen = this.readBuf.Length - sz;
|
||||
byte[] newBuf = new byte[ newLen ];
|
||||
Array.Copy(this.readBuf, sz, newBuf, 0, newLen);
|
||||
this.readBuf = newBuf;
|
||||
}
|
||||
|
||||
totalRead += sz;
|
||||
numToRead -= sz;
|
||||
offset += sz;
|
||||
}
|
||||
|
||||
while (numToRead > 0) {
|
||||
byte[] rec = this.buffer.ReadRecord();
|
||||
if (rec == null) {
|
||||
// Unexpected EOF!
|
||||
throw new IOException("unexpected EOF with " + numToRead + " bytes unread");
|
||||
}
|
||||
|
||||
int sz = numToRead;
|
||||
int recLen = rec.Length;
|
||||
|
||||
if (recLen > sz) {
|
||||
Array.Copy(rec, 0, buf, offset, sz);
|
||||
this.readBuf = new byte[recLen - sz];
|
||||
Array.Copy(rec, sz, this.readBuf, 0, recLen - sz);
|
||||
} else {
|
||||
sz = recLen;
|
||||
Array.Copy(rec, 0, buf, offset, recLen);
|
||||
}
|
||||
|
||||
totalRead += sz;
|
||||
numToRead -= sz;
|
||||
offset += sz;
|
||||
}
|
||||
|
||||
this.entryOffset += totalRead;
|
||||
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the contents of the current tar archive entry directly into
|
||||
/// an output stream.
|
||||
/// </summary>
|
||||
/// <param name="outputStream">
|
||||
/// The OutputStream into which to write the entry's data.
|
||||
/// </param>
|
||||
public void CopyEntryContents(Stream outputStream)
|
||||
{
|
||||
byte[] buf = new byte[32 * 1024];
|
||||
|
||||
while (true) {
|
||||
int numRead = this.Read(buf, 0, buf.Length);
|
||||
if (numRead <= 0) {
|
||||
break;
|
||||
}
|
||||
outputStream.Write(buf, 0, numRead);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface is provided, with the method setEntryFactory(), to allow
|
||||
/// the programmer to have their own TarEntry subclass instantiated for the
|
||||
/// entries return from getNextEntry().
|
||||
/// </summary>
|
||||
public interface IEntryFactory
|
||||
{
|
||||
TarEntry CreateEntry(string name);
|
||||
|
||||
TarEntry CreateEntryFromFile(string fileName);
|
||||
|
||||
TarEntry CreateEntry(byte[] headerBuf);
|
||||
}
|
||||
|
||||
public class EntryFactoryAdapter : IEntryFactory
|
||||
{
|
||||
public TarEntry CreateEntry(string name)
|
||||
{
|
||||
return TarEntry.CreateTarEntry(name);
|
||||
}
|
||||
|
||||
public TarEntry CreateEntryFromFile(string fileName)
|
||||
{
|
||||
return TarEntry.CreateEntryFromFile(fileName);
|
||||
}
|
||||
|
||||
public TarEntry CreateEntry(byte[] headerBuf)
|
||||
{
|
||||
return new TarEntry(headerBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
// TarOutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar {
|
||||
|
||||
/// <summary>
|
||||
/// The TarOutputStream writes a UNIX tar archive as an OutputStream.
|
||||
/// Methods are provided to put entries, and then write their contents
|
||||
/// by writing to this stream using write().
|
||||
/// </summary>
|
||||
/// public
|
||||
public class TarOutputStream : Stream
|
||||
{
|
||||
protected bool debug;
|
||||
protected int currSize;
|
||||
protected int currBytes;
|
||||
protected byte[] recordBuf;
|
||||
protected int assemLen;
|
||||
protected byte[] assemBuf;
|
||||
|
||||
protected TarBuffer buffer;
|
||||
protected Stream outputStream;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return outputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return outputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return outputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length {
|
||||
get {
|
||||
return outputStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position {
|
||||
get {
|
||||
return outputStream.Position;
|
||||
}
|
||||
set {
|
||||
outputStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return outputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void SetLength(long val)
|
||||
{
|
||||
outputStream.SetLength(val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override int ReadByte()
|
||||
{
|
||||
return outputStream.ReadByte();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
return outputStream.Read(b, off, len);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
outputStream.Flush();
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream) : this(outputStream, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockSize) : this(outputStream, blockSize, TarBuffer.DEFAULT_RCDSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
public TarOutputStream(Stream outputStream, int blockSize, int recordSize)
|
||||
{
|
||||
this.outputStream = outputStream;
|
||||
this.buffer = TarBuffer.CreateOutputTarBuffer(outputStream, blockSize, recordSize);
|
||||
|
||||
this.debug = false;
|
||||
this.assemLen = 0;
|
||||
this.assemBuf = new byte[recordSize];
|
||||
this.recordBuf = new byte[recordSize];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the debugging flag.
|
||||
/// </summary>
|
||||
/// <param name = "debugF">
|
||||
/// True to turn on debugging.
|
||||
/// </param>
|
||||
public void SetDebug(bool debugF)
|
||||
{
|
||||
this.debug = debugF;
|
||||
SetBufferDebug(debugF);
|
||||
}
|
||||
|
||||
public void SetBufferDebug(bool debug)
|
||||
{
|
||||
this.buffer.SetDebug(debug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the TAR archive without closing the underlying OutputStream.
|
||||
/// The result is that the EOF record of nulls is written.
|
||||
/// </summary>
|
||||
public void Finish()
|
||||
{
|
||||
this.WriteEOFRecord();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the TAR archive and closes the underlying OutputStream.
|
||||
/// This means that finish() is called followed by calling the
|
||||
/// TarBuffer's close().
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
this.Finish();
|
||||
this.buffer.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the record size being used by this stream's TarBuffer.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The TarBuffer record size.
|
||||
/// </returns>
|
||||
public int GetRecordSize()
|
||||
{
|
||||
return this.buffer.GetRecordSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Put an entry on the output stream. This writes the entry's
|
||||
/// header record and positions the output stream for writing
|
||||
/// the contents of the entry. Once this method is called, the
|
||||
/// stream is ready for calls to write() to write the entry's
|
||||
/// contents. Once the contents are written, closeEntry()
|
||||
/// <B>MUST</B> be called to ensure that all buffered data
|
||||
/// is completely written to the output stream.
|
||||
/// </summary>
|
||||
/// <param name="entry">
|
||||
/// The TarEntry to be written to the archive.
|
||||
/// </param>
|
||||
public void PutNextEntry(TarEntry entry)
|
||||
{
|
||||
if (entry.TarHeader.name.Length > TarHeader.NAMELEN) {
|
||||
throw new InvalidHeaderException("file name '" + entry.TarHeader.name + "' is too long ( > " + TarHeader.NAMELEN + " bytes )");
|
||||
}
|
||||
|
||||
entry.WriteEntryHeader(this.recordBuf);
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
|
||||
this.currBytes = 0;
|
||||
|
||||
this.currSize = entry.IsDirectory ? 0 : (int)entry.Size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close an entry. This method MUST be called for all file
|
||||
/// entries that contain data. The reason is that we must
|
||||
/// buffer data written to the stream in order to satisfy
|
||||
/// the buffer's record based writes. Thus, there may be
|
||||
/// data fragments still being assembled that must be written
|
||||
/// to the output stream before this entry is closed and the
|
||||
/// next entry written.
|
||||
/// </summary>
|
||||
public void CloseEntry()
|
||||
{
|
||||
if (this.assemLen > 0) {
|
||||
for (int i = this.assemLen; i < this.assemBuf.Length; ++i) {
|
||||
this.assemBuf[i] = 0;
|
||||
}
|
||||
|
||||
this.buffer.WriteRecord(this.assemBuf);
|
||||
|
||||
this.currBytes += this.assemLen;
|
||||
this.assemLen = 0;
|
||||
}
|
||||
|
||||
if (this.currBytes < this.currSize) {
|
||||
throw new IOException("entry closed at '" + this.currBytes + "' before the '" + this.currSize + "' bytes specified in the header were written");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a byte to the current tar archive entry.
|
||||
/// This method simply calls Write(byte[], int, int).
|
||||
/// </summary>
|
||||
/// <param name="b">
|
||||
/// The byte written.
|
||||
/// </param>
|
||||
public override void WriteByte(byte b)
|
||||
{
|
||||
this.Write(new byte[] { b }, 0, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes bytes to the current tar archive entry. This method
|
||||
/// is aware of the current entry and will throw an exception if
|
||||
/// you attempt to write bytes past the length specified for the
|
||||
/// current entry. The method is also (painfully) aware of the
|
||||
/// record buffering required by TarBuffer, and manages buffers
|
||||
/// that are not a multiple of recordsize in length, including
|
||||
/// assembling records from small buffers.
|
||||
/// </summary>
|
||||
/// <param name = "wBuf">
|
||||
/// The buffer to write to the archive.
|
||||
/// </param>
|
||||
/// <param name = "wOffset">
|
||||
/// The offset in the buffer from which to get bytes.
|
||||
/// </param>
|
||||
/// <param name = "numToWrite">
|
||||
/// The number of bytes to write.
|
||||
/// </param>
|
||||
public override void Write(byte[] wBuf, int wOffset, int numToWrite)
|
||||
{
|
||||
if ((this.currBytes + numToWrite) > this.currSize) {
|
||||
throw new IOException("request to write '" + numToWrite + "' bytes exceeds size in header of '" + this.currSize + "' bytes");
|
||||
}
|
||||
|
||||
//
|
||||
// We have to deal with assembly!!!
|
||||
// The programmer can be writing little 32 byte chunks for all
|
||||
// we know, and we must assemble complete records for writing.
|
||||
// REVIEW Maybe this should be in TarBuffer? Could that help to
|
||||
// eliminate some of the buffer copying.
|
||||
//
|
||||
if (this.assemLen > 0) {
|
||||
if ((this.assemLen + numToWrite ) >= this.recordBuf.Length) {
|
||||
int aLen = this.recordBuf.Length - this.assemLen;
|
||||
|
||||
Array.Copy(this.assemBuf, 0, this.recordBuf, 0, this.assemLen);
|
||||
|
||||
Array.Copy(wBuf, wOffset, this.recordBuf, this.assemLen, aLen);
|
||||
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
|
||||
this.currBytes += this.recordBuf.Length;
|
||||
|
||||
wOffset += aLen;
|
||||
numToWrite -= aLen;
|
||||
|
||||
this.assemLen = 0;
|
||||
} else {// ( (this.assemLen + numToWrite ) < this.recordBuf.length )
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
wOffset += numToWrite;
|
||||
this.assemLen += numToWrite;
|
||||
numToWrite -= numToWrite;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// When we get here we have EITHER:
|
||||
// o An empty "assemble" buffer.
|
||||
// o No bytes to write (numToWrite == 0)
|
||||
//
|
||||
while (numToWrite > 0) {
|
||||
if (numToWrite < this.recordBuf.Length) {
|
||||
Array.Copy(wBuf, wOffset, this.assemBuf, this.assemLen, numToWrite);
|
||||
this.assemLen += numToWrite;
|
||||
break;
|
||||
}
|
||||
|
||||
this.buffer.WriteRecord(wBuf, wOffset);
|
||||
|
||||
int num = this.recordBuf.Length;
|
||||
this.currBytes += num;
|
||||
numToWrite -= num;
|
||||
wOffset += num;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an EOF (end of archive) record to the tar archive.
|
||||
/// An EOF record consists of a record of all zeros.
|
||||
/// </summary>
|
||||
void WriteEOFRecord()
|
||||
{
|
||||
for (int i = 0; i < this.recordBuf.Length; ++i) {
|
||||
this.recordBuf[i] = 0;
|
||||
}
|
||||
this.buffer.WriteRecord(this.recordBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The original Java file had this header:
|
||||
** Authored by Timothy Gerard Endres
|
||||
** <mailto:[email protected]> <http://www.trustice.com>
|
||||
**
|
||||
** This work has been placed into the public domain.
|
||||
** You may use this work in any way and for any purpose you wish.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
|
||||
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
|
||||
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
|
||||
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
|
||||
** REDISTRIBUTION OF THIS SOFTWARE.
|
||||
**
|
||||
*/
|
||||
+542
@@ -0,0 +1,542 @@
|
||||
// Deflater.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This is the Deflater class. The deflater class compresses input
|
||||
/// with the deflate algorithm described in RFC 1951. It has several
|
||||
/// compression levels and three different strategies described below.
|
||||
///
|
||||
/// This class is <i>not</i> thread safe. This is inherent in the API, due
|
||||
/// to the split of deflate and setInput.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class Deflater
|
||||
{
|
||||
/// <summary>
|
||||
/// The best and slowest compression level. This tries to find very
|
||||
/// long and distant string repetitions.
|
||||
/// </summary>
|
||||
public static int BEST_COMPRESSION = 9;
|
||||
|
||||
/// <summary>
|
||||
/// The worst but fastest compression level.
|
||||
/// </summary>
|
||||
public static int BEST_SPEED = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The default compression level.
|
||||
/// </summary>
|
||||
public static int DEFAULT_COMPRESSION = -1;
|
||||
|
||||
/// <summary>
|
||||
/// This level won't compress at all but output uncompressed blocks.
|
||||
/// </summary>
|
||||
public static int NO_COMPRESSION = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The compression method. This is the only method supported so far.
|
||||
/// There is no need to use this constant at all.
|
||||
/// </summary>
|
||||
public static int DEFLATED = 8;
|
||||
|
||||
/*
|
||||
* The Deflater can do the following state transitions:
|
||||
*
|
||||
* (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---.
|
||||
* / | (2) (5) |
|
||||
* / v (5) |
|
||||
* (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3)
|
||||
* \ | (3) | ,-------'
|
||||
* | | | (3) /
|
||||
* v v (5) v v
|
||||
* (1) -> BUSY_STATE ----> FINISHING_STATE
|
||||
* | (6)
|
||||
* v
|
||||
* FINISHED_STATE
|
||||
* \_____________________________________/
|
||||
* | (7)
|
||||
* v
|
||||
* CLOSED_STATE
|
||||
*
|
||||
* (1) If we should produce a header we start in INIT_STATE, otherwise
|
||||
* we start in BUSY_STATE.
|
||||
* (2) A dictionary may be set only when we are in INIT_STATE, then
|
||||
* we change the state as indicated.
|
||||
* (3) Whether a dictionary is set or not, on the first call of deflate
|
||||
* we change to BUSY_STATE.
|
||||
* (4) -- intentionally left blank -- :)
|
||||
* (5) FINISHING_STATE is entered, when flush() is called to indicate that
|
||||
* there is no more INPUT. There are also states indicating, that
|
||||
* the header wasn't written yet.
|
||||
* (6) FINISHED_STATE is entered, when everything has been flushed to the
|
||||
* internal pending output buffer.
|
||||
* (7) At any time (7)
|
||||
*
|
||||
*/
|
||||
|
||||
private static int IS_SETDICT = 0x01;
|
||||
private static int IS_FLUSHING = 0x04;
|
||||
private static int IS_FINISHING = 0x08;
|
||||
|
||||
private static int INIT_STATE = 0x00;
|
||||
private static int SETDICT_STATE = 0x01;
|
||||
// private static int INIT_FINISHING_STATE = 0x08;
|
||||
// private static int SETDICT_FINISHING_STATE = 0x09;
|
||||
private static int BUSY_STATE = 0x10;
|
||||
private static int FLUSHING_STATE = 0x14;
|
||||
private static int FINISHING_STATE = 0x1c;
|
||||
private static int FINISHED_STATE = 0x1e;
|
||||
private static int CLOSED_STATE = 0x7f;
|
||||
|
||||
/// <summary>
|
||||
/// Compression level.
|
||||
/// </summary>
|
||||
private int level;
|
||||
|
||||
/// <summary>
|
||||
/// should we include a header.
|
||||
/// </summary>
|
||||
private bool noHeader;
|
||||
|
||||
// /// <summary>
|
||||
// /// Compression strategy.
|
||||
// /// </summary>
|
||||
// private int strategy;
|
||||
|
||||
/// <summary>
|
||||
/// The current state.
|
||||
/// </summary>
|
||||
private int state;
|
||||
|
||||
/// <summary>
|
||||
/// The total bytes of output written.
|
||||
/// </summary>
|
||||
private int totalOut;
|
||||
|
||||
/// <summary>
|
||||
/// The pending output.
|
||||
/// </summary>
|
||||
private DeflaterPending pending;
|
||||
|
||||
/// <summary>
|
||||
/// The deflater engine.
|
||||
/// </summary>
|
||||
private DeflaterEngine engine;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new deflater with default compression level.
|
||||
/// </summary>
|
||||
public Deflater() : this(DEFAULT_COMPRESSION, false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new deflater with given compression level.
|
||||
/// </summary>
|
||||
/// <param name="lvl">
|
||||
/// the compression level, a value between NO_COMPRESSION
|
||||
/// and BEST_COMPRESSION, or DEFAULT_COMPRESSION.
|
||||
/// </param>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">if lvl is out of range.</exception>
|
||||
public Deflater(int lvl) : this(lvl, false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new deflater with given compression level.
|
||||
/// </summary>
|
||||
/// <param name="lvl">
|
||||
/// the compression level, a value between NO_COMPRESSION
|
||||
/// and BEST_COMPRESSION.
|
||||
/// </param>
|
||||
/// <param name="nowrap">
|
||||
/// true, if we should suppress the deflate header at the
|
||||
/// beginning and the adler checksum at the end of the output. This is
|
||||
/// useful for the GZIP format.
|
||||
/// </param>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">if lvl is out of range.</exception>
|
||||
public Deflater(int lvl, bool nowrap)
|
||||
{
|
||||
if (lvl == DEFAULT_COMPRESSION) {
|
||||
lvl = 6;
|
||||
} else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) {
|
||||
throw new ArgumentOutOfRangeException("lvl");
|
||||
}
|
||||
|
||||
pending = new DeflaterPending();
|
||||
engine = new DeflaterEngine(pending);
|
||||
this.noHeader = nowrap;
|
||||
SetStrategy(DeflateStrategy.Default);
|
||||
SetLevel(lvl);
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets the deflater. The deflater acts afterwards as if it was
|
||||
/// just created with the same compression level and strategy as it
|
||||
/// had before.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
state = (noHeader ? BUSY_STATE : INIT_STATE);
|
||||
totalOut = 0;
|
||||
pending.Reset();
|
||||
engine.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current adler checksum of the data that was processed so far.
|
||||
/// </summary>
|
||||
public int Adler {
|
||||
get {
|
||||
return engine.Adler;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of input bytes processed so far.
|
||||
/// </summary>
|
||||
public int TotalIn {
|
||||
get {
|
||||
return engine.TotalIn;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of output bytes so far.
|
||||
/// </summary>
|
||||
public int TotalOut {
|
||||
get {
|
||||
return totalOut;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the current input block. Further calls to deflate() will
|
||||
/// produce enough output to inflate everything in the current input
|
||||
/// block. This is not part of Sun's JDK so I have made it package
|
||||
/// private. It is used by DeflaterOutputStream to implement
|
||||
/// flush().
|
||||
/// </summary>
|
||||
public void Flush()
|
||||
{
|
||||
state |= IS_FLUSHING;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finishes the deflater with the current input block. It is an error
|
||||
/// to give more input after this method was called. This method must
|
||||
/// be called to force all bytes to be flushed.
|
||||
/// </summary>
|
||||
public void Finish()
|
||||
{
|
||||
state |= IS_FLUSHING | IS_FINISHING;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the stream was finished and no more output bytes
|
||||
/// are available.
|
||||
/// </summary>
|
||||
public bool IsFinished {
|
||||
get {
|
||||
return state == FINISHED_STATE && pending.IsFlushed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the input buffer is empty.
|
||||
/// You should then call setInput().
|
||||
/// NOTE: This method can also return true when the stream
|
||||
/// was finished.
|
||||
/// </summary>
|
||||
public bool IsNeedingInput {
|
||||
get {
|
||||
return engine.NeedsInput();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data which should be compressed next. This should be only
|
||||
/// called when needsInput indicates that more input is needed.
|
||||
/// If you call setInput when needsInput() returns false, the
|
||||
/// previous input that is still pending will be thrown away.
|
||||
/// The given byte array should not be changed, before needsInput() returns
|
||||
/// true again.
|
||||
/// This call is equivalent to <code>setInput(input, 0, input.length)</code>.
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
/// the buffer containing the input data.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if the buffer was finished() or ended().
|
||||
/// </exception>
|
||||
public void SetInput(byte[] input)
|
||||
{
|
||||
SetInput(input, 0, input.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data which should be compressed next. This should be
|
||||
/// only called when needsInput indicates that more input is needed.
|
||||
/// The given byte array should not be changed, before needsInput() returns
|
||||
/// true again.
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
/// the buffer containing the input data.
|
||||
/// </param>
|
||||
/// <param name="off">
|
||||
/// the start of the data.
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the length of the data.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if the buffer was finished() or ended() or if previous input is still pending.
|
||||
/// </exception>
|
||||
public void SetInput(byte[] input, int off, int len)
|
||||
{
|
||||
if ((state & IS_FINISHING) != 0) {
|
||||
throw new InvalidOperationException("finish()/end() already called");
|
||||
}
|
||||
engine.SetInput(input, off, len);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the compression level. There is no guarantee of the exact
|
||||
/// position of the change, but if you call this when needsInput is
|
||||
/// true the change of compression level will occur somewhere near
|
||||
/// before the end of the so far given input.
|
||||
/// </summary>
|
||||
/// <param name="lvl">
|
||||
/// the new compression level.
|
||||
/// </param>
|
||||
public void SetLevel(int lvl)
|
||||
{
|
||||
if (lvl == DEFAULT_COMPRESSION) {
|
||||
lvl = 6;
|
||||
} else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) {
|
||||
throw new ArgumentOutOfRangeException("lvl");
|
||||
}
|
||||
|
||||
|
||||
if (level != lvl) {
|
||||
level = lvl;
|
||||
engine.SetLevel(lvl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the compression strategy. Strategy is one of
|
||||
/// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact
|
||||
/// position where the strategy is changed, the same as for
|
||||
/// setLevel() applies.
|
||||
/// </summary>
|
||||
/// <param name="stgy">
|
||||
/// the new compression strategy.
|
||||
/// </param>
|
||||
public void SetStrategy(DeflateStrategy stgy)
|
||||
{
|
||||
engine.Strategy = stgy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deflates the current input block to the given array. It returns
|
||||
/// the number of bytes compressed, or 0 if either
|
||||
/// needsInput() or finished() returns true or length is zero.
|
||||
/// </summary>
|
||||
/// <param name="output">
|
||||
/// the buffer where to write the compressed data.
|
||||
/// </param>
|
||||
public int Deflate(byte[] output)
|
||||
{
|
||||
return Deflate(output, 0, output.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deflates the current input block to the given array. It returns
|
||||
/// the number of bytes compressed, or 0 if either
|
||||
/// needsInput() or finished() returns true or length is zero.
|
||||
/// </summary>
|
||||
/// <param name="output">
|
||||
/// the buffer where to write the compressed data.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// the offset into the output array.
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// the maximum number of bytes that may be written.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if end() was called.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if offset and/or length don't match the array length.
|
||||
/// </exception>
|
||||
public int Deflate(byte[] output, int offset, int length)
|
||||
{
|
||||
int origLength = length;
|
||||
|
||||
if (state == CLOSED_STATE) {
|
||||
throw new InvalidOperationException("Deflater closed");
|
||||
}
|
||||
|
||||
if (state < BUSY_STATE) {
|
||||
/* output header */
|
||||
int header = (DEFLATED +
|
||||
((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8;
|
||||
int level_flags = (level - 1) >> 1;
|
||||
if (level_flags < 0 || level_flags > 3) {
|
||||
level_flags = 3;
|
||||
}
|
||||
header |= level_flags << 6;
|
||||
if ((state & IS_SETDICT) != 0) {
|
||||
/* Dictionary was set */
|
||||
header |= DeflaterConstants.PRESET_DICT;
|
||||
}
|
||||
header += 31 - (header % 31);
|
||||
|
||||
|
||||
pending.WriteShortMSB(header);
|
||||
if ((state & IS_SETDICT) != 0) {
|
||||
int chksum = engine.Adler;
|
||||
engine.ResetAdler();
|
||||
pending.WriteShortMSB(chksum >> 16);
|
||||
pending.WriteShortMSB(chksum & 0xffff);
|
||||
}
|
||||
|
||||
state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING));
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int count = pending.Flush(output, offset, length);
|
||||
offset += count;
|
||||
totalOut += count;
|
||||
length -= count;
|
||||
|
||||
if (length == 0 || state == FINISHED_STATE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) {
|
||||
if (state == BUSY_STATE) {
|
||||
/* We need more input now */
|
||||
return origLength - length;
|
||||
} else if (state == FLUSHING_STATE) {
|
||||
if (level != NO_COMPRESSION) {
|
||||
/* We have to supply some lookahead. 8 bit lookahead
|
||||
* are needed by the zlib inflater, and we must fill
|
||||
* the next byte, so that all bits are flushed.
|
||||
*/
|
||||
int neededbits = 8 + ((-pending.BitCount) & 7);
|
||||
while (neededbits > 0) {
|
||||
/* write a static tree block consisting solely of
|
||||
* an EOF:
|
||||
*/
|
||||
pending.WriteBits(2, 10);
|
||||
neededbits -= 10;
|
||||
}
|
||||
}
|
||||
state = BUSY_STATE;
|
||||
} else if (state == FINISHING_STATE) {
|
||||
pending.AlignToByte();
|
||||
/* We have completed the stream */
|
||||
if (!noHeader) {
|
||||
int adler = engine.Adler;
|
||||
pending.WriteShortMSB(adler >> 16);
|
||||
pending.WriteShortMSB(adler & 0xffff);
|
||||
}
|
||||
state = FINISHED_STATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return origLength - length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the dictionary which should be used in the deflate process.
|
||||
/// This call is equivalent to <code>setDictionary(dict, 0, dict.Length)</code>.
|
||||
/// </summary>
|
||||
/// <param name="dict">
|
||||
/// the dictionary.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if setInput () or deflate () were already called or another dictionary was already set.
|
||||
/// </exception>
|
||||
public void SetDictionary(byte[] dict)
|
||||
{
|
||||
SetDictionary(dict, 0, dict.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the dictionary which should be used in the deflate process.
|
||||
/// The dictionary should be a byte array containing strings that are
|
||||
/// likely to occur in the data which should be compressed. The
|
||||
/// dictionary is not stored in the compressed output, only a
|
||||
/// checksum. To decompress the output you need to supply the same
|
||||
/// dictionary again.
|
||||
/// </summary>
|
||||
/// <param name="dict">
|
||||
/// the dictionary.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// an offset into the dictionary.
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// the length of the dictionary.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if setInput () or deflate () were already called or another dictionary was already set.
|
||||
/// </exception>
|
||||
public void SetDictionary(byte[] dict, int offset, int length)
|
||||
{
|
||||
if (state != INIT_STATE) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
state = SETDICT_STATE;
|
||||
engine.SetDictionary(dict, offset, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
// DeflaterConstants.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for the deflater.
|
||||
/// </summary>
|
||||
public class DeflaterConstants
|
||||
{
|
||||
public const bool DEBUGGING = false;
|
||||
|
||||
public const int STORED_BLOCK = 0;
|
||||
public const int STATIC_TREES = 1;
|
||||
public const int DYN_TREES = 2;
|
||||
public const int PRESET_DICT = 0x20;
|
||||
|
||||
public const int DEFAULT_MEM_LEVEL = 8;
|
||||
|
||||
public const int MAX_MATCH = 258;
|
||||
public const int MIN_MATCH = 3;
|
||||
|
||||
public const int MAX_WBITS = 15;
|
||||
public const int WSIZE = 1 << MAX_WBITS;
|
||||
public const int WMASK = WSIZE - 1;
|
||||
|
||||
public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7;
|
||||
public const int HASH_SIZE = 1 << HASH_BITS;
|
||||
public const int HASH_MASK = HASH_SIZE - 1;
|
||||
public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH;
|
||||
|
||||
public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
|
||||
public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD;
|
||||
|
||||
public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8);
|
||||
public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE-5);
|
||||
|
||||
public const int DEFLATE_STORED = 0;
|
||||
public const int DEFLATE_FAST = 1;
|
||||
public const int DEFLATE_SLOW = 2;
|
||||
|
||||
public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 };
|
||||
public static int[] MAX_LAZY = { 0, 4, 5, 6, 4,16, 16, 32, 128, 258 };
|
||||
public static int[] NICE_LENGTH = { 0, 8,16,32,16,32,128,128, 258, 258 };
|
||||
public static int[] MAX_CHAIN = { 0, 4, 8,32,16,32,128,256,1024,4096 };
|
||||
public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
|
||||
}
|
||||
}
|
||||
+650
@@ -0,0 +1,650 @@
|
||||
// DeflaterEngine.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
public enum DeflateStrategy {
|
||||
// The default strategy.
|
||||
Default = 0,
|
||||
|
||||
// This strategy will only allow longer string repetitions. It is
|
||||
// useful for random data with a small character set.
|
||||
Filtered = 1,
|
||||
|
||||
// This strategy will not look for string repetitions at all. It
|
||||
// only encodes with Huffman trees (which means, that more common
|
||||
// characters get a smaller encoding.
|
||||
HuffmanOnly = 2
|
||||
}
|
||||
|
||||
public class DeflaterEngine : DeflaterConstants
|
||||
{
|
||||
static int TOO_FAR = 4096;
|
||||
|
||||
int ins_h;
|
||||
// private byte[] buffer;
|
||||
short[] head;
|
||||
short[] prev;
|
||||
|
||||
int matchStart, matchLen;
|
||||
bool prevAvailable;
|
||||
int blockStart;
|
||||
int strstart, lookahead;
|
||||
byte[] window;
|
||||
|
||||
DeflateStrategy strategy;
|
||||
int max_chain, max_lazy, niceLength, goodLength;
|
||||
|
||||
/// <summary>
|
||||
/// The current compression function.
|
||||
/// </summary>
|
||||
int comprFunc;
|
||||
|
||||
/// <summary>
|
||||
/// The input data for compression.
|
||||
/// </summary>
|
||||
byte[] inputBuf;
|
||||
|
||||
/// <summary>
|
||||
/// The total bytes of input read.
|
||||
/// </summary>
|
||||
int totalIn;
|
||||
|
||||
/// <summary>
|
||||
/// The offset into inputBuf, where input data starts.
|
||||
/// </summary>
|
||||
int inputOff;
|
||||
|
||||
/// <summary>
|
||||
/// The end offset of the input data.
|
||||
/// </summary>
|
||||
int inputEnd;
|
||||
|
||||
DeflaterPending pending;
|
||||
DeflaterHuffman huffman;
|
||||
|
||||
/// <summary>
|
||||
/// The adler checksum
|
||||
/// </summary>
|
||||
Adler32 adler;
|
||||
|
||||
public DeflaterEngine(DeflaterPending pending)
|
||||
{
|
||||
this.pending = pending;
|
||||
huffman = new DeflaterHuffman(pending);
|
||||
adler = new Adler32();
|
||||
|
||||
window = new byte[2 * WSIZE];
|
||||
head = new short[HASH_SIZE];
|
||||
prev = new short[WSIZE];
|
||||
|
||||
/* We start at index 1, to avoid a implementation deficiency, that
|
||||
* we cannot build a repeat pattern at index 0.
|
||||
*/
|
||||
blockStart = strstart = 1;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
huffman.Reset();
|
||||
adler.Reset();
|
||||
blockStart = strstart = 1;
|
||||
lookahead = 0;
|
||||
totalIn = 0;
|
||||
prevAvailable = false;
|
||||
matchLen = MIN_MATCH - 1;
|
||||
|
||||
for (int i = 0; i < HASH_SIZE; i++) {
|
||||
head[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < WSIZE; i++) {
|
||||
prev[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAdler()
|
||||
{
|
||||
adler.Reset();
|
||||
}
|
||||
|
||||
public int Adler {
|
||||
get {
|
||||
return (int)adler.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalIn {
|
||||
get {
|
||||
return totalIn;
|
||||
}
|
||||
}
|
||||
|
||||
public DeflateStrategy Strategy {
|
||||
get {
|
||||
return strategy;
|
||||
}
|
||||
set {
|
||||
strategy = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLevel(int lvl)
|
||||
{
|
||||
goodLength = DeflaterConstants.GOOD_LENGTH[lvl];
|
||||
max_lazy = DeflaterConstants.MAX_LAZY[lvl];
|
||||
niceLength = DeflaterConstants.NICE_LENGTH[lvl];
|
||||
max_chain = DeflaterConstants.MAX_CHAIN[lvl];
|
||||
|
||||
if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Change from "+comprFunc +" to "
|
||||
// + DeflaterConstants.COMPR_FUNC[lvl]);
|
||||
// }
|
||||
switch (comprFunc) {
|
||||
case DEFLATE_STORED:
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushStoredBlock(window, blockStart,
|
||||
strstart - blockStart, false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
UpdateHash();
|
||||
break;
|
||||
case DEFLATE_FAST:
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
break;
|
||||
case DEFLATE_SLOW:
|
||||
if (prevAvailable) {
|
||||
huffman.TallyLit(window[strstart-1] & 0xff);
|
||||
}
|
||||
if (strstart > blockStart) {
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
false);
|
||||
blockStart = strstart;
|
||||
}
|
||||
prevAvailable = false;
|
||||
matchLen = MIN_MATCH - 1;
|
||||
break;
|
||||
}
|
||||
comprFunc = COMPR_FUNC[lvl];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHash()
|
||||
{
|
||||
// if (DEBUGGING) {
|
||||
// Console.WriteLine("updateHash: "+strstart);
|
||||
// }
|
||||
ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1];
|
||||
}
|
||||
|
||||
private int InsertString()
|
||||
{
|
||||
short match;
|
||||
int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK;
|
||||
|
||||
// if (DEBUGGING) {
|
||||
// if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^
|
||||
// (window[strstart + 1] << HASH_SHIFT) ^
|
||||
// (window[strstart + 2])) & HASH_MASK)) {
|
||||
// throw new Exception("hash inconsistent: "+hash+"/"
|
||||
// +window[strstart]+","
|
||||
// +window[strstart+1]+","
|
||||
// +window[strstart+2]+","+HASH_SHIFT);
|
||||
// }
|
||||
// }
|
||||
|
||||
prev[strstart & WMASK] = match = head[hash];
|
||||
head[hash] = (short)strstart;
|
||||
ins_h = hash;
|
||||
return match & 0xffff;
|
||||
}
|
||||
|
||||
void SlideWindow()
|
||||
{
|
||||
Array.Copy(window, WSIZE, window, 0, WSIZE);
|
||||
matchStart -= WSIZE;
|
||||
strstart -= WSIZE;
|
||||
blockStart -= WSIZE;
|
||||
|
||||
/* Slide the hash table (could be avoided with 32 bit values
|
||||
* at the expense of memory usage).
|
||||
*/
|
||||
for (int i = 0; i < HASH_SIZE; ++i) {
|
||||
int m = head[i] & 0xffff;
|
||||
head[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0);
|
||||
}
|
||||
|
||||
/* Slide the prev table. */
|
||||
for (int i = 0; i < WSIZE; i++) {
|
||||
int m = prev[i] & 0xffff;
|
||||
prev[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void FillWindow()
|
||||
{
|
||||
/* If the window is almost full and there is insufficient lookahead,
|
||||
* move the upper half to the lower one to make room in the upper half.
|
||||
*/
|
||||
if (strstart >= WSIZE + MAX_DIST) {
|
||||
SlideWindow();
|
||||
}
|
||||
|
||||
/* If there is not enough lookahead, but still some input left,
|
||||
* read in the input
|
||||
*/
|
||||
while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) {
|
||||
int more = 2 * WSIZE - lookahead - strstart;
|
||||
|
||||
if (more > inputEnd - inputOff) {
|
||||
more = inputEnd - inputOff;
|
||||
}
|
||||
|
||||
System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more);
|
||||
adler.Update(inputBuf, inputOff, more);
|
||||
|
||||
inputOff += more;
|
||||
totalIn += more;
|
||||
lookahead += more;
|
||||
}
|
||||
|
||||
if (lookahead >= MIN_MATCH) {
|
||||
UpdateHash();
|
||||
}
|
||||
}
|
||||
|
||||
private bool FindLongestMatch(int curMatch)
|
||||
{
|
||||
int chainLength = this.max_chain;
|
||||
int niceLength = this.niceLength;
|
||||
short[] prev = this.prev;
|
||||
int scan = this.strstart;
|
||||
int match;
|
||||
int best_end = this.strstart + matchLen;
|
||||
int best_len = Math.Max(matchLen, MIN_MATCH - 1);
|
||||
|
||||
int limit = Math.Max(strstart - MAX_DIST, 0);
|
||||
|
||||
int strend = strstart + MAX_MATCH - 1;
|
||||
byte scan_end1 = window[best_end - 1];
|
||||
byte scan_end = window[best_end];
|
||||
|
||||
/* Do not waste too much time if we already have a good match: */
|
||||
if (best_len >= this.goodLength) {
|
||||
chainLength >>= 2;
|
||||
}
|
||||
|
||||
/* Do not look for matches beyond the end of the input. This is necessary
|
||||
* to make deflate deterministic.
|
||||
*/
|
||||
if (niceLength > lookahead) {
|
||||
niceLength = lookahead;
|
||||
}
|
||||
|
||||
if (DeflaterConstants.DEBUGGING && strstart > 2 * WSIZE - MIN_LOOKAHEAD) {
|
||||
throw new InvalidOperationException("need lookahead");
|
||||
}
|
||||
|
||||
do {
|
||||
if (DeflaterConstants.DEBUGGING && curMatch >= strstart) {
|
||||
throw new InvalidOperationException("future match");
|
||||
}
|
||||
if (window[curMatch + best_len] != scan_end ||
|
||||
window[curMatch + best_len - 1] != scan_end1 ||
|
||||
window[curMatch] != window[scan] ||
|
||||
window[curMatch + 1] != window[scan + 1]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = curMatch + 2;
|
||||
scan += 2;
|
||||
|
||||
/* We check for insufficient lookahead only every 8th comparison;
|
||||
* the 256th check will be made at strstart+258.
|
||||
*/
|
||||
while (window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] &&
|
||||
window[++scan] == window[++match] && scan < strend) ;
|
||||
|
||||
if (scan > best_end) {
|
||||
// if (DeflaterConstants.DEBUGGING && ins_h == 0)
|
||||
// System.err.println("Found match: "+curMatch+"-"+(scan-strstart));
|
||||
matchStart = curMatch;
|
||||
best_end = scan;
|
||||
best_len = scan - strstart;
|
||||
if (best_len >= niceLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
scan_end1 = window[best_end - 1];
|
||||
scan_end = window[best_end];
|
||||
}
|
||||
scan = strstart;
|
||||
} while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit && --chainLength != 0);
|
||||
|
||||
matchLen = Math.Min(best_len, lookahead);
|
||||
return matchLen >= MIN_MATCH;
|
||||
}
|
||||
|
||||
public void SetDictionary(byte[] buffer, int offset, int length)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && strstart != 1) {
|
||||
throw new InvalidOperationException("strstart not 1");
|
||||
}
|
||||
adler.Update(buffer, offset, length);
|
||||
if (length < MIN_MATCH) {
|
||||
return;
|
||||
}
|
||||
if (length > MAX_DIST) {
|
||||
offset += length - MAX_DIST;
|
||||
length = MAX_DIST;
|
||||
}
|
||||
|
||||
System.Array.Copy(buffer, offset, window, strstart, length);
|
||||
|
||||
UpdateHash();
|
||||
--length;
|
||||
while (--length > 0) {
|
||||
InsertString();
|
||||
strstart++;
|
||||
}
|
||||
strstart += 2;
|
||||
blockStart = strstart;
|
||||
}
|
||||
|
||||
private bool DeflateStored(bool flush, bool finish)
|
||||
{
|
||||
if (!flush && lookahead == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
strstart += lookahead;
|
||||
lookahead = 0;
|
||||
|
||||
int storedLen = strstart - blockStart;
|
||||
|
||||
if ((storedLen >= DeflaterConstants.MAX_BLOCK_SIZE) || /* Block is full */
|
||||
(blockStart < WSIZE && storedLen >= MAX_DIST) || /* Block may move out of window */
|
||||
flush) {
|
||||
bool lastBlock = finish;
|
||||
if (storedLen > DeflaterConstants.MAX_BLOCK_SIZE) {
|
||||
storedLen = DeflaterConstants.MAX_BLOCK_SIZE;
|
||||
lastBlock = false;
|
||||
}
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]");
|
||||
// }
|
||||
|
||||
huffman.FlushStoredBlock(window, blockStart, storedLen, lastBlock);
|
||||
blockStart += storedLen;
|
||||
return !lastBlock;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DeflateFast(bool flush, bool finish)
|
||||
{
|
||||
if (lookahead < MIN_LOOKAHEAD && !flush) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (lookahead >= MIN_LOOKAHEAD || flush) {
|
||||
if (lookahead == 0) {
|
||||
/* We are flushing everything */
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart, finish);
|
||||
blockStart = strstart;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstart > 2 * WSIZE - MIN_LOOKAHEAD)
|
||||
{
|
||||
/* slide window, as findLongestMatch need this.
|
||||
* This should only happen when flushing and the window
|
||||
* is almost full.
|
||||
*/
|
||||
SlideWindow();
|
||||
}
|
||||
|
||||
int hashHead;
|
||||
if (lookahead >= MIN_MATCH &&
|
||||
(hashHead = InsertString()) != 0 &&
|
||||
strategy != DeflateStrategy.HuffmanOnly &&
|
||||
strstart - hashHead <= MAX_DIST &&
|
||||
FindLongestMatch(hashHead)) {
|
||||
/* longestMatch sets matchStart and matchLen */
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart+i] != window[matchStart + i]) {
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
huffman.TallyDist(strstart - matchStart, matchLen);
|
||||
|
||||
lookahead -= matchLen;
|
||||
if (matchLen <= max_lazy && lookahead >= MIN_MATCH) {
|
||||
while (--matchLen > 0) {
|
||||
++strstart;
|
||||
InsertString();
|
||||
}
|
||||
++strstart;
|
||||
} else {
|
||||
strstart += matchLen;
|
||||
if (lookahead >= MIN_MATCH - 1) {
|
||||
UpdateHash();
|
||||
}
|
||||
}
|
||||
matchLen = MIN_MATCH - 1;
|
||||
continue;
|
||||
} else {
|
||||
/* No match found */
|
||||
huffman.TallyLit(window[strstart] & 0xff);
|
||||
++strstart;
|
||||
--lookahead;
|
||||
}
|
||||
|
||||
if (huffman.IsFull()) {
|
||||
bool lastBlock = finish && lookahead == 0;
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
lastBlock);
|
||||
blockStart = strstart;
|
||||
return !lastBlock;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DeflateSlow(bool flush, bool finish)
|
||||
{
|
||||
if (lookahead < MIN_LOOKAHEAD && !flush) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (lookahead >= MIN_LOOKAHEAD || flush) {
|
||||
if (lookahead == 0) {
|
||||
if (prevAvailable) {
|
||||
huffman.TallyLit(window[strstart-1] & 0xff);
|
||||
}
|
||||
prevAvailable = false;
|
||||
|
||||
/* We are flushing everything */
|
||||
if (DeflaterConstants.DEBUGGING && !flush) {
|
||||
throw new Exception("Not flushing, but no lookahead");
|
||||
}
|
||||
huffman.FlushBlock(window, blockStart, strstart - blockStart,
|
||||
finish);
|
||||
blockStart = strstart;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD)
|
||||
{
|
||||
/* slide window, as findLongestMatch need this.
|
||||
* This should only happen when flushing and the window
|
||||
* is almost full.
|
||||
*/
|
||||
SlideWindow();
|
||||
}
|
||||
|
||||
int prevMatch = matchStart;
|
||||
int prevLen = matchLen;
|
||||
if (lookahead >= MIN_MATCH) {
|
||||
int hashHead = InsertString();
|
||||
if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead))
|
||||
{
|
||||
/* longestMatch sets matchStart and matchLen */
|
||||
|
||||
/* Discard match if too small and too far away */
|
||||
if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) {
|
||||
matchLen = MIN_MATCH - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* previous match was better */
|
||||
if (prevLen >= MIN_MATCH && matchLen <= prevLen) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// for (int i = 0 ; i < matchLen; i++) {
|
||||
// if (window[strstart-1+i] != window[prevMatch + i])
|
||||
// throw new Exception();
|
||||
// }
|
||||
// }
|
||||
huffman.TallyDist(strstart - 1 - prevMatch, prevLen);
|
||||
prevLen -= 2;
|
||||
do {
|
||||
strstart++;
|
||||
lookahead--;
|
||||
if (lookahead >= MIN_MATCH) {
|
||||
InsertString();
|
||||
}
|
||||
} while (--prevLen > 0);
|
||||
strstart ++;
|
||||
lookahead--;
|
||||
prevAvailable = false;
|
||||
matchLen = MIN_MATCH - 1;
|
||||
} else {
|
||||
if (prevAvailable) {
|
||||
huffman.TallyLit(window[strstart-1] & 0xff);
|
||||
}
|
||||
prevAvailable = true;
|
||||
strstart++;
|
||||
lookahead--;
|
||||
}
|
||||
|
||||
if (huffman.IsFull()) {
|
||||
int len = strstart - blockStart;
|
||||
if (prevAvailable) {
|
||||
len--;
|
||||
}
|
||||
bool lastBlock = (finish && lookahead == 0 && !prevAvailable);
|
||||
huffman.FlushBlock(window, blockStart, len, lastBlock);
|
||||
blockStart += len;
|
||||
return !lastBlock;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Deflate(bool flush, bool finish)
|
||||
{
|
||||
bool progress;
|
||||
do {
|
||||
FillWindow();
|
||||
bool canFlush = flush && inputOff == inputEnd;
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("window: ["+blockStart+","+strstart+","
|
||||
// +lookahead+"], "+comprFunc+","+canFlush);
|
||||
// }
|
||||
switch (comprFunc) {
|
||||
case DEFLATE_STORED:
|
||||
progress = DeflateStored(canFlush, finish);
|
||||
break;
|
||||
case DEFLATE_FAST:
|
||||
progress = DeflateFast(canFlush, finish);
|
||||
break;
|
||||
case DEFLATE_SLOW:
|
||||
progress = DeflateSlow(canFlush, finish);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("unknown comprFunc");
|
||||
}
|
||||
} while (pending.IsFlushed && progress); /* repeat while we have no pending output and progress was made */
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void SetInput(byte[] buf, int off, int len)
|
||||
{
|
||||
if (inputOff < inputEnd) {
|
||||
throw new InvalidOperationException("Old input was not completely processed");
|
||||
}
|
||||
|
||||
int end = off + len;
|
||||
|
||||
/* We want to throw an ArrayIndexOutOfBoundsException early. The
|
||||
* check is very tricky: it also handles integer wrap around.
|
||||
*/
|
||||
if (0 > off || off > end || end > buf.Length) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
inputBuf = buf;
|
||||
inputOff = off;
|
||||
inputEnd = end;
|
||||
}
|
||||
|
||||
public bool NeedsInput()
|
||||
{
|
||||
return inputEnd == inputOff;
|
||||
}
|
||||
}
|
||||
}
|
||||
+778
@@ -0,0 +1,778 @@
|
||||
// DeflaterHuffman.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This is the DeflaterHuffman class.
|
||||
///
|
||||
/// This class is <i>not</i> thread safe. This is inherent in the API, due
|
||||
/// to the split of deflate and setInput.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class DeflaterHuffman
|
||||
{
|
||||
private static int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6);
|
||||
private static int LITERAL_NUM = 286;
|
||||
private static int DIST_NUM = 30;
|
||||
private static int BITLEN_NUM = 19;
|
||||
private static int REP_3_6 = 16;
|
||||
private static int REP_3_10 = 17;
|
||||
private static int REP_11_138 = 18;
|
||||
private static int EOF_SYMBOL = 256;
|
||||
private static int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||
|
||||
private static byte[] bit4Reverse = {
|
||||
0,
|
||||
8,
|
||||
4,
|
||||
12,
|
||||
2,
|
||||
10,
|
||||
6,
|
||||
14,
|
||||
1,
|
||||
9,
|
||||
5,
|
||||
13,
|
||||
3,
|
||||
11,
|
||||
7,
|
||||
15
|
||||
};
|
||||
|
||||
|
||||
public class Tree
|
||||
{
|
||||
public short[] freqs;
|
||||
public short[] codes;
|
||||
public byte[] length;
|
||||
public int[] bl_counts;
|
||||
public int minNumCodes, numCodes;
|
||||
public int maxLength;
|
||||
DeflaterHuffman dh;
|
||||
|
||||
public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength)
|
||||
{
|
||||
this.dh = dh;
|
||||
this.minNumCodes = minCodes;
|
||||
this.maxLength = maxLength;
|
||||
freqs = new short[elems];
|
||||
bl_counts = new int[maxLength];
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
for (int i = 0; i < freqs.Length; i++) {
|
||||
freqs[i] = 0;
|
||||
}
|
||||
codes = null;
|
||||
length = null;
|
||||
}
|
||||
|
||||
public void WriteSymbol(int code)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// freqs[code]--;
|
||||
// // Console.Write("writeSymbol("+freqs.length+","+code+"): ");
|
||||
// }
|
||||
dh.pending.WriteBits(codes[code] & 0xffff, length[code]);
|
||||
}
|
||||
|
||||
public void CheckEmpty()
|
||||
{
|
||||
bool empty = true;
|
||||
for (int i = 0; i < freqs.Length; i++) {
|
||||
if (freqs[i] != 0) {
|
||||
Console.WriteLine("freqs["+i+"] == "+freqs[i]);
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
if (!empty) {
|
||||
throw new Exception();
|
||||
}
|
||||
Console.WriteLine("checkEmpty suceeded!");
|
||||
}
|
||||
|
||||
public void SetStaticCodes(short[] stCodes, byte[] stLength)
|
||||
{
|
||||
codes = stCodes;
|
||||
length = stLength;
|
||||
}
|
||||
|
||||
public void BuildCodes()
|
||||
{
|
||||
int numSymbols = freqs.Length;
|
||||
int[] nextCode = new int[maxLength];
|
||||
int code = 0;
|
||||
codes = new short[freqs.Length];
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("buildCodes: "+freqs.Length);
|
||||
// }
|
||||
|
||||
for (int bits = 0; bits < maxLength; bits++) {
|
||||
nextCode[bits] = code;
|
||||
code += bl_counts[bits] << (15 - bits);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("bits: "+(bits+1)+" count: "+bl_counts[bits]
|
||||
// +" nextCode: "+code); // HACK : Integer.toHexString(
|
||||
// }
|
||||
}
|
||||
if (DeflaterConstants.DEBUGGING && code != 65536) {
|
||||
throw new Exception("Inconsistent bl_counts!");
|
||||
}
|
||||
|
||||
for (int i=0; i < numCodes; i++) {
|
||||
int bits = length[i];
|
||||
if (bits > 0) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+")," // HACK : Integer.toHexString(
|
||||
// +bits);
|
||||
// }
|
||||
codes[i] = BitReverse(nextCode[bits-1]);
|
||||
nextCode[bits-1] += 1 << (16 - bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildLength(int[] childs)
|
||||
{
|
||||
this.length = new byte [freqs.Length];
|
||||
int numNodes = childs.Length / 2;
|
||||
int numLeafs = (numNodes + 1) / 2;
|
||||
int overflow = 0;
|
||||
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
bl_counts[i] = 0;
|
||||
}
|
||||
|
||||
/* First calculate optimal bit lengths */
|
||||
int[] lengths = new int[numNodes];
|
||||
lengths[numNodes-1] = 0;
|
||||
|
||||
for (int i = numNodes - 1; i >= 0; i--) {
|
||||
if (childs[2*i+1] != -1) {
|
||||
int bitLength = lengths[i] + 1;
|
||||
if (bitLength > maxLength) {
|
||||
bitLength = maxLength;
|
||||
overflow++;
|
||||
}
|
||||
lengths[childs[2*i]] = lengths[childs[2*i+1]] = bitLength;
|
||||
} else {
|
||||
/* A leaf node */
|
||||
int bitLength = lengths[i];
|
||||
bl_counts[bitLength - 1]++;
|
||||
this.length[childs[2*i]] = (byte) lengths[i];
|
||||
}
|
||||
}
|
||||
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Tree "+freqs.Length+" lengths:");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (overflow == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int incrBitLen = maxLength - 1;
|
||||
do {
|
||||
/* Find the first bit length which could increase: */
|
||||
while (bl_counts[--incrBitLen] == 0)
|
||||
;
|
||||
|
||||
/* Move this node one down and remove a corresponding
|
||||
* amount of overflow nodes.
|
||||
*/
|
||||
do {
|
||||
bl_counts[incrBitLen]--;
|
||||
bl_counts[++incrBitLen]++;
|
||||
overflow -= 1 << (maxLength - 1 - incrBitLen);
|
||||
} while (overflow > 0 && incrBitLen < maxLength - 1);
|
||||
} while (overflow > 0);
|
||||
|
||||
/* We may have overshot above. Move some nodes from maxLength to
|
||||
* maxLength-1 in that case.
|
||||
*/
|
||||
bl_counts[maxLength-1] += overflow;
|
||||
bl_counts[maxLength-2] -= overflow;
|
||||
|
||||
/* Now recompute all bit lengths, scanning in increasing
|
||||
* frequency. It is simpler to reconstruct all lengths instead of
|
||||
* fixing only the wrong ones. This idea is taken from 'ar'
|
||||
* written by Haruhiko Okumura.
|
||||
*
|
||||
* The nodes were inserted with decreasing frequency into the childs
|
||||
* array.
|
||||
*/
|
||||
int nodePtr = 2 * numLeafs;
|
||||
for (int bits = maxLength; bits != 0; bits--) {
|
||||
int n = bl_counts[bits-1];
|
||||
while (n > 0) {
|
||||
int childPtr = 2*childs[nodePtr++];
|
||||
if (childs[childPtr + 1] == -1) {
|
||||
/* We found another leaf */
|
||||
length[childs[childPtr]] = (byte) bits;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("*** After overflow elimination. ***");
|
||||
// for (int i=0; i < numLeafs; i++) {
|
||||
// Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
|
||||
// + " len: "+length[childs[2*i]]);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public void BuildTree()
|
||||
{
|
||||
int numSymbols = freqs.Length;
|
||||
|
||||
/* heap is a priority queue, sorted by frequency, least frequent
|
||||
* nodes first. The heap is a binary tree, with the property, that
|
||||
* the parent node is smaller than both child nodes. This assures
|
||||
* that the smallest node is the first parent.
|
||||
*
|
||||
* The binary tree is encoded in an array: 0 is root node and
|
||||
* the nodes 2*n+1, 2*n+2 are the child nodes of node n.
|
||||
*/
|
||||
int[] heap = new int[numSymbols];
|
||||
int heapLen = 0;
|
||||
int maxCode = 0;
|
||||
for (int n = 0; n < numSymbols; n++) {
|
||||
int freq = freqs[n];
|
||||
if (freq != 0) {
|
||||
/* Insert n into heap */
|
||||
int pos = heapLen++;
|
||||
int ppos;
|
||||
while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) {
|
||||
heap[pos] = heap[ppos];
|
||||
pos = ppos;
|
||||
}
|
||||
heap[pos] = n;
|
||||
|
||||
maxCode = n;
|
||||
}
|
||||
}
|
||||
|
||||
/* We could encode a single literal with 0 bits but then we
|
||||
* don't see the literals. Therefore we force at least two
|
||||
* literals to avoid this case. We don't care about order in
|
||||
* this case, both literals get a 1 bit code.
|
||||
*/
|
||||
while (heapLen < 2) {
|
||||
int node = maxCode < 2 ? ++maxCode : 0;
|
||||
heap[heapLen++] = node;
|
||||
}
|
||||
|
||||
numCodes = Math.Max(maxCode + 1, minNumCodes);
|
||||
|
||||
int numLeafs = heapLen;
|
||||
int[] childs = new int[4*heapLen - 2];
|
||||
int[] values = new int[2*heapLen - 1];
|
||||
int numNodes = numLeafs;
|
||||
for (int i = 0; i < heapLen; i++) {
|
||||
int node = heap[i];
|
||||
childs[2*i] = node;
|
||||
childs[2*i+1] = -1;
|
||||
values[i] = freqs[node] << 8;
|
||||
heap[i] = i;
|
||||
}
|
||||
|
||||
/* Construct the Huffman tree by repeatedly combining the least two
|
||||
* frequent nodes.
|
||||
*/
|
||||
do {
|
||||
int first = heap[0];
|
||||
int last = heap[--heapLen];
|
||||
|
||||
/* Propagate the hole to the leafs of the heap */
|
||||
int ppos = 0;
|
||||
int path = 1;
|
||||
while (path < heapLen) {
|
||||
if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) {
|
||||
path++;
|
||||
}
|
||||
|
||||
heap[ppos] = heap[path];
|
||||
ppos = path;
|
||||
path = path * 2 + 1;
|
||||
}
|
||||
|
||||
/* Now propagate the last element down along path. Normally
|
||||
* it shouldn't go too deep.
|
||||
*/
|
||||
int lastVal = values[last];
|
||||
while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) {
|
||||
heap[path] = heap[ppos];
|
||||
}
|
||||
heap[path] = last;
|
||||
|
||||
|
||||
int second = heap[0];
|
||||
|
||||
/* Create a new node father of first and second */
|
||||
last = numNodes++;
|
||||
childs[2*last] = first;
|
||||
childs[2*last+1] = second;
|
||||
int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff);
|
||||
values[last] = lastVal = values[first] + values[second] - mindepth + 1;
|
||||
|
||||
/* Again, propagate the hole to the leafs */
|
||||
ppos = 0;
|
||||
path = 1;
|
||||
while (path < heapLen) {
|
||||
if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) {
|
||||
path++;
|
||||
}
|
||||
|
||||
heap[ppos] = heap[path];
|
||||
ppos = path;
|
||||
path = ppos * 2 + 1;
|
||||
}
|
||||
|
||||
/* Now propagate the new element down along path */
|
||||
while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) {
|
||||
heap[path] = heap[ppos];
|
||||
}
|
||||
heap[path] = last;
|
||||
} while (heapLen > 1);
|
||||
|
||||
if (heap[0] != childs.Length / 2 - 1) {
|
||||
throw new Exception("Weird!");
|
||||
}
|
||||
BuildLength(childs);
|
||||
}
|
||||
|
||||
public int GetEncodedLength()
|
||||
{
|
||||
int len = 0;
|
||||
for (int i = 0; i < freqs.Length; i++) {
|
||||
len += freqs[i] * length[i];
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
public void CalcBLFreq(Tree blTree)
|
||||
{
|
||||
int max_count; /* max repeat count */
|
||||
int min_count; /* min repeat count */
|
||||
int count; /* repeat count of the current code */
|
||||
int curlen = -1; /* length of current code */
|
||||
|
||||
int i = 0;
|
||||
while (i < numCodes) {
|
||||
count = 1;
|
||||
int nextlen = length[i];
|
||||
if (nextlen == 0) {
|
||||
max_count = 138;
|
||||
min_count = 3;
|
||||
} else {
|
||||
max_count = 6;
|
||||
min_count = 3;
|
||||
if (curlen != nextlen) {
|
||||
blTree.freqs[nextlen]++;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
curlen = nextlen;
|
||||
i++;
|
||||
|
||||
while (i < numCodes && curlen == length[i]) {
|
||||
i++;
|
||||
if (++count >= max_count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < min_count) {
|
||||
blTree.freqs[curlen] += (short)count;
|
||||
} else if (curlen != 0) {
|
||||
blTree.freqs[REP_3_6]++;
|
||||
} else if (count <= 10) {
|
||||
blTree.freqs[REP_3_10]++;
|
||||
} else {
|
||||
blTree.freqs[REP_11_138]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteTree(Tree blTree)
|
||||
{
|
||||
int max_count; /* max repeat count */
|
||||
int min_count; /* min repeat count */
|
||||
int count; /* repeat count of the current code */
|
||||
int curlen = -1; /* length of current code */
|
||||
|
||||
int i = 0;
|
||||
while (i < numCodes) {
|
||||
count = 1;
|
||||
int nextlen = length[i];
|
||||
if (nextlen == 0) {
|
||||
max_count = 138;
|
||||
min_count = 3;
|
||||
} else {
|
||||
max_count = 6;
|
||||
min_count = 3;
|
||||
if (curlen != nextlen) {
|
||||
blTree.WriteSymbol(nextlen);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
curlen = nextlen;
|
||||
i++;
|
||||
|
||||
while (i < numCodes && curlen == length[i]) {
|
||||
i++;
|
||||
if (++count >= max_count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < min_count) {
|
||||
while (count-- > 0) {
|
||||
blTree.WriteSymbol(curlen);
|
||||
}
|
||||
}
|
||||
else if (curlen != 0) {
|
||||
blTree.WriteSymbol(REP_3_6);
|
||||
dh.pending.WriteBits(count - 3, 2);
|
||||
} else if (count <= 10) {
|
||||
blTree.WriteSymbol(REP_3_10);
|
||||
dh.pending.WriteBits(count - 3, 3);
|
||||
} else {
|
||||
blTree.WriteSymbol(REP_11_138);
|
||||
dh.pending.WriteBits(count - 11, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DeflaterPending pending;
|
||||
private Tree literalTree, distTree, blTree;
|
||||
|
||||
private short[] d_buf;
|
||||
private byte[] l_buf;
|
||||
private int last_lit;
|
||||
private int extra_bits;
|
||||
|
||||
private static short[] staticLCodes;
|
||||
private static byte[] staticLLength;
|
||||
private static short[] staticDCodes;
|
||||
private static byte[] staticDLength;
|
||||
|
||||
/// <summary>
|
||||
/// Reverse the bits of a 16 bit value.
|
||||
/// </summary>
|
||||
public static short BitReverse(int value)
|
||||
{
|
||||
return (short) (bit4Reverse[value & 0xF] << 12
|
||||
| bit4Reverse[(value >> 4) & 0xF] << 8
|
||||
| bit4Reverse[(value >> 8) & 0xF] << 4
|
||||
| bit4Reverse[value >> 12]);
|
||||
}
|
||||
|
||||
|
||||
static DeflaterHuffman()
|
||||
{
|
||||
/* See RFC 1951 3.2.6 */
|
||||
/* Literal codes */
|
||||
staticLCodes = new short[LITERAL_NUM];
|
||||
staticLLength = new byte[LITERAL_NUM];
|
||||
int i = 0;
|
||||
while (i < 144) {
|
||||
staticLCodes[i] = BitReverse((0x030 + i) << 8);
|
||||
staticLLength[i++] = 8;
|
||||
}
|
||||
while (i < 256) {
|
||||
staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7);
|
||||
staticLLength[i++] = 9;
|
||||
}
|
||||
while (i < 280) {
|
||||
staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9);
|
||||
staticLLength[i++] = 7;
|
||||
}
|
||||
while (i < LITERAL_NUM) {
|
||||
staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8);
|
||||
staticLLength[i++] = 8;
|
||||
}
|
||||
|
||||
/* Distant codes */
|
||||
staticDCodes = new short[DIST_NUM];
|
||||
staticDLength = new byte[DIST_NUM];
|
||||
for (i = 0; i < DIST_NUM; i++) {
|
||||
staticDCodes[i] = BitReverse(i << 11);
|
||||
staticDLength[i] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
public DeflaterHuffman(DeflaterPending pending)
|
||||
{
|
||||
this.pending = pending;
|
||||
|
||||
literalTree = new Tree(this, LITERAL_NUM, 257, 15);
|
||||
distTree = new Tree(this, DIST_NUM, 1, 15);
|
||||
blTree = new Tree(this, BITLEN_NUM, 4, 7);
|
||||
|
||||
d_buf = new short[BUFSIZE];
|
||||
l_buf = new byte [BUFSIZE];
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
last_lit = 0;
|
||||
extra_bits = 0;
|
||||
literalTree.Reset();
|
||||
distTree.Reset();
|
||||
blTree.Reset();
|
||||
}
|
||||
|
||||
private int L_code(int len)
|
||||
{
|
||||
if (len == 255) {
|
||||
return 285;
|
||||
}
|
||||
|
||||
int code = 257;
|
||||
while (len >= 8) {
|
||||
code += 4;
|
||||
len >>= 1;
|
||||
}
|
||||
return code + len;
|
||||
}
|
||||
|
||||
private int D_code(int distance)
|
||||
{
|
||||
int code = 0;
|
||||
while (distance >= 4) {
|
||||
code += 2;
|
||||
distance >>= 1;
|
||||
}
|
||||
return code + distance;
|
||||
}
|
||||
|
||||
public void SendAllTrees(int blTreeCodes)
|
||||
{
|
||||
blTree.BuildCodes();
|
||||
literalTree.BuildCodes();
|
||||
distTree.BuildCodes();
|
||||
pending.WriteBits(literalTree.numCodes - 257, 5);
|
||||
pending.WriteBits(distTree.numCodes - 1, 5);
|
||||
pending.WriteBits(blTreeCodes - 4, 4);
|
||||
for (int rank = 0; rank < blTreeCodes; rank++) {
|
||||
pending.WriteBits(blTree.length[BL_ORDER[rank]], 3);
|
||||
}
|
||||
literalTree.WriteTree(blTree);
|
||||
distTree.WriteTree(blTree);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// blTree.CheckEmpty();
|
||||
// }
|
||||
}
|
||||
|
||||
public void CompressBlock()
|
||||
{
|
||||
for (int i = 0; i < last_lit; i++) {
|
||||
int litlen = l_buf[i] & 0xff;
|
||||
int dist = d_buf[i];
|
||||
if (dist-- != 0) {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("["+(dist+1)+","+(litlen+3)+"]: ");
|
||||
// }
|
||||
|
||||
int lc = L_code(litlen);
|
||||
literalTree.WriteSymbol(lc);
|
||||
|
||||
int bits = (lc - 261) / 4;
|
||||
if (bits > 0 && bits <= 5) {
|
||||
pending.WriteBits(litlen & ((1 << bits) - 1), bits);
|
||||
}
|
||||
|
||||
int dc = D_code(dist);
|
||||
distTree.WriteSymbol(dc);
|
||||
|
||||
bits = dc / 2 - 1;
|
||||
if (bits > 0) {
|
||||
pending.WriteBits(dist & ((1 << bits) - 1), bits);
|
||||
}
|
||||
} else {
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (litlen > 32 && litlen < 127) {
|
||||
// Console.Write("("+(char)litlen+"): ");
|
||||
// } else {
|
||||
// Console.Write("{"+litlen+"}: ");
|
||||
// }
|
||||
// }
|
||||
literalTree.WriteSymbol(litlen);
|
||||
}
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.Write("EOF: ");
|
||||
// }
|
||||
literalTree.WriteSymbol(EOF_SYMBOL);
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// literalTree.CheckEmpty();
|
||||
// distTree.CheckEmpty();
|
||||
// }
|
||||
}
|
||||
|
||||
public void FlushStoredBlock(byte[] stored, int stored_offset, int stored_len, bool lastBlock)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Flushing stored block "+ stored_len);
|
||||
// }
|
||||
pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1)
|
||||
+ (lastBlock ? 1 : 0), 3);
|
||||
pending.AlignToByte();
|
||||
pending.WriteShort(stored_len);
|
||||
pending.WriteShort(~stored_len);
|
||||
pending.WriteBlock(stored, stored_offset, stored_len);
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void FlushBlock(byte[] stored, int stored_offset, int stored_len, bool lastBlock)
|
||||
{
|
||||
literalTree.freqs[EOF_SYMBOL]++;
|
||||
|
||||
/* Build trees */
|
||||
literalTree.BuildTree();
|
||||
distTree.BuildTree();
|
||||
|
||||
/* Calculate bitlen frequency */
|
||||
literalTree.CalcBLFreq(blTree);
|
||||
distTree.CalcBLFreq(blTree);
|
||||
|
||||
/* Build bitlen tree */
|
||||
blTree.BuildTree();
|
||||
|
||||
int blTreeCodes = 4;
|
||||
for (int i = 18; i > blTreeCodes; i--) {
|
||||
if (blTree.length[BL_ORDER[i]] > 0) {
|
||||
blTreeCodes = i+1;
|
||||
}
|
||||
}
|
||||
int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() +
|
||||
literalTree.GetEncodedLength() + distTree.GetEncodedLength() +
|
||||
extra_bits;
|
||||
|
||||
int static_len = extra_bits;
|
||||
for (int i = 0; i < LITERAL_NUM; i++) {
|
||||
static_len += literalTree.freqs[i] * staticLLength[i];
|
||||
}
|
||||
for (int i = 0; i < DIST_NUM; i++) {
|
||||
static_len += distTree.freqs[i] * staticDLength[i];
|
||||
}
|
||||
if (opt_len >= static_len) {
|
||||
/* Force static trees */
|
||||
opt_len = static_len;
|
||||
}
|
||||
|
||||
if (stored_offset >= 0 && stored_len+4 < opt_len >> 3) {
|
||||
/* Store Block */
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("Storing, since " + stored_len + " < " + opt_len
|
||||
// + " <= " + static_len);
|
||||
// }
|
||||
FlushStoredBlock(stored, stored_offset, stored_len, lastBlock);
|
||||
} else if (opt_len == static_len) {
|
||||
/* Encode with static tree */
|
||||
pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3);
|
||||
literalTree.SetStaticCodes(staticLCodes, staticLLength);
|
||||
distTree.SetStaticCodes(staticDCodes, staticDLength);
|
||||
CompressBlock();
|
||||
Reset();
|
||||
} else {
|
||||
/* Encode with dynamic tree */
|
||||
pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3);
|
||||
SendAllTrees(blTreeCodes);
|
||||
CompressBlock();
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFull()
|
||||
{
|
||||
return last_lit + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast
|
||||
}
|
||||
|
||||
public bool TallyLit(int lit)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// if (lit > 32 && lit < 127) {
|
||||
// Console.WriteLine("("+(char)lit+")");
|
||||
// } else {
|
||||
// Console.WriteLine("{"+lit+"}");
|
||||
// }
|
||||
// }
|
||||
d_buf[last_lit] = 0;
|
||||
l_buf[last_lit++] = (byte)lit;
|
||||
literalTree.freqs[lit]++;
|
||||
return IsFull();
|
||||
}
|
||||
|
||||
public bool TallyDist(int dist, int len)
|
||||
{
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("["+dist+","+len+"]");
|
||||
// }
|
||||
|
||||
d_buf[last_lit] = (short)dist;
|
||||
l_buf[last_lit++] = (byte)(len - 3);
|
||||
|
||||
int lc = L_code(len - 3);
|
||||
literalTree.freqs[lc]++;
|
||||
if (lc >= 265 && lc < 285) {
|
||||
extra_bits += (lc - 261) / 4;
|
||||
}
|
||||
|
||||
int dc = D_code(dist - 1);
|
||||
distTree.freqs[dc]++;
|
||||
if (dc >= 4) {
|
||||
extra_bits += dc / 2 - 1;
|
||||
}
|
||||
return IsFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// DeflaterPending.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class stores the pending output of the Deflater.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class DeflaterPending : PendingBuffer
|
||||
{
|
||||
public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+778
@@ -0,0 +1,778 @@
|
||||
// Inflater.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// Inflater is used to decompress data that has been compressed according
|
||||
/// to the "deflate" standard described in rfc1950.
|
||||
///
|
||||
/// The usage is as following. First you have to set some input with
|
||||
/// <code>setInput()</code>, then inflate() it. If inflate doesn't
|
||||
/// inflate any bytes there may be three reasons:
|
||||
/// <ul>
|
||||
/// <li>needsInput() returns true because the input buffer is empty.
|
||||
/// You have to provide more input with <code>setInput()</code>.
|
||||
/// NOTE: needsInput() also returns true when, the stream is finished.
|
||||
/// </li>
|
||||
/// <li>needsDictionary() returns true, you have to provide a preset
|
||||
/// dictionary with <code>setDictionary()</code>.</li>
|
||||
/// <li>finished() returns true, the inflater has finished.</li>
|
||||
/// </ul>
|
||||
/// Once the first output byte is produced, a dictionary will not be
|
||||
/// needed at a later stage.
|
||||
///
|
||||
/// author of the original java version : John Leuner, Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class Inflater
|
||||
{
|
||||
/// <summary>
|
||||
/// Copy lengths for literal codes 257..285
|
||||
/// </summary>
|
||||
private static int[] CPLENS = {
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Extra bits for literal codes 257..285
|
||||
/// </summary>
|
||||
private static int[] CPLEXT = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Copy offsets for distance codes 0..29
|
||||
/// </summary>
|
||||
private static int[] CPDIST = {
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Extra bits for distance codes
|
||||
/// </summary>
|
||||
private static int[] CPDEXT = {
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// This are the state in which the inflater can be.
|
||||
/// </summary>
|
||||
private const int DECODE_HEADER = 0;
|
||||
private const int DECODE_DICT = 1;
|
||||
private const int DECODE_BLOCKS = 2;
|
||||
private const int DECODE_STORED_LEN1 = 3;
|
||||
private const int DECODE_STORED_LEN2 = 4;
|
||||
private const int DECODE_STORED = 5;
|
||||
private const int DECODE_DYN_HEADER = 6;
|
||||
private const int DECODE_HUFFMAN = 7;
|
||||
private const int DECODE_HUFFMAN_LENBITS = 8;
|
||||
private const int DECODE_HUFFMAN_DIST = 9;
|
||||
private const int DECODE_HUFFMAN_DISTBITS = 10;
|
||||
private const int DECODE_CHKSUM = 11;
|
||||
private const int FINISHED = 12;
|
||||
|
||||
/// <summary>
|
||||
/// This variable contains the current state.
|
||||
/// </summary>
|
||||
private int mode;
|
||||
|
||||
/// <summary>
|
||||
/// The adler checksum of the dictionary or of the decompressed
|
||||
/// stream, as it is written in the header resp. footer of the
|
||||
/// compressed stream.
|
||||
/// Only valid if mode is DECODE_DICT or DECODE_CHKSUM.
|
||||
/// </summary>
|
||||
private int readAdler;
|
||||
|
||||
/// <summary>
|
||||
/// The number of bits needed to complete the current state. This
|
||||
/// is valid, if mode is DECODE_DICT, DECODE_CHKSUM,
|
||||
/// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.
|
||||
/// </summary>
|
||||
private int neededBits;
|
||||
private int repLength, repDist;
|
||||
private int uncomprLen;
|
||||
|
||||
/// <summary>
|
||||
/// True, if the last block flag was set in the last block of the
|
||||
/// inflated stream. This means that the stream ends after the
|
||||
/// current block.
|
||||
/// </summary>
|
||||
private bool isLastBlock;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of inflated bytes.
|
||||
/// </summary>
|
||||
private int totalOut;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of bytes set with setInput(). This is not the
|
||||
/// value returned by getTotalIn(), since this also includes the
|
||||
/// unprocessed input.
|
||||
/// </summary>
|
||||
private int totalIn;
|
||||
|
||||
/// <summary>
|
||||
/// This variable stores the nowrap flag that was given to the constructor.
|
||||
/// True means, that the inflated stream doesn't contain a header nor the
|
||||
/// checksum in the footer.
|
||||
/// </summary>
|
||||
private bool nowrap;
|
||||
|
||||
private StreamManipulator input;
|
||||
private OutputWindow outputWindow;
|
||||
private InflaterDynHeader dynHeader;
|
||||
private InflaterHuffmanTree litlenTree, distTree;
|
||||
private Adler32 adler;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inflater.
|
||||
/// </summary>
|
||||
public Inflater() : this(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inflater.
|
||||
/// </summary>
|
||||
/// <param name="nowrap">
|
||||
/// true if no header and checksum field appears in the
|
||||
/// stream. This is used for GZIPed input. For compatibility with
|
||||
/// Sun JDK you should provide one byte of input more than needed in
|
||||
/// this case.
|
||||
/// </param>
|
||||
public Inflater(bool nowrap)
|
||||
{
|
||||
this.nowrap = nowrap;
|
||||
this.adler = new Adler32();
|
||||
input = new StreamManipulator();
|
||||
outputWindow = new OutputWindow();
|
||||
mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the inflater so that a new stream can be decompressed. All
|
||||
/// pending input and output will be discarded.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER;
|
||||
totalIn = totalOut = 0;
|
||||
input.Reset();
|
||||
outputWindow.Reset();
|
||||
dynHeader = null;
|
||||
litlenTree = null;
|
||||
distTree = null;
|
||||
isLastBlock = false;
|
||||
adler.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the deflate header.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// false if more input is needed.
|
||||
/// </returns>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// if header is invalid.
|
||||
/// </exception>
|
||||
private bool DecodeHeader()
|
||||
{
|
||||
int header = input.PeekBits(16);
|
||||
if (header < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(16);
|
||||
/* The header is written in "wrong" byte order */
|
||||
header = ((header << 8) | (header >> 8)) & 0xffff;
|
||||
if (header % 31 != 0) {
|
||||
throw new FormatException("Header checksum illegal");
|
||||
}
|
||||
|
||||
if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) {
|
||||
throw new FormatException("Compression Method unknown");
|
||||
}
|
||||
|
||||
/* Maximum size of the backwards window in bits.
|
||||
* We currently ignore this, but we could use it to make the
|
||||
* inflater window more space efficient. On the other hand the
|
||||
* full window (15 bits) is needed most times, anyway.
|
||||
int max_wbits = ((header & 0x7000) >> 12) + 8;
|
||||
*/
|
||||
|
||||
if ((header & 0x0020) == 0) { // Dictionary flag?
|
||||
mode = DECODE_BLOCKS;
|
||||
} else {
|
||||
mode = DECODE_DICT;
|
||||
neededBits = 32;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the dictionary checksum after the deflate header.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// false if more input is needed.
|
||||
/// </returns>
|
||||
private bool DecodeDict()
|
||||
{
|
||||
while (neededBits > 0) {
|
||||
int dictByte = input.PeekBits(8);
|
||||
if (dictByte < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(8);
|
||||
readAdler = (readAdler << 8) | dictByte;
|
||||
neededBits -= 8;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the huffman encoded symbols in the input stream.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// false if more input is needed, true if output window is
|
||||
/// full or the current block ends.
|
||||
/// </returns>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// if deflated stream is invalid.
|
||||
/// </exception>
|
||||
private bool DecodeHuffman()
|
||||
{
|
||||
int free = outputWindow.GetFreeSpace();
|
||||
while (free >= 258) {
|
||||
int symbol;
|
||||
switch (mode) {
|
||||
case DECODE_HUFFMAN:
|
||||
/* This is the inner loop so it is optimized a bit */
|
||||
while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) {
|
||||
outputWindow.Write(symbol);
|
||||
if (--free < 258) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (symbol < 257) {
|
||||
if (symbol < 0) {
|
||||
return false;
|
||||
} else {
|
||||
/* symbol == 256: end of block */
|
||||
distTree = null;
|
||||
litlenTree = null;
|
||||
mode = DECODE_BLOCKS;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
repLength = CPLENS[symbol - 257];
|
||||
neededBits = CPLEXT[symbol - 257];
|
||||
} catch (Exception) {
|
||||
throw new FormatException("Illegal rep length code");
|
||||
}
|
||||
goto case DECODE_HUFFMAN_LENBITS;/* fall through */
|
||||
case DECODE_HUFFMAN_LENBITS:
|
||||
if (neededBits > 0) {
|
||||
mode = DECODE_HUFFMAN_LENBITS;
|
||||
int i = input.PeekBits(neededBits);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(neededBits);
|
||||
repLength += i;
|
||||
}
|
||||
mode = DECODE_HUFFMAN_DIST;
|
||||
goto case DECODE_HUFFMAN_DIST;/* fall through */
|
||||
case DECODE_HUFFMAN_DIST:
|
||||
symbol = distTree.GetSymbol(input);
|
||||
if (symbol < 0) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
repDist = CPDIST[symbol];
|
||||
neededBits = CPDEXT[symbol];
|
||||
} catch (Exception) {
|
||||
throw new FormatException("Illegal rep dist code");
|
||||
}
|
||||
|
||||
goto case DECODE_HUFFMAN_DISTBITS;/* fall through */
|
||||
case DECODE_HUFFMAN_DISTBITS:
|
||||
if (neededBits > 0) {
|
||||
mode = DECODE_HUFFMAN_DISTBITS;
|
||||
int i = input.PeekBits(neededBits);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(neededBits);
|
||||
repDist += i;
|
||||
}
|
||||
outputWindow.Repeat(repLength, repDist);
|
||||
free -= repLength;
|
||||
mode = DECODE_HUFFMAN;
|
||||
break;
|
||||
default:
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the adler checksum after the deflate stream.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// false if more input is needed.
|
||||
/// </returns>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// DataFormatException, if checksum doesn't match.
|
||||
/// </exception>
|
||||
private bool DecodeChksum()
|
||||
{
|
||||
while (neededBits > 0) {
|
||||
int chkByte = input.PeekBits(8);
|
||||
if (chkByte < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(8);
|
||||
readAdler = (readAdler << 8) | chkByte;
|
||||
neededBits -= 8;
|
||||
}
|
||||
if ((int) adler.Value != readAdler) {
|
||||
throw new FormatException("Adler chksum doesn't match: "
|
||||
+ (int)adler.Value
|
||||
+ " vs. " + readAdler);
|
||||
}
|
||||
mode = FINISHED;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the deflated stream.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// false if more input is needed, or if finished.
|
||||
/// </returns>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// DataFormatException, if deflated stream is invalid.
|
||||
/// </exception>
|
||||
private bool Decode()
|
||||
{
|
||||
switch (mode) {
|
||||
case DECODE_HEADER:
|
||||
return DecodeHeader();
|
||||
case DECODE_DICT:
|
||||
return DecodeDict();
|
||||
case DECODE_CHKSUM:
|
||||
return DecodeChksum();
|
||||
|
||||
case DECODE_BLOCKS:
|
||||
if (isLastBlock) {
|
||||
if (nowrap) {
|
||||
mode = FINISHED;
|
||||
return false;
|
||||
} else {
|
||||
input.SkipToByteBoundary();
|
||||
neededBits = 32;
|
||||
mode = DECODE_CHKSUM;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int type = input.PeekBits(3);
|
||||
if (type < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(3);
|
||||
|
||||
if ((type & 1) != 0) {
|
||||
isLastBlock = true;
|
||||
}
|
||||
switch (type >> 1) {
|
||||
case DeflaterConstants.STORED_BLOCK:
|
||||
input.SkipToByteBoundary();
|
||||
mode = DECODE_STORED_LEN1;
|
||||
break;
|
||||
case DeflaterConstants.STATIC_TREES:
|
||||
litlenTree = InflaterHuffmanTree.defLitLenTree;
|
||||
distTree = InflaterHuffmanTree.defDistTree;
|
||||
mode = DECODE_HUFFMAN;
|
||||
break;
|
||||
case DeflaterConstants.DYN_TREES:
|
||||
dynHeader = new InflaterDynHeader();
|
||||
mode = DECODE_DYN_HEADER;
|
||||
break;
|
||||
default:
|
||||
throw new FormatException("Unknown block type "+type);
|
||||
}
|
||||
return true;
|
||||
|
||||
case DECODE_STORED_LEN1: {
|
||||
if ((uncomprLen = input.PeekBits(16)) < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(16);
|
||||
mode = DECODE_STORED_LEN2;
|
||||
}
|
||||
goto case DECODE_STORED_LEN2; /* fall through */
|
||||
case DECODE_STORED_LEN2: {
|
||||
int nlen = input.PeekBits(16);
|
||||
if (nlen < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(16);
|
||||
if (nlen != (uncomprLen ^ 0xffff)) {
|
||||
throw new FormatException("broken uncompressed block");
|
||||
}
|
||||
mode = DECODE_STORED;
|
||||
}
|
||||
goto case DECODE_STORED;/* fall through */
|
||||
case DECODE_STORED: {
|
||||
int more = outputWindow.CopyStored(input, uncomprLen);
|
||||
uncomprLen -= more;
|
||||
if (uncomprLen == 0) {
|
||||
mode = DECODE_BLOCKS;
|
||||
return true;
|
||||
}
|
||||
return !input.IsNeedingInput;
|
||||
}
|
||||
|
||||
case DECODE_DYN_HEADER:
|
||||
if (!dynHeader.Decode(input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
litlenTree = dynHeader.BuildLitLenTree();
|
||||
distTree = dynHeader.BuildDistTree();
|
||||
mode = DECODE_HUFFMAN;
|
||||
goto case DECODE_HUFFMAN; /* fall through */
|
||||
case DECODE_HUFFMAN:
|
||||
case DECODE_HUFFMAN_LENBITS:
|
||||
case DECODE_HUFFMAN_DIST:
|
||||
case DECODE_HUFFMAN_DISTBITS:
|
||||
return DecodeHuffman();
|
||||
case FINISHED:
|
||||
return false;
|
||||
default:
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the preset dictionary. This should only be called, if
|
||||
/// needsDictionary() returns true and it should set the same
|
||||
/// dictionary, that was used for deflating. The getAdler()
|
||||
/// function returns the checksum of the dictionary needed.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// the dictionary.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no dictionary is needed.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// if the dictionary checksum is wrong.
|
||||
/// </exception>
|
||||
public void SetDictionary(byte[] buffer)
|
||||
{
|
||||
SetDictionary(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the preset dictionary. This should only be called, if
|
||||
/// needsDictionary() returns true and it should set the same
|
||||
/// dictionary, that was used for deflating. The getAdler()
|
||||
/// function returns the checksum of the dictionary needed.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// the dictionary.
|
||||
/// </param>
|
||||
/// <param name="off">
|
||||
/// the offset into buffer where the dictionary starts.
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the length of the dictionary.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no dictionary is needed.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// if the dictionary checksum is wrong.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if the off and/or len are wrong.
|
||||
/// </exception>
|
||||
public void SetDictionary(byte[] buffer, int off, int len)
|
||||
{
|
||||
if (!IsNeedingDictionary) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
adler.Update(buffer, off, len);
|
||||
if ((int) adler.Value != readAdler) {
|
||||
throw new ArgumentException("Wrong adler checksum");
|
||||
}
|
||||
adler.Reset();
|
||||
outputWindow.CopyDict(buffer, off, len);
|
||||
mode = DECODE_BLOCKS;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input. This should only be called, if needsInput()
|
||||
/// returns true.
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// the input.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no input is needed.
|
||||
/// </exception>
|
||||
public void SetInput(byte[] buf)
|
||||
{
|
||||
SetInput(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input. This should only be called, if needsInput()
|
||||
/// returns true.
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// the input.
|
||||
/// </param>
|
||||
/// <param name="off">
|
||||
/// the offset into buffer where the input starts.
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the length of the input.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no input is needed.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if the off and/or len are wrong.
|
||||
/// </exception>
|
||||
public void SetInput(byte[] buf, int off, int len)
|
||||
{
|
||||
input.SetInput(buf, off, len);
|
||||
totalIn += len;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflates the compressed stream to the output buffer. If this
|
||||
/// returns 0, you should check, whether needsDictionary(),
|
||||
/// needsInput() or finished() returns true, to determine why no
|
||||
/// further output is produced.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// the output buffer.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the number of bytes written to the buffer, 0 if no further
|
||||
/// output can be produced.
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if buf has length 0.
|
||||
/// </exception>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// if deflated stream is invalid.
|
||||
/// </exception>
|
||||
public int Inflate(byte[] buf)
|
||||
{
|
||||
return Inflate(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inflates the compressed stream to the output buffer. If this
|
||||
/// returns 0, you should check, whether needsDictionary(),
|
||||
/// needsInput() or finished() returns true, to determine why no
|
||||
/// further output is produced.
|
||||
/// </summary>
|
||||
/// <param name = "buf">
|
||||
/// the output buffer.
|
||||
/// </param>
|
||||
/// <param name = "off">
|
||||
/// the offset into buffer where the output should start.
|
||||
/// </param>
|
||||
/// <param name = "len">
|
||||
/// the maximum length of the output.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the number of bytes written to the buffer, 0 if no further output can be produced.
|
||||
/// </returns>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if len is <= 0.
|
||||
/// </exception>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if the off and/or len are wrong.
|
||||
/// </exception>
|
||||
/// <exception cref="System.FormatException">
|
||||
/// if deflated stream is invalid.
|
||||
/// </exception>
|
||||
public int Inflate(byte[] buf, int off, int len)
|
||||
{
|
||||
if (len < 0) {
|
||||
throw new ArgumentOutOfRangeException("len < 0");
|
||||
}
|
||||
// Special case: len may be zero
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
/* // Check for correct buff, off, len triple
|
||||
if (off < 0 || off + len >= buf.Length) {
|
||||
throw new ArgumentException("off/len outside buf bounds");
|
||||
}*/
|
||||
int count = 0;
|
||||
int more;
|
||||
do {
|
||||
if (mode != DECODE_CHKSUM) {
|
||||
/* Don't give away any output, if we are waiting for the
|
||||
* checksum in the input stream.
|
||||
*
|
||||
* With this trick we have always:
|
||||
* needsInput() and not finished()
|
||||
* implies more output can be produced.
|
||||
*/
|
||||
more = outputWindow.CopyOutput(buf, off, len);
|
||||
adler.Update(buf, off, more);
|
||||
off += more;
|
||||
count += more;
|
||||
totalOut += more;
|
||||
len -= more;
|
||||
if (len == 0) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
} while (Decode() || (outputWindow.GetAvailable() > 0 &&
|
||||
mode != DECODE_CHKSUM));
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the input buffer is empty.
|
||||
/// You should then call setInput().
|
||||
/// NOTE: This method also returns true when the stream is finished.
|
||||
/// </summary>
|
||||
public bool IsNeedingInput {
|
||||
get {
|
||||
return input.IsNeedingInput;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if a preset dictionary is needed to inflate the input.
|
||||
/// </summary>
|
||||
public bool IsNeedingDictionary {
|
||||
get {
|
||||
return mode == DECODE_DICT && neededBits == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the inflater has finished. This means, that no
|
||||
/// input is needed and no output can be produced.
|
||||
/// </summary>
|
||||
public bool IsFinished {
|
||||
get {
|
||||
return mode == FINISHED && outputWindow.GetAvailable() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the adler checksum. This is either the checksum of all
|
||||
/// uncompressed bytes returned by inflate(), or if needsDictionary()
|
||||
/// returns true (and thus no output was yet produced) this is the
|
||||
/// adler checksum of the expected dictionary.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the adler checksum.
|
||||
/// </returns>
|
||||
public int Adler {
|
||||
get {
|
||||
return IsNeedingDictionary ? readAdler : (int) adler.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of output bytes returned by inflate().
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the total number of output bytes.
|
||||
/// </returns>
|
||||
public int TotalOut {
|
||||
get {
|
||||
return totalOut;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of processed compressed input bytes.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the total number of bytes of processed input bytes.
|
||||
/// </returns>
|
||||
public int TotalIn {
|
||||
get {
|
||||
return totalIn - RemainingInput;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of unprocessed input. Useful, if the end of the
|
||||
/// stream is reached and you want to further process the bytes after
|
||||
/// the deflate stream.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the number of bytes of the input which were not processed.
|
||||
/// </returns>
|
||||
public int RemainingInput {
|
||||
get {
|
||||
return input.AvailableBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
// InflaterDynHeader.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
class InflaterDynHeader
|
||||
{
|
||||
const int LNUM = 0;
|
||||
const int DNUM = 1;
|
||||
const int BLNUM = 2;
|
||||
const int BLLENS = 3;
|
||||
const int LENS = 4;
|
||||
const int REPS = 5;
|
||||
|
||||
static readonly int[] repMin = { 3, 3, 11 };
|
||||
static readonly int[] repBits = { 2, 3, 7 };
|
||||
|
||||
byte[] blLens;
|
||||
byte[] litdistLens;
|
||||
|
||||
InflaterHuffmanTree blTree;
|
||||
|
||||
int mode;
|
||||
int lnum, dnum, blnum, num;
|
||||
int repSymbol;
|
||||
byte lastLen;
|
||||
int ptr;
|
||||
|
||||
static readonly int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||
|
||||
public InflaterDynHeader()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Decode(StreamManipulator input)
|
||||
{
|
||||
decode_loop:
|
||||
for (;;) {
|
||||
switch (mode) {
|
||||
case LNUM:
|
||||
lnum = input.PeekBits(5);
|
||||
if (lnum < 0) {
|
||||
return false;
|
||||
}
|
||||
lnum += 257;
|
||||
input.DropBits(5);
|
||||
// System.err.println("LNUM: "+lnum);
|
||||
mode = DNUM;
|
||||
goto case DNUM; // fall through
|
||||
case DNUM:
|
||||
dnum = input.PeekBits(5);
|
||||
if (dnum < 0) {
|
||||
return false;
|
||||
}
|
||||
dnum++;
|
||||
input.DropBits(5);
|
||||
// System.err.println("DNUM: "+dnum);
|
||||
num = lnum+dnum;
|
||||
litdistLens = new byte[num];
|
||||
mode = BLNUM;
|
||||
goto case BLNUM; // fall through
|
||||
case BLNUM:
|
||||
blnum = input.PeekBits(4);
|
||||
if (blnum < 0) {
|
||||
return false;
|
||||
}
|
||||
blnum += 4;
|
||||
input.DropBits(4);
|
||||
blLens = new byte[19];
|
||||
ptr = 0;
|
||||
// System.err.println("BLNUM: "+blnum);
|
||||
mode = BLLENS;
|
||||
goto case BLLENS; // fall through
|
||||
case BLLENS:
|
||||
while (ptr < blnum) {
|
||||
int len = input.PeekBits(3);
|
||||
if (len < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(3);
|
||||
// System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len);
|
||||
blLens[BL_ORDER[ptr]] = (byte) len;
|
||||
ptr++;
|
||||
}
|
||||
blTree = new InflaterHuffmanTree(blLens);
|
||||
blLens = null;
|
||||
ptr = 0;
|
||||
mode = LENS;
|
||||
goto case LENS; // fall through
|
||||
case LENS: {
|
||||
int symbol;
|
||||
while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) {
|
||||
/* Normal case: symbol in [0..15] */
|
||||
|
||||
// System.err.println("litdistLens["+ptr+"]: "+symbol);
|
||||
litdistLens[ptr++] = lastLen = (byte)symbol;
|
||||
|
||||
if (ptr == num) {
|
||||
/* Finished */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* need more input ? */
|
||||
if (symbol < 0)
|
||||
return false;
|
||||
|
||||
/* otherwise repeat code */
|
||||
if (symbol >= 17) {
|
||||
/* repeat zero */
|
||||
// System.err.println("repeating zero");
|
||||
lastLen = 0;
|
||||
} else {
|
||||
if (ptr == 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
repSymbol = symbol-16;
|
||||
}
|
||||
mode = REPS;
|
||||
goto case REPS; // fall through
|
||||
case REPS:
|
||||
{
|
||||
int bits = repBits[repSymbol];
|
||||
int count = input.PeekBits(bits);
|
||||
if (count < 0) {
|
||||
return false;
|
||||
}
|
||||
input.DropBits(bits);
|
||||
count += repMin[repSymbol];
|
||||
// System.err.println("litdistLens repeated: "+count);
|
||||
|
||||
if (ptr + count > num) {
|
||||
throw new Exception();
|
||||
}
|
||||
while (count-- > 0) {
|
||||
litdistLens[ptr++] = lastLen;
|
||||
}
|
||||
|
||||
if (ptr == num) {
|
||||
/* Finished */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
mode = LENS;
|
||||
goto decode_loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InflaterHuffmanTree BuildLitLenTree()
|
||||
{
|
||||
byte[] litlenLens = new byte[lnum];
|
||||
Array.Copy(litdistLens, 0, litlenLens, 0, lnum);
|
||||
return new InflaterHuffmanTree(litlenLens);
|
||||
}
|
||||
|
||||
public InflaterHuffmanTree BuildDistTree()
|
||||
{
|
||||
byte[] distLens = new byte[dnum];
|
||||
Array.Copy(litdistLens, lnum, distLens, 0, dnum);
|
||||
return new InflaterHuffmanTree(distLens);
|
||||
}
|
||||
}
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
// InflaterHuffmanTree.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
public class InflaterHuffmanTree
|
||||
{
|
||||
private static int MAX_BITLEN = 15;
|
||||
private short[] tree;
|
||||
|
||||
public static InflaterHuffmanTree defLitLenTree, defDistTree;
|
||||
|
||||
static InflaterHuffmanTree()
|
||||
{
|
||||
try {
|
||||
byte[] codeLengths = new byte[288];
|
||||
int i = 0;
|
||||
while (i < 144) {
|
||||
codeLengths[i++] = 8;
|
||||
}
|
||||
while (i < 256) {
|
||||
codeLengths[i++] = 9;
|
||||
}
|
||||
while (i < 280) {
|
||||
codeLengths[i++] = 7;
|
||||
}
|
||||
while (i < 288) {
|
||||
codeLengths[i++] = 8;
|
||||
}
|
||||
defLitLenTree = new InflaterHuffmanTree(codeLengths);
|
||||
|
||||
codeLengths = new byte[32];
|
||||
i = 0;
|
||||
while (i < 32) {
|
||||
codeLengths[i++] = 5;
|
||||
}
|
||||
defDistTree = new InflaterHuffmanTree(codeLengths);
|
||||
} catch (Exception) {
|
||||
throw new ApplicationException("InflaterHuffmanTree: static tree length illegal");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a Huffman tree from the array of code lengths.
|
||||
/// </summary>
|
||||
/// <param name = "codeLengths">
|
||||
/// the array of code lengths
|
||||
/// </param>
|
||||
public InflaterHuffmanTree(byte[] codeLengths)
|
||||
{
|
||||
BuildTree(codeLengths);
|
||||
}
|
||||
|
||||
private void BuildTree(byte[] codeLengths)
|
||||
{
|
||||
int[] blCount = new int[MAX_BITLEN + 1];
|
||||
int[] nextCode = new int[MAX_BITLEN + 1];
|
||||
|
||||
for (int i = 0; i < codeLengths.Length; i++) {
|
||||
int bits = codeLengths[i];
|
||||
if (bits > 0)
|
||||
blCount[bits]++;
|
||||
}
|
||||
|
||||
int code = 0;
|
||||
int treeSize = 512;
|
||||
for (int bits = 1; bits <= MAX_BITLEN; bits++) {
|
||||
nextCode[bits] = code;
|
||||
code += blCount[bits] << (16 - bits);
|
||||
if (bits >= 10) {
|
||||
/* We need an extra table for bit lengths >= 10. */
|
||||
int start = nextCode[bits] & 0x1ff80;
|
||||
int end = code & 0x1ff80;
|
||||
treeSize += (end - start) >> (16 - bits);
|
||||
}
|
||||
}
|
||||
if (code != 65536) {
|
||||
throw new Exception("Code lengths don't add up properly.");
|
||||
}
|
||||
/* Now create and fill the extra tables from longest to shortest
|
||||
* bit len. This way the sub trees will be aligned.
|
||||
*/
|
||||
tree = new short[treeSize];
|
||||
int treePtr = 512;
|
||||
for (int bits = MAX_BITLEN; bits >= 10; bits--) {
|
||||
int end = code & 0x1ff80;
|
||||
code -= blCount[bits] << (16 - bits);
|
||||
int start = code & 0x1ff80;
|
||||
for (int i = start; i < end; i += 1 << 7) {
|
||||
tree[DeflaterHuffman.BitReverse(i)] = (short) ((-treePtr << 4) | bits);
|
||||
treePtr += 1 << (bits-9);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < codeLengths.Length; i++) {
|
||||
int bits = codeLengths[i];
|
||||
if (bits == 0) {
|
||||
continue;
|
||||
}
|
||||
code = nextCode[bits];
|
||||
int revcode = DeflaterHuffman.BitReverse(code);
|
||||
if (bits <= 9) {
|
||||
do {
|
||||
tree[revcode] = (short) ((i << 4) | bits);
|
||||
revcode += 1 << bits;
|
||||
} while (revcode < 512);
|
||||
} else {
|
||||
int subTree = tree[revcode & 511];
|
||||
int treeLen = 1 << (subTree & 15);
|
||||
subTree = -(subTree >> 4);
|
||||
do {
|
||||
tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits);
|
||||
revcode += 1 << bits;
|
||||
} while (revcode < treeLen);
|
||||
}
|
||||
nextCode[bits] = code + (1 << (16 - bits));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the next symbol from input. The symbol is encoded using the
|
||||
/// huffman tree.
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
/// input the input source.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the next symbol, or -1 if not enough input is available.
|
||||
/// </returns>
|
||||
public int GetSymbol(StreamManipulator input)
|
||||
{
|
||||
int lookahead, symbol;
|
||||
if ((lookahead = input.PeekBits(9)) >= 0) {
|
||||
if ((symbol = tree[lookahead]) >= 0) {
|
||||
input.DropBits(symbol & 15);
|
||||
return symbol >> 4;
|
||||
}
|
||||
int subtree = -(symbol >> 4);
|
||||
int bitlen = symbol & 15;
|
||||
if ((lookahead = input.PeekBits(bitlen)) >= 0) {
|
||||
symbol = tree[subtree | (lookahead >> 9)];
|
||||
input.DropBits(symbol & 15);
|
||||
return symbol >> 4;
|
||||
} else {
|
||||
int bits = input.AvailableBits;
|
||||
lookahead = input.PeekBits(bits);
|
||||
symbol = tree[subtree | (lookahead >> 9)];
|
||||
if ((symbol & 15) <= bits) {
|
||||
input.DropBits(symbol & 15);
|
||||
return symbol >> 4;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int bits = input.AvailableBits;
|
||||
lookahead = input.PeekBits(bits);
|
||||
symbol = tree[lookahead];
|
||||
if (symbol >= 0 && (symbol & 15) <= bits) {
|
||||
input.DropBits(symbol & 15);
|
||||
return symbol >> 4;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
// PendingBuffer.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression {
|
||||
|
||||
/// <summary>
|
||||
/// This class is general purpose class for writing data to a buffer.
|
||||
///
|
||||
/// It allows you to write bits as well as bytes
|
||||
/// Based on DeflaterPending.java
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class PendingBuffer
|
||||
{
|
||||
protected byte[] buf;
|
||||
int start;
|
||||
int end;
|
||||
|
||||
uint bits;
|
||||
int bitCount;
|
||||
|
||||
public PendingBuffer() : this( 4096 )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PendingBuffer(int bufsize)
|
||||
{
|
||||
buf = new byte[bufsize];
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
start = end = bitCount = 0;
|
||||
}
|
||||
|
||||
public void WriteByte(int b)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0)
|
||||
throw new Exception();
|
||||
buf[end++] = (byte) b;
|
||||
}
|
||||
|
||||
public void WriteShort(int s)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
buf[end++] = (byte) s;
|
||||
buf[end++] = (byte) (s >> 8);
|
||||
}
|
||||
|
||||
public void WriteInt(int s)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
buf[end++] = (byte) s;
|
||||
buf[end++] = (byte) (s >> 8);
|
||||
buf[end++] = (byte) (s >> 16);
|
||||
buf[end++] = (byte) (s >> 24);
|
||||
}
|
||||
|
||||
public void WriteBlock(byte[] block, int offset, int len)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
System.Array.Copy(block, offset, buf, end, len);
|
||||
end += len;
|
||||
}
|
||||
|
||||
public int BitCount {
|
||||
get {
|
||||
return bitCount;
|
||||
}
|
||||
}
|
||||
|
||||
public void AlignToByte()
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
if (bitCount > 0) {
|
||||
buf[end++] = (byte) bits;
|
||||
if (bitCount > 8) {
|
||||
buf[end++] = (byte) (bits >> 8);
|
||||
}
|
||||
}
|
||||
bits = 0;
|
||||
bitCount = 0;
|
||||
}
|
||||
|
||||
public void WriteBits(int b, int count)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
// if (DeflaterConstants.DEBUGGING) {
|
||||
// Console.WriteLine("writeBits("+b+","+count+")");
|
||||
// }
|
||||
bits |= (uint)(b << bitCount);
|
||||
bitCount += count;
|
||||
if (bitCount >= 16) {
|
||||
buf[end++] = (byte) bits;
|
||||
buf[end++] = (byte) (bits >> 8);
|
||||
bits >>= 16;
|
||||
bitCount -= 16;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteShortMSB(int s)
|
||||
{
|
||||
if (DeflaterConstants.DEBUGGING && start != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
buf[end++] = (byte) (s >> 8);
|
||||
buf[end++] = (byte) s;
|
||||
}
|
||||
|
||||
public bool IsFlushed {
|
||||
get {
|
||||
return end == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the pending buffer into the given output array. If the
|
||||
/// output array is to small, only a partial flush is done.
|
||||
/// </summary>
|
||||
/// <param name="output">
|
||||
/// the output array;
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// the offset into output array;
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// length the maximum number of bytes to store;
|
||||
/// </param>
|
||||
/// <exception name="ArgumentOutOfRangeException">
|
||||
/// IndexOutOfBoundsException if offset or length are invalid.
|
||||
/// </exception>
|
||||
public int Flush(byte[] output, int offset, int length)
|
||||
{
|
||||
if (bitCount >= 8) {
|
||||
buf[end++] = (byte) bits;
|
||||
bits >>= 8;
|
||||
bitCount -= 8;
|
||||
}
|
||||
if (length > end - start) {
|
||||
length = end - start;
|
||||
System.Array.Copy(buf, start, output, offset, length);
|
||||
start = 0;
|
||||
end = 0;
|
||||
} else {
|
||||
System.Array.Copy(buf, start, output, offset, length);
|
||||
start += length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] ret = new byte[ end - start ];
|
||||
System.Array.Copy(buf, start, ret, 0, ret.Length);
|
||||
start = 0;
|
||||
end = 0;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
// DeflaterOutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This is a special FilterOutputStream deflating the bytes that are
|
||||
/// written through it. It uses the Deflater for deflating.
|
||||
///
|
||||
/// authors of the original java version : Tom Tromey, Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class DeflaterOutputStream : Stream
|
||||
{
|
||||
/// <summary>
|
||||
/// This buffer is used temporarily to retrieve the bytes from the
|
||||
/// deflater and write them to the underlying output stream.
|
||||
/// </summary>
|
||||
protected byte[] buf;
|
||||
|
||||
/// <summary>
|
||||
/// The deflater which is used to deflate the stream.
|
||||
/// </summary>
|
||||
protected Deflater def;
|
||||
|
||||
/// <summary>
|
||||
/// base stream the deflater depends on.
|
||||
/// </summary>
|
||||
protected Stream baseOutputStream;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return baseOutputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return baseOutputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return baseOutputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length {
|
||||
get {
|
||||
return baseOutputStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position {
|
||||
get {
|
||||
return baseOutputStream.Position;
|
||||
}
|
||||
set {
|
||||
baseOutputStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return baseOutputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void SetLength(long val)
|
||||
{
|
||||
baseOutputStream.SetLength(val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override int ReadByte()
|
||||
{
|
||||
return baseOutputStream.ReadByte();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
return baseOutputStream.Read(b, off, len);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deflates everything in the def's input buffers. This will call
|
||||
/// <code>def.deflate()</code> until all bytes from the input buffers
|
||||
/// are processed.
|
||||
/// </summary>
|
||||
protected void deflate()
|
||||
{
|
||||
while (!def.IsNeedingInput) {
|
||||
int len = def.Deflate(buf, 0, buf.Length);
|
||||
|
||||
// System.err.println("DOS deflated " + len + " baseOutputStream of " + buf.length);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
baseOutputStream.Write(buf, 0, len);
|
||||
}
|
||||
|
||||
if (!def.IsNeedingInput) {
|
||||
throw new ApplicationException("Can't deflate all input?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new DeflaterOutputStream with a default Deflater and default buffer size.
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// the output stream where deflated output should be written.
|
||||
/// </param>
|
||||
public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new DeflaterOutputStream with the given Deflater and
|
||||
/// default buffer size.
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// the output stream where deflated output should be written.
|
||||
/// </param>
|
||||
/// <param name="defl">
|
||||
/// the underlying deflater.
|
||||
/// </param>
|
||||
public DeflaterOutputStream(Stream baseOutputStream, Deflater defl) :this(baseOutputStream, defl, 512)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new DeflaterOutputStream with the given Deflater and
|
||||
/// buffer size.
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// the output stream where deflated output should be written.
|
||||
/// </param>
|
||||
/// <param name="defl">
|
||||
/// the underlying deflater.
|
||||
/// </param>
|
||||
/// <param name="bufsize">
|
||||
/// the buffer size.
|
||||
/// </param>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if bufsize isn't positive.
|
||||
/// </exception>
|
||||
public DeflaterOutputStream(Stream baseOutputStream, Deflater defl, int bufsize)
|
||||
{
|
||||
this.baseOutputStream = baseOutputStream;
|
||||
if (bufsize <= 0) {
|
||||
throw new InvalidOperationException("bufsize <= 0");
|
||||
}
|
||||
buf = new byte[bufsize];
|
||||
def = defl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the stream by calling flush() on the deflater and then
|
||||
/// on the underlying stream. This ensures that all bytes are
|
||||
/// flushed.
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
def.Flush();
|
||||
deflate();
|
||||
baseOutputStream.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finishes the stream by calling finish() on the deflater.
|
||||
/// </summary>
|
||||
public virtual void Finish()
|
||||
{
|
||||
def.Finish();
|
||||
while (!def.IsFinished) {
|
||||
int len = def.Deflate(buf, 0, buf.Length);
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
baseOutputStream.Write(buf, 0, len);
|
||||
}
|
||||
if (!def.IsFinished) {
|
||||
throw new ApplicationException("Can't deflate all input?");
|
||||
}
|
||||
baseOutputStream.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls finish () and closes the stream.
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
Finish();
|
||||
baseOutputStream.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a single byte to the compressed output stream.
|
||||
/// </summary>
|
||||
/// <param name="bval">
|
||||
/// the byte value.
|
||||
/// </param>
|
||||
public override void WriteByte(byte bval)
|
||||
{
|
||||
byte[] b = new byte[1];
|
||||
b[0] = (byte) bval;
|
||||
Write(b, 0, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a len bytes from an array to the compressed stream.
|
||||
/// </summary>
|
||||
/// <param name="buf">
|
||||
/// the byte array.
|
||||
/// </param>
|
||||
/// <param name="off">
|
||||
/// the offset into the byte array where to start.
|
||||
/// </param>
|
||||
/// <param name="len">
|
||||
/// the number of bytes to write.
|
||||
/// </param>
|
||||
public override void Write(byte[] buf, int off, int len)
|
||||
{
|
||||
// System.err.println("DOS with off " + off + " and len " + len);
|
||||
def.SetInput(buf, off, len);
|
||||
deflate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
// InflaterInputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This filter stream is used to decompress data compressed baseInputStream the "deflate"
|
||||
/// format. The "deflate" format is described baseInputStream RFC 1951.
|
||||
///
|
||||
/// This stream may form the basis for other decompression filters, such
|
||||
/// as the <code>GzipInputStream</code>.
|
||||
///
|
||||
/// author of the original java version : John Leuner
|
||||
/// </summary>
|
||||
public class InflaterInputStream : Stream
|
||||
{
|
||||
//Variables
|
||||
|
||||
/// <summary>
|
||||
/// Decompressor for this filter
|
||||
/// </summary>
|
||||
protected Inflater inf;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Byte array used as a buffer
|
||||
/// </summary>
|
||||
protected byte[] buf;
|
||||
|
||||
/// <summary>
|
||||
/// Size of buffer
|
||||
/// </summary>
|
||||
protected int len;
|
||||
|
||||
//We just use this if we are decoding one byte at a time with the read() call
|
||||
private byte[] onebytebuffer = new byte[1];
|
||||
|
||||
/// <summary>
|
||||
/// base stream the inflater depends on.
|
||||
/// </summary>
|
||||
protected Stream baseInputStream;
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanRead {
|
||||
get {
|
||||
return baseInputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanSeek {
|
||||
get {
|
||||
return baseInputStream.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override bool CanWrite {
|
||||
get {
|
||||
return baseInputStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Length {
|
||||
get {
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Position {
|
||||
get {
|
||||
return baseInputStream.Position;
|
||||
}
|
||||
set {
|
||||
baseInputStream.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the baseInputStream
|
||||
/// </summary>
|
||||
public override void Flush()
|
||||
{
|
||||
baseInputStream.Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return baseInputStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void SetLength(long val)
|
||||
{
|
||||
baseInputStream.SetLength(val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void Write(byte[] array, int offset, int count)
|
||||
{
|
||||
baseInputStream.Write(array, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I needed to implement the abstract member.
|
||||
/// </summary>
|
||||
public override void WriteByte(byte val)
|
||||
{
|
||||
baseInputStream.WriteByte(val);
|
||||
}
|
||||
|
||||
//Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create an InflaterInputStream with the default decompresseor
|
||||
/// and a default buffer size.
|
||||
/// </summary>
|
||||
/// <param name = "baseInputStream">
|
||||
/// the InputStream to read bytes from
|
||||
/// </param>
|
||||
public InflaterInputStream(Stream baseInputStream) : this(baseInputStream, new Inflater(), 4096)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an InflaterInputStream with the specified decompresseor
|
||||
/// and a default buffer size.
|
||||
/// </summary>
|
||||
/// <param name = "baseInputStream">
|
||||
/// the InputStream to read bytes from
|
||||
/// </param>
|
||||
/// <param name = "inf">
|
||||
/// the decompressor used to decompress data read from baseInputStream
|
||||
/// </param>
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an InflaterInputStream with the specified decompresseor
|
||||
/// and a specified buffer size.
|
||||
/// </summary>
|
||||
/// <param name = "baseInputStream">
|
||||
/// the InputStream to read bytes from
|
||||
/// </param>
|
||||
/// <param name = "inf">
|
||||
/// the decompressor used to decompress data read from baseInputStream
|
||||
/// </param>
|
||||
/// <param name = "size">
|
||||
/// size of the buffer to use
|
||||
/// </param>
|
||||
public InflaterInputStream(Stream baseInputStream, Inflater inf, int size)
|
||||
{
|
||||
this.baseInputStream = baseInputStream;
|
||||
this.inf = inf;
|
||||
try {
|
||||
this.len = (int)baseInputStream.Length;
|
||||
} catch (Exception) { // the stream may not support .Length
|
||||
this.len = 0;
|
||||
}
|
||||
|
||||
if (size <= 0) {
|
||||
throw new ArgumentOutOfRangeException("size <= 0");
|
||||
}
|
||||
|
||||
buf = new byte[size]; //Create the buffer
|
||||
}
|
||||
|
||||
//Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns 0 once the end of the stream (EOF) has been reached.
|
||||
/// Otherwise returns 1.
|
||||
/// </summary>
|
||||
public virtual int Available {
|
||||
get {
|
||||
return inf.IsFinished ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the input stream
|
||||
/// </summary>
|
||||
public override void Close()
|
||||
{
|
||||
baseInputStream.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills the buffer with more data to decompress.
|
||||
/// </summary>
|
||||
protected void Fill()
|
||||
{
|
||||
len = baseInputStream.Read(buf, 0, buf.Length);
|
||||
|
||||
if (len < 0) {
|
||||
throw new ApplicationException("Deflated stream ends early.");
|
||||
}
|
||||
inf.SetInput(buf, 0, len);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads one byte of decompressed data.
|
||||
///
|
||||
/// The byte is baseInputStream the lower 8 bits of the int.
|
||||
/// </summary>
|
||||
public override int ReadByte()
|
||||
{
|
||||
int nread = Read(onebytebuffer, 0, 1); //read one byte
|
||||
if (nread > 0) {
|
||||
return onebytebuffer[0] & 0xff;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decompresses data into the byte array
|
||||
/// </summary>
|
||||
/// <param name ="b">
|
||||
/// the array to read and decompress data into
|
||||
/// </param>
|
||||
/// <param name ="off">
|
||||
/// the offset indicating where the data should be placed
|
||||
/// </param>
|
||||
/// <param name ="len">
|
||||
/// the number of bytes to decompress
|
||||
/// </param>
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
for (;;) {
|
||||
int count;
|
||||
try {
|
||||
count = inf.Inflate(b, off, len);
|
||||
} catch (Exception e) {
|
||||
throw new ZipException(e.ToString());
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
return count;
|
||||
}
|
||||
|
||||
if (inf.IsNeedingDictionary) {
|
||||
throw new ZipException("Need a dictionary");
|
||||
} else if (inf.IsFinished) {
|
||||
return 0;
|
||||
} else if (inf.IsNeedingInput) {
|
||||
Fill();
|
||||
} else {
|
||||
throw new InvalidOperationException("Don't know what to do");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip specified number of bytes of uncompressed data
|
||||
/// </summary>
|
||||
/// <param name ="n">
|
||||
/// number of bytes to skip
|
||||
/// </param>
|
||||
public long Skip(long n)
|
||||
{
|
||||
if (n < 0) {
|
||||
throw new ArgumentOutOfRangeException("n");
|
||||
}
|
||||
int len = 2048;
|
||||
if (n < len) {
|
||||
len = (int) n;
|
||||
}
|
||||
byte[] tmp = new byte[len];
|
||||
return (long)baseInputStream.Read(tmp, 0, tmp.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
// OutputWindow.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// Contains the output from the Inflation process.
|
||||
/// We need to have a window so that we can refer backwards into the output stream
|
||||
/// to repeat stuff.
|
||||
///
|
||||
/// author of the original java version : John Leuner
|
||||
/// </summary>
|
||||
public class OutputWindow
|
||||
{
|
||||
private static int WINDOW_SIZE = 1 << 15;
|
||||
private static int WINDOW_MASK = WINDOW_SIZE - 1;
|
||||
|
||||
private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes
|
||||
private int window_end = 0;
|
||||
private int window_filled = 0;
|
||||
|
||||
public void Write(int abyte)
|
||||
{
|
||||
if (window_filled++ == WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
window[window_end++] = (byte) abyte;
|
||||
window_end &= WINDOW_MASK;
|
||||
}
|
||||
|
||||
|
||||
private void SlowRepeat(int rep_start, int len, int dist)
|
||||
{
|
||||
while (len-- > 0) {
|
||||
window[window_end++] = window[rep_start++];
|
||||
window_end &= WINDOW_MASK;
|
||||
rep_start &= WINDOW_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
public void Repeat(int len, int dist)
|
||||
{
|
||||
if ((window_filled += len) > WINDOW_SIZE) {
|
||||
throw new InvalidOperationException("Window full");
|
||||
}
|
||||
|
||||
int rep_start = (window_end - dist) & WINDOW_MASK;
|
||||
int border = WINDOW_SIZE - len;
|
||||
if (rep_start <= border && window_end < border) {
|
||||
if (len <= dist) {
|
||||
System.Array.Copy(window, rep_start, window, window_end, len);
|
||||
window_end += len;
|
||||
} else {
|
||||
/* We have to copy manually, since the repeat pattern overlaps.
|
||||
*/
|
||||
while (len-- > 0) {
|
||||
window[window_end++] = window[rep_start++];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SlowRepeat(rep_start, len, dist);
|
||||
}
|
||||
}
|
||||
|
||||
public int CopyStored(StreamManipulator input, int len)
|
||||
{
|
||||
len = Math.Min(Math.Min(len, WINDOW_SIZE - window_filled), input.AvailableBytes);
|
||||
int copied;
|
||||
|
||||
int tailLen = WINDOW_SIZE - window_end;
|
||||
if (len > tailLen) {
|
||||
copied = input.CopyBytes(window, window_end, tailLen);
|
||||
if (copied == tailLen) {
|
||||
copied += input.CopyBytes(window, 0, len - tailLen);
|
||||
}
|
||||
} else {
|
||||
copied = input.CopyBytes(window, window_end, len);
|
||||
}
|
||||
|
||||
window_end = (window_end + copied) & WINDOW_MASK;
|
||||
window_filled += copied;
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void CopyDict(byte[] dict, int offset, int len)
|
||||
{
|
||||
if (window_filled > 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (len > WINDOW_SIZE) {
|
||||
offset += len - WINDOW_SIZE;
|
||||
len = WINDOW_SIZE;
|
||||
}
|
||||
System.Array.Copy(dict, offset, window, 0, len);
|
||||
window_end = len & WINDOW_MASK;
|
||||
}
|
||||
|
||||
public int GetFreeSpace()
|
||||
{
|
||||
return WINDOW_SIZE - window_filled;
|
||||
}
|
||||
|
||||
public int GetAvailable()
|
||||
{
|
||||
return window_filled;
|
||||
}
|
||||
|
||||
public int CopyOutput(byte[] output, int offset, int len)
|
||||
{
|
||||
int copy_end = window_end;
|
||||
if (len > window_filled) {
|
||||
len = window_filled;
|
||||
} else {
|
||||
copy_end = (window_end - window_filled + len) & WINDOW_MASK;
|
||||
}
|
||||
|
||||
int copied = len;
|
||||
int tailLen = len - copy_end;
|
||||
|
||||
if (tailLen > 0) {
|
||||
System.Array.Copy(window, WINDOW_SIZE - tailLen,
|
||||
output, offset, tailLen);
|
||||
offset += tailLen;
|
||||
len = copy_end;
|
||||
}
|
||||
System.Array.Copy(window, copy_end - len, output, offset, len);
|
||||
window_filled -= copied;
|
||||
if (window_filled < 0) {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
window_filled = window_end = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
// StreamManipulator.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams {
|
||||
|
||||
/// <summary>
|
||||
/// This class allows us to retrieve a specified amount of bits from
|
||||
/// the input buffer, as well as copy big byte blocks.
|
||||
///
|
||||
/// It uses an int buffer to store up to 31 bits for direct
|
||||
/// manipulation. This guarantees that we can get at least 16 bits,
|
||||
/// but we only need at most 15, so this is all safe.
|
||||
///
|
||||
/// There are some optimizations in this class, for example, you must
|
||||
/// never peek more then 8 bits more than needed, and you must first
|
||||
/// peek bits before you may drop them. This is not a general purpose
|
||||
/// class but optimized for the behaviour of the Inflater.
|
||||
///
|
||||
/// authors of the original java version : John Leuner, Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class StreamManipulator
|
||||
{
|
||||
private byte[] window;
|
||||
private int window_start = 0;
|
||||
private int window_end = 0;
|
||||
|
||||
private uint buffer = 0;
|
||||
private int bits_in_buffer = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the next n bits but don't increase input pointer. n must be
|
||||
/// less or equal 16 and if you if this call succeeds, you must drop
|
||||
/// at least n-8 bits in the next call.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the value of the bits, or -1 if not enough bits available. */
|
||||
/// </returns>
|
||||
public int PeekBits(int n)
|
||||
{
|
||||
if (bits_in_buffer < n) {
|
||||
if (window_start == window_end) {
|
||||
return -1;
|
||||
}
|
||||
buffer |= (uint)((window[window_start++] & 0xff |
|
||||
(window[window_start++] & 0xff) << 8) << bits_in_buffer);
|
||||
bits_in_buffer += 16;
|
||||
}
|
||||
return (int)(buffer & ((1 << n) - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops the next n bits from the input. You should have called peekBits
|
||||
/// with a bigger or equal n before, to make sure that enough bits are in
|
||||
/// the bit buffer.
|
||||
/// </summary>
|
||||
public void DropBits(int n)
|
||||
{
|
||||
buffer >>= n;
|
||||
bits_in_buffer -= n;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next n bits and increases input pointer. This is equivalent
|
||||
/// to peekBits followed by dropBits, except for correct error handling.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the value of the bits, or -1 if not enough bits available.
|
||||
/// </returns>
|
||||
public int GetBits(int n)
|
||||
{
|
||||
int bits = PeekBits(n);
|
||||
if (bits >= 0) {
|
||||
DropBits(n);
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of bits available in the bit buffer. This must be
|
||||
/// only called when a previous peekBits() returned -1.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the number of bits available.
|
||||
/// </returns>
|
||||
public int AvailableBits {
|
||||
get {
|
||||
return bits_in_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of bytes available.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the number of bytes available.
|
||||
/// </returns>
|
||||
public int AvailableBytes {
|
||||
get {
|
||||
return window_end - window_start + (bits_in_buffer >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skips to the next byte boundary.
|
||||
/// </summary>
|
||||
public void SkipToByteBoundary()
|
||||
{
|
||||
buffer >>= (bits_in_buffer & 7);
|
||||
bits_in_buffer &= ~7;
|
||||
}
|
||||
|
||||
public bool IsNeedingInput {
|
||||
get {
|
||||
return window_start == window_end;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies length bytes from input buffer to output buffer starting
|
||||
/// at output[offset]. You have to make sure, that the buffer is
|
||||
/// byte aligned. If not enough bytes are available, copies fewer
|
||||
/// bytes.
|
||||
/// </summary>
|
||||
/// <param name="output">
|
||||
/// the buffer.
|
||||
/// </param>
|
||||
/// <param name="offset">
|
||||
/// the offset in the buffer.
|
||||
/// </param>
|
||||
/// <param name="length">
|
||||
/// the length to copy, 0 is allowed.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the number of bytes copied, 0 if no byte is available.
|
||||
/// </returns>
|
||||
public int CopyBytes(byte[] output, int offset, int length)
|
||||
{
|
||||
if (length < 0) {
|
||||
throw new ArgumentOutOfRangeException("length negative");
|
||||
}
|
||||
if ((bits_in_buffer & 7) != 0) {
|
||||
/* bits_in_buffer may only be 0 or 8 */
|
||||
throw new InvalidOperationException("Bit buffer is not aligned!");
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
while (bits_in_buffer > 0 && length > 0) {
|
||||
output[offset++] = (byte) buffer;
|
||||
buffer >>= 8;
|
||||
bits_in_buffer -= 8;
|
||||
length--;
|
||||
count++;
|
||||
}
|
||||
if (length == 0) {
|
||||
return count;
|
||||
}
|
||||
|
||||
int avail = window_end - window_start;
|
||||
if (length > avail) {
|
||||
length = avail;
|
||||
}
|
||||
System.Array.Copy(window, window_start, output, offset, length);
|
||||
window_start += length;
|
||||
|
||||
if (((window_start - window_end) & 1) != 0) {
|
||||
/* We always want an even number of bytes in input, see peekBits */
|
||||
buffer = (uint)(window[window_start++] & 0xff);
|
||||
bits_in_buffer = 8;
|
||||
}
|
||||
return count + length;
|
||||
}
|
||||
|
||||
public StreamManipulator()
|
||||
{
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
buffer = (uint)(window_start = window_end = bits_in_buffer = 0);
|
||||
}
|
||||
|
||||
public void SetInput(byte[] buf, int off, int len)
|
||||
{
|
||||
if (window_start < window_end) {
|
||||
throw new InvalidOperationException("Old input was not completely processed");
|
||||
}
|
||||
|
||||
int end = off + len;
|
||||
|
||||
/* We want to throw an ArrayIndexOutOfBoundsException early. The
|
||||
* check is very tricky: it also handles integer wrap around.
|
||||
*/
|
||||
if (0 > off || off > end || end > buf.Length) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if ((len & 1) != 0) {
|
||||
/* We always want an even number of bytes in input, see peekBits */
|
||||
buffer |= (uint)((buf[off++] & 0xff) << bits_in_buffer);
|
||||
bits_in_buffer += 8;
|
||||
}
|
||||
|
||||
window = buf;
|
||||
window_start = off;
|
||||
window_end = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// ZipConstants.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains constants used for zip.
|
||||
/// </summary>
|
||||
public sealed class ZipConstants
|
||||
{
|
||||
/* The local file header */
|
||||
public const int LOCHDR = 30;
|
||||
public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);
|
||||
|
||||
public const int LOCVER = 4;
|
||||
public const int LOCFLG = 6;
|
||||
public const int LOCHOW = 8;
|
||||
public const int LOCTIM = 10;
|
||||
public const int LOCCRC = 14;
|
||||
public const int LOCSIZ = 18;
|
||||
public const int LOCLEN = 22;
|
||||
public const int LOCNAM = 26;
|
||||
public const int LOCEXT = 28;
|
||||
|
||||
/* The Data descriptor */
|
||||
public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24);
|
||||
public const int EXTHDR = 16;
|
||||
|
||||
public const int EXTCRC = 4;
|
||||
public const int EXTSIZ = 8;
|
||||
public const int EXTLEN = 12;
|
||||
|
||||
/* The central directory file header */
|
||||
public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24);
|
||||
|
||||
/* The central directory file header for 64bit ZIP*/
|
||||
public const int CENSIG64 = 0x06064b50;
|
||||
|
||||
public const int CENHDR = 46;
|
||||
|
||||
public const int CENVEM = 4;
|
||||
public const int CENVER = 6;
|
||||
public const int CENFLG = 8;
|
||||
public const int CENHOW = 10;
|
||||
public const int CENTIM = 12;
|
||||
public const int CENCRC = 16;
|
||||
public const int CENSIZ = 20;
|
||||
public const int CENLEN = 24;
|
||||
public const int CENNAM = 28;
|
||||
public const int CENEXT = 30;
|
||||
public const int CENCOM = 32;
|
||||
public const int CENDSK = 34;
|
||||
public const int CENATT = 36;
|
||||
public const int CENATX = 38;
|
||||
public const int CENOFF = 42;
|
||||
|
||||
/* The entries in the end of central directory */
|
||||
public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24);
|
||||
public const int ENDHDR = 22;
|
||||
|
||||
/* The following two fields are missing in SUN JDK */
|
||||
public const int ENDNRD = 4;
|
||||
public const int ENDDCD = 6;
|
||||
|
||||
public const int ENDSUB = 8;
|
||||
public const int ENDTOT = 10;
|
||||
public const int ENDSIZ = 12;
|
||||
public const int ENDOFF = 16;
|
||||
public const int ENDCOM = 20;
|
||||
|
||||
/* Using the codepage 1252 doesn't solve the 8bit ASCII problem :/
|
||||
any help would be appreciated.
|
||||
|
||||
// get encoding for latin characters (like ö, ü, ß or ô)
|
||||
static Encoding ecp1252 = Encoding.GetEncoding(1252);
|
||||
*/
|
||||
public static string ConvertToString(byte[] data)
|
||||
{
|
||||
|
||||
return Encoding.ASCII.GetString(data);
|
||||
}
|
||||
|
||||
public static byte[] ConvertToArray(string str)
|
||||
{
|
||||
return Encoding.ASCII.GetBytes(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
// ZipEntry.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
public enum CompressionMethod
|
||||
{
|
||||
Stored = 0,
|
||||
Deflated = 8,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class represents a member of a zip archive. ZipFile and
|
||||
/// ZipInputStream will give you instances of this class as information
|
||||
/// about the members in an archive. On the other hand ZipOutputStream
|
||||
/// needs an instance of this class to create a new member.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
public class ZipEntry : ICloneable
|
||||
{
|
||||
static int KNOWN_SIZE = 1;
|
||||
static int KNOWN_CSIZE = 2;
|
||||
static int KNOWN_CRC = 4;
|
||||
static int KNOWN_TIME = 8;
|
||||
|
||||
DateTime cal = DateTime.Now;
|
||||
|
||||
string name;
|
||||
uint size;
|
||||
ushort version;
|
||||
uint compressedSize;
|
||||
int crc;
|
||||
|
||||
ushort known = 0;
|
||||
CompressionMethod method = CompressionMethod.Deflated;
|
||||
byte[] extra = null;
|
||||
string comment = null;
|
||||
|
||||
public int zipFileIndex = -1; /* used by ZipFile */
|
||||
public int flags; /* used by ZipOutputStream */
|
||||
public int offset; /* used by ZipFile and ZipOutputStream */
|
||||
|
||||
/// <summary>
|
||||
/// Creates a zip entry with the given name.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// the name. May include directory components separated by '/'.
|
||||
/// </param>
|
||||
public ZipEntry(string name)
|
||||
{
|
||||
if (name == null) {
|
||||
throw new System.ArgumentNullException("name");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of the given zip entry.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// the entry to copy.
|
||||
/// </param>
|
||||
public ZipEntry(ZipEntry e)
|
||||
{
|
||||
name = e.name;
|
||||
known = e.known;
|
||||
size = e.size;
|
||||
compressedSize = e.compressedSize;
|
||||
crc = e.crc;
|
||||
// time = e.time;
|
||||
method = e.method;
|
||||
extra = e.extra;
|
||||
comment = e.comment;
|
||||
}
|
||||
|
||||
public ushort Version {
|
||||
get {
|
||||
return version;
|
||||
}
|
||||
set {
|
||||
version = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int DosTime {
|
||||
get {
|
||||
// if ((known & KNOWN_TIME) == 0) {
|
||||
// return 0;
|
||||
// }
|
||||
lock (this) {
|
||||
return (cal.Year - 1980 & 0x7f) << 25 |
|
||||
(cal.Month + 1) << 21 |
|
||||
(cal.Day ) << 16 |
|
||||
(cal.Hour) << 11 |
|
||||
(cal.Minute) << 5 |
|
||||
(cal.Second) >> 1;
|
||||
}
|
||||
}
|
||||
set {
|
||||
// Guard against invalid or missing date causing
|
||||
// IndexOutOfBoundsException.
|
||||
try {
|
||||
lock (this) {
|
||||
cal = CalculateDateTime(value);
|
||||
// time = (int) (cal.Millisecond / 1000L);
|
||||
}
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
} catch (Exception) {
|
||||
/* Ignore illegal time stamp */
|
||||
known &= (ushort)~KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the time of last modification of the entry.
|
||||
/// </summary>
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return cal;
|
||||
}
|
||||
set {
|
||||
lock (this) {
|
||||
cal = value;
|
||||
// time = (int) (cal.Millisecond / 1000L);
|
||||
}
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the entry name. The path components in the entry are
|
||||
/// always separated by slashes ('/').
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets/Sets the time of last modification of the entry.
|
||||
// /// </summary>
|
||||
// /// <returns>
|
||||
// /// the time of last modification of the entry, or -1 if unknown.
|
||||
// /// </returns>
|
||||
// public long Time {
|
||||
// get {
|
||||
// return (known & KNOWN_TIME) != 0 ? time * 1000L : -1;
|
||||
// }
|
||||
// set {
|
||||
// this.time = (int) (value / 1000L);
|
||||
// this.known |= (ushort)KNOWN_TIME;
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the size of the uncompressed data.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if size is not in 0..0xffffffffL
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the size or -1 if unknown.
|
||||
/// </returns>
|
||||
public long Size {
|
||||
get {
|
||||
return (known & KNOWN_SIZE) != 0 ? (long)size : -1L;
|
||||
}
|
||||
set {
|
||||
if (((ulong)value & 0xFFFFFFFF00000000L) != 0) {
|
||||
throw new ArgumentOutOfRangeException("size");
|
||||
}
|
||||
this.size = (uint)value;
|
||||
this.known |= (ushort)KNOWN_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the size of the compressed data.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if csize is not in 0..0xffffffffL
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the size or -1 if unknown.
|
||||
/// </returns>
|
||||
public long CompressedSize {
|
||||
get {
|
||||
return (known & KNOWN_CSIZE) != 0 ? (long)compressedSize : -1L;
|
||||
}
|
||||
set {
|
||||
if (((ulong)value & 0xffffffff00000000L) != 0) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
this.compressedSize = (uint)value;
|
||||
this.known |= (ushort)KNOWN_CSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the crc of the uncompressed data.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if crc is not in 0..0xffffffffL
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the crc or -1 if unknown.
|
||||
/// </returns>
|
||||
public long Crc {
|
||||
get {
|
||||
return (known & KNOWN_CRC) != 0 ? crc & 0xffffffffL : -1L;
|
||||
}
|
||||
set {
|
||||
if (((ulong)crc & 0xffffffff00000000L) != 0) {
|
||||
throw new Exception();
|
||||
}
|
||||
this.crc = (int)value;
|
||||
this.known |= (ushort)KNOWN_CRC;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the compression method. Only DEFLATED and STORED are supported.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if method is not supported.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the compression method or -1 if unknown.
|
||||
/// </returns>
|
||||
/// <see cref="ZipOutputStream.DEFLATED"/>
|
||||
/// <see cref="ZipOutputStream.STORED"/>
|
||||
public CompressionMethod CompressionMethod {
|
||||
get {
|
||||
return method;
|
||||
}
|
||||
set {
|
||||
this.method = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the extra data.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if extra is longer than 0xffff bytes.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the extra data or null if not set.
|
||||
/// </returns>
|
||||
public byte[] ExtraData {
|
||||
get {
|
||||
return extra;
|
||||
}
|
||||
set {
|
||||
if (value == null) {
|
||||
this.extra = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.Length > 0xffff) {
|
||||
throw new System.ArgumentOutOfRangeException();
|
||||
}
|
||||
this.extra = value;
|
||||
try {
|
||||
int pos = 0;
|
||||
while (pos < extra.Length) {
|
||||
int sig = (extra[pos++] & 0xff) | (extra[pos++] & 0xff) << 8;
|
||||
int len = (extra[pos++] & 0xff) | (extra[pos++] & 0xff) << 8;
|
||||
if (sig == 0x5455) {
|
||||
/* extended time stamp, unix format by Rainer Prem <[email protected]> */
|
||||
int flags = extra[pos];
|
||||
if ((flags & 1) != 0) {
|
||||
int iTime = ((extra[pos+1] & 0xff) |
|
||||
(extra[pos+2] & 0xff) << 8 |
|
||||
(extra[pos+3] & 0xff) << 16 |
|
||||
(extra[pos+4] & 0xff) << 24);
|
||||
|
||||
cal = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) +
|
||||
new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime ();
|
||||
known |= (ushort)KNOWN_TIME;
|
||||
}
|
||||
}
|
||||
pos += len;
|
||||
}
|
||||
} catch (Exception) {
|
||||
/* be lenient */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the entry comment.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if comment is longer than 0xffff.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// the comment or null if not set.
|
||||
/// </returns>
|
||||
public string Comment {
|
||||
get {
|
||||
return comment;
|
||||
}
|
||||
set {
|
||||
if (value.Length > 0xffff) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
this.comment = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets true, if the entry is a directory. This is solely
|
||||
/// determined by the name, a trailing slash '/' marks a directory.
|
||||
/// </summary>
|
||||
public bool IsDirectory {
|
||||
get {
|
||||
int nlen = name.Length;
|
||||
return nlen > 0 && name[nlen - 1] == '/';
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of this zip entry.
|
||||
/// </summary>
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string representation of this ZipEntry. This is just
|
||||
/// the name as returned by getName().
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
DateTime CalculateDateTime(int dosTime)
|
||||
{
|
||||
int sec = 2 * (dosTime & 0x1f);
|
||||
int min = (dosTime >> 5) & 0x3f;
|
||||
int hrs = (dosTime >> 11) & 0x1f;
|
||||
int day = (dosTime >> 16) & 0x1f;
|
||||
int mon = ((dosTime >> 21) & 0xf);
|
||||
int year = ((dosTime >> 25) & 0x7f) + 1980; /* since 1900 */
|
||||
|
||||
return new DateTime(year, mon, day, hrs, min, sec);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,521 @@
|
||||
// ZipFile.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This class represents a Zip archive. You can ask for the contained
|
||||
/// entries, or get an input stream for a file entry. The entry is
|
||||
/// automatically decompressed.
|
||||
///
|
||||
/// This class is thread safe: You can open input streams for arbitrary
|
||||
/// entries in different threads.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// using System;
|
||||
/// using System.Text;
|
||||
/// using System.Collections;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.Zip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
/// static public void Main(string[] args)
|
||||
/// {
|
||||
/// ZipFile zFile = new ZipFile(args[0]);
|
||||
/// Console.WriteLine("Listing of : " + zFile.Name);
|
||||
/// Console.WriteLine("");
|
||||
/// Console.WriteLine("Raw Size Size Date Time Name");
|
||||
/// Console.WriteLine("-------- -------- -------- ------ ---------");
|
||||
/// foreach (ZipEntry e in zFile) {
|
||||
/// DateTime d = e.DateTime;
|
||||
/// Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize,
|
||||
/// d.ToString("dd-MM-yy"), d.ToString("t"),
|
||||
/// e.Name);
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </example>
|
||||
public class ZipFile : IEnumerable
|
||||
{
|
||||
string name;
|
||||
Stream baseStream;
|
||||
ZipEntry[] entries;
|
||||
|
||||
/// <summary>
|
||||
/// Opens a Zip file with the given name for reading.
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// IOException if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the file doesn't contain a valid zip archive.
|
||||
/// </exception>
|
||||
public ZipFile(string name) : this(File.OpenRead(name))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a Zip file reading the given FileStream
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// IOException if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the file doesn't contain a valid zip archive.
|
||||
/// </exception>
|
||||
public ZipFile(FileStream file)
|
||||
{
|
||||
this.baseStream = file;
|
||||
this.name = file.Name;
|
||||
ReadEntries();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a Zip file reading the given Stream
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// IOException if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the file doesn't contain a valid zip archive.
|
||||
/// </exception>
|
||||
public ZipFile(Stream baseStream)
|
||||
{
|
||||
this.baseStream = baseStream;
|
||||
this.name = null;
|
||||
ReadEntries();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read an unsigned short in little endian byte order.
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="System.IO.EndOfStreamException">
|
||||
/// if the file ends prematurely
|
||||
/// </exception>
|
||||
int ReadLeShort()
|
||||
{
|
||||
return baseStream.ReadByte() | baseStream.ReadByte() << 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read an int in little endian byte order.
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="System.IO.EndOfStreamException">
|
||||
/// if the file ends prematurely
|
||||
/// </exception>
|
||||
int ReadLeInt()
|
||||
{
|
||||
return ReadLeShort() | ReadLeShort() << 16;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read the central directory of a zip file and fill the entries
|
||||
/// array. This is called exactly once by the constructors.
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the central directory is malformed
|
||||
/// </exception>
|
||||
void ReadEntries()
|
||||
{
|
||||
/* Search for the End Of Central Directory. When a zip comment is
|
||||
* present the directory may start earlier.
|
||||
* FIXME: This searches the whole file in a very slow manner if the
|
||||
* file isn't a zip file.
|
||||
*/
|
||||
long pos = baseStream.Length - ZipConstants.ENDHDR;
|
||||
do {
|
||||
if (pos < 0) {
|
||||
throw new ZipException("central directory not found, probably not a zip file");
|
||||
}
|
||||
baseStream.Seek(pos--, SeekOrigin.Begin);
|
||||
} while (ReadLeInt() != ZipConstants.ENDSIG);
|
||||
|
||||
long oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.ENDTOT - ZipConstants.ENDNRD;
|
||||
|
||||
if (baseStream.Position - oldPos != ZipConstants.ENDTOT - ZipConstants.ENDNRD) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
int count = ReadLeShort();
|
||||
|
||||
oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.ENDOFF - ZipConstants.ENDSIZ;
|
||||
|
||||
if (baseStream.Position - oldPos != ZipConstants.ENDOFF - ZipConstants.ENDSIZ) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
int centralOffset = ReadLeInt();
|
||||
|
||||
entries = new ZipEntry[count];
|
||||
baseStream.Seek(centralOffset, SeekOrigin.Begin);
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (ReadLeInt() != ZipConstants.CENSIG) {
|
||||
throw new ZipException("Wrong Central Directory signature");
|
||||
}
|
||||
|
||||
oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.CENHOW - ZipConstants.CENVEM;
|
||||
|
||||
if (baseStream.Position - oldPos != ZipConstants.CENHOW - ZipConstants.CENVEM) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
int method = ReadLeShort();
|
||||
int dostime = ReadLeInt();
|
||||
int crc = ReadLeInt();
|
||||
int csize = ReadLeInt();
|
||||
int size = ReadLeInt();
|
||||
int nameLen = ReadLeShort();
|
||||
int extraLen = ReadLeShort();
|
||||
int commentLen = ReadLeShort();
|
||||
|
||||
oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.CENOFF - ZipConstants.CENDSK;
|
||||
if (baseStream.Position - oldPos != ZipConstants.CENOFF - ZipConstants.CENDSK) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
int offset = ReadLeInt();
|
||||
|
||||
byte[] buffer = new byte[Math.Max(nameLen, commentLen)];
|
||||
|
||||
baseStream.Read(buffer, 0, nameLen);
|
||||
string name = ZipConstants.ConvertToString(buffer);
|
||||
|
||||
ZipEntry entry = new ZipEntry(name);
|
||||
entry.CompressionMethod = (CompressionMethod)method;
|
||||
entry.Crc = crc & 0xffffffffL;
|
||||
entry.Size = size & 0xffffffffL;
|
||||
entry.CompressedSize = csize & 0xffffffffL;
|
||||
entry.DosTime = dostime;
|
||||
if (extraLen > 0) {
|
||||
byte[] extra = new byte[extraLen];
|
||||
baseStream.Read(extra, 0, extraLen);
|
||||
entry.ExtraData = extra;
|
||||
}
|
||||
if (commentLen > 0) {
|
||||
baseStream.Read(buffer, 0, commentLen);
|
||||
entry.Comment = ZipConstants.ConvertToString(buffer);
|
||||
}
|
||||
entry.zipFileIndex = i;
|
||||
entry.offset = offset;
|
||||
entries[i] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the ZipFile. This also closes all input streams given by
|
||||
/// this class. After this is called, no further method should be
|
||||
/// called.
|
||||
/// </summary>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
public void Close()
|
||||
{
|
||||
entries = null;
|
||||
lock(baseStream) {
|
||||
baseStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an IEnumerator of all Zip entries in this Zip file.
|
||||
/// </summary>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
if (entries == null) {
|
||||
throw new InvalidOperationException("ZipFile has closed");
|
||||
}
|
||||
|
||||
return new ZipEntryEnumeration(entries);
|
||||
}
|
||||
|
||||
int GetEntryIndex(string name)
|
||||
{
|
||||
for (int i = 0; i < entries.Length; i++) {
|
||||
if (name.Equals(entries[i].Name)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a zip entry in this archive with the given name.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// the name. May contain directory components separated by slashes ('/').
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// the zip entry, or null if no entry with that name exists.
|
||||
/// </returns>
|
||||
public ZipEntry GetEntry(string name)
|
||||
{
|
||||
if (entries == null) {
|
||||
throw new InvalidOperationException("ZipFile has closed");
|
||||
}
|
||||
int index = GetEntryIndex(name);
|
||||
return index >= 0 ? (ZipEntry) entries[index].Clone() : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks, if the local header of the entry at index i matches the
|
||||
/// central directory, and returns the offset to the data.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the start offset of the (compressed) data.
|
||||
/// </returns>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the local header doesn't match the central directory header
|
||||
/// </exception>
|
||||
long CheckLocalHeader(ZipEntry entry)
|
||||
{
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(entry.offset, SeekOrigin.Begin);
|
||||
if (ReadLeInt() != ZipConstants.LOCSIG) {
|
||||
throw new ZipException("Wrong Local header signature");
|
||||
}
|
||||
|
||||
/* skip version and flags */
|
||||
long oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.LOCHOW - ZipConstants.LOCVER;
|
||||
if (baseStream.Position - oldPos != ZipConstants.LOCHOW - ZipConstants.LOCVER) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
if (entry.CompressionMethod != (CompressionMethod)ReadLeShort()) {
|
||||
throw new ZipException("Compression method mismatch");
|
||||
}
|
||||
|
||||
/* Skip time, crc, size and csize */
|
||||
oldPos = baseStream.Position;
|
||||
baseStream.Position += ZipConstants.LOCNAM - ZipConstants.LOCTIM;
|
||||
|
||||
if (baseStream.Position - oldPos != ZipConstants.LOCNAM - ZipConstants.LOCTIM) {
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
if (entry.Name.Length != ReadLeShort()) {
|
||||
throw new ZipException("file name length mismatch");
|
||||
}
|
||||
|
||||
int extraLen = entry.Name.Length + ReadLeShort();
|
||||
return entry.offset + ZipConstants.LOCHDR + extraLen;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an input stream reading the given zip entry as
|
||||
/// uncompressed data. Normally zip entry should be an entry
|
||||
/// returned by GetEntry().
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the input stream.
|
||||
/// </returns>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// if the Zip archive is malformed.
|
||||
/// </exception>
|
||||
public Stream GetInputStream(ZipEntry entry)
|
||||
{
|
||||
if (entries == null) {
|
||||
throw new InvalidOperationException("ZipFile has closed");
|
||||
}
|
||||
|
||||
int index = entry.zipFileIndex;
|
||||
if (index < 0 || index >= entries.Length || entries[index].Name != entry.Name) {
|
||||
index = GetEntryIndex(entry.Name);
|
||||
if (index < 0) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
long start = CheckLocalHeader(entries[index]);
|
||||
CompressionMethod method = entries[index].CompressionMethod;
|
||||
Stream istr = new PartialInputStream(baseStream, start, entries[index].CompressedSize);
|
||||
switch (method) {
|
||||
case CompressionMethod.Stored:
|
||||
return istr;
|
||||
case CompressionMethod.Deflated:
|
||||
return new InflaterInputStream(istr, new Inflater(true));
|
||||
default:
|
||||
throw new ZipException("Unknown compression method " + method);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of this zip file.
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of entries in this zip file.
|
||||
/// </summary>
|
||||
public int Size {
|
||||
get {
|
||||
try {
|
||||
return entries.Length;
|
||||
} catch (Exception) {
|
||||
throw new InvalidOperationException("ZipFile has closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ZipEntryEnumeration : IEnumerator
|
||||
{
|
||||
ZipEntry[] array;
|
||||
int ptr = -1;
|
||||
|
||||
public ZipEntryEnumeration(ZipEntry[] arr)
|
||||
{
|
||||
array = arr;
|
||||
}
|
||||
|
||||
public object Current {
|
||||
get {
|
||||
return array[ptr];
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
ptr = -1;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return (++ptr < array.Length);
|
||||
}
|
||||
}
|
||||
|
||||
class PartialInputStream : InflaterInputStream
|
||||
{
|
||||
Stream baseStream;
|
||||
long filepos, end;
|
||||
|
||||
public PartialInputStream(Stream baseStream, long start, long len) : base(baseStream)
|
||||
{
|
||||
this.baseStream = baseStream;
|
||||
filepos = start;
|
||||
end = start + len;
|
||||
}
|
||||
|
||||
public override int Available {
|
||||
get {
|
||||
long amount = end - filepos;
|
||||
if (amount > Int32.MaxValue) {
|
||||
return Int32.MaxValue;
|
||||
}
|
||||
|
||||
return (int) amount;
|
||||
}
|
||||
}
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (filepos == end) {
|
||||
return -1;
|
||||
}
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(filepos++, SeekOrigin.Begin);
|
||||
return baseStream.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
if (len > end - filepos) {
|
||||
len = (int) (end - filepos);
|
||||
if (len == 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
lock(baseStream) {
|
||||
baseStream.Seek(filepos, SeekOrigin.Begin);
|
||||
int count = baseStream.Read(b, off, len);
|
||||
if (count > 0) {
|
||||
filepos += len;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public long SkipBytes(long amount)
|
||||
{
|
||||
if (amount < 0) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
if (amount > end - filepos) {
|
||||
amount = end - filepos;
|
||||
}
|
||||
filepos += amount;
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
// ZipInputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This is a FilterInputStream that reads the files baseInputStream an zip archive
|
||||
/// one after another. It has a special method to get the zip entry of
|
||||
/// the next file. The zip entry contains information about the file name
|
||||
/// size, compressed size, CRC, etc.
|
||||
/// It includes support for STORED and DEFLATED entries.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
/// <example> This sample shows how to read a zip file
|
||||
/// <code>
|
||||
/// using System;
|
||||
/// using System.Text;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.Zip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
/// public static void Main(string[] args)
|
||||
/// {
|
||||
/// ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
|
||||
///
|
||||
/// ZipEntry theEntry;
|
||||
/// while ((theEntry = s.GetNextEntry()) != null) {
|
||||
/// Console.WriteLine("File " + theEntry.Name);
|
||||
/// int size = 2048;
|
||||
/// byte[] data = new byte[2048];
|
||||
///
|
||||
/// Console.Write("Show contents (y/n) ?");
|
||||
/// if (Console.ReadLine() == "y") {
|
||||
/// while (true) {
|
||||
/// size = s.Read(data, 0, data.Length);
|
||||
/// if (size > 0) {
|
||||
/// Console.Write(new ASCIIEncoding().GetString(data, 0, size));
|
||||
/// } else {
|
||||
/// break;
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// Console.WriteLine();
|
||||
/// }
|
||||
/// s.Close();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class ZipInputStream : InflaterInputStream
|
||||
{
|
||||
private Crc32 crc = new Crc32();
|
||||
private ZipEntry entry = null;
|
||||
|
||||
private long csize;
|
||||
private long size;
|
||||
private int method;
|
||||
private int flags;
|
||||
private long avail;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Zip input stream, reading a zip archive.
|
||||
/// </summary>
|
||||
public ZipInputStream(Stream baseInputStream) : base(baseInputStream, new Inflater(true))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FillBuf()
|
||||
{
|
||||
avail = len = baseInputStream.Read(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
private int ReadBuf(byte[] outBuf, int offset, int length)
|
||||
{
|
||||
if (avail <= 0) {
|
||||
FillBuf();
|
||||
if (avail <= 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (length > avail) {
|
||||
length = (int)avail;
|
||||
}
|
||||
System.Array.Copy(buf, len - (int)avail, outBuf, offset, length);
|
||||
avail -= length;
|
||||
return length;
|
||||
}
|
||||
|
||||
private void ReadFully(byte[] outBuf)
|
||||
{
|
||||
int off = 0;
|
||||
int len = outBuf.Length;
|
||||
while (len > 0) {
|
||||
int count = ReadBuf(outBuf, off, len);
|
||||
if (count == -1) {
|
||||
throw new Exception();
|
||||
}
|
||||
off += count;
|
||||
len -= count;
|
||||
}
|
||||
}
|
||||
|
||||
private int ReadLeByte()
|
||||
{
|
||||
if (avail <= 0) {
|
||||
FillBuf();
|
||||
if (avail <= 0) {
|
||||
throw new ZipException("EOF in header");
|
||||
}
|
||||
}
|
||||
return buf[len - avail--] & 0xff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read an unsigned short baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private int ReadLeShort()
|
||||
{
|
||||
return ReadLeByte() | (ReadLeByte() << 8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read an int baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private int ReadLeInt()
|
||||
{
|
||||
return ReadLeShort() | (ReadLeShort() << 16);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read an int baseInputStream little endian byte order.
|
||||
/// </summary>
|
||||
private long ReadLeLong()
|
||||
{
|
||||
return ReadLeInt() | (ReadLeInt() << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the next entry from the zip archive, and return its description.
|
||||
/// If the previous entry wasn't closed, this method will close it.
|
||||
/// </summary>
|
||||
public ZipEntry GetNextEntry()
|
||||
{
|
||||
if (crc == null) {
|
||||
throw new InvalidOperationException("Closed.");
|
||||
}
|
||||
if (entry != null) {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
int header = ReadLeInt();
|
||||
if (header == ZipConstants.CENSIG) {
|
||||
/* Central Header reached. */
|
||||
Close();
|
||||
return null;
|
||||
}
|
||||
if (header != ZipConstants.LOCSIG) {
|
||||
throw new ZipException("Wrong Local header signature" + header);
|
||||
}
|
||||
|
||||
short version = (short)ReadLeShort();
|
||||
|
||||
flags = ReadLeShort();
|
||||
method = ReadLeShort();
|
||||
int dostime = ReadLeInt();
|
||||
int crc2 = ReadLeInt();
|
||||
csize = ReadLeInt();
|
||||
size = ReadLeInt();
|
||||
int nameLen = ReadLeShort();
|
||||
int extraLen = ReadLeShort();
|
||||
|
||||
if (method == ZipOutputStream.STORED && csize != size) {
|
||||
throw new ZipException("Stored, but compressed != uncompressed");
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[nameLen];
|
||||
ReadFully(buffer);
|
||||
|
||||
string name = ZipConstants.ConvertToString(buffer);
|
||||
|
||||
entry = new ZipEntry(name);
|
||||
|
||||
entry.Version = (ushort)version;
|
||||
if (method != 0 && method != 8) {
|
||||
throw new ZipException("unknown compression method " + method);
|
||||
}
|
||||
entry.CompressionMethod = (CompressionMethod)method;
|
||||
|
||||
if ((flags & 8) == 0) {
|
||||
entry.Crc = crc2 & 0xFFFFFFFFL;
|
||||
entry.Size = size & 0xFFFFFFFFL;
|
||||
entry.CompressedSize = csize & 0xFFFFFFFFL;
|
||||
}
|
||||
entry.DosTime = dostime;
|
||||
if (extraLen > 0) {
|
||||
byte[] extra = new byte[extraLen];
|
||||
ReadFully(extra);
|
||||
entry.ExtraData = extra;
|
||||
}
|
||||
|
||||
if (method == ZipOutputStream.DEFLATED && avail > 0) {
|
||||
System.Array.Copy(buf, len - (int)avail, buf, 0, (int)avail);
|
||||
len = (int)avail;
|
||||
avail = 0;
|
||||
inf.SetInput(buf, 0, len);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
private void ReadDataDescr()
|
||||
{
|
||||
if (ReadLeInt() != ZipConstants.EXTSIG) {
|
||||
throw new ZipException("Data descriptor signature not found");
|
||||
}
|
||||
entry.Crc = ReadLeInt() & 0xFFFFFFFFL;
|
||||
csize = ReadLeInt();
|
||||
size = ReadLeInt();
|
||||
entry.Size = size & 0xFFFFFFFFL;
|
||||
entry.CompressedSize = csize & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the current zip entry and moves to the next one.
|
||||
/// </summary>
|
||||
public void CloseEntry()
|
||||
{
|
||||
if (crc == null) {
|
||||
throw new InvalidOperationException("Closed.");
|
||||
}
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method == ZipOutputStream.DEFLATED) {
|
||||
if ((flags & 8) != 0) {
|
||||
/* We don't know how much we must skip, read until end. */
|
||||
byte[] tmp = new byte[2048];
|
||||
while (Read(tmp, 0, tmp.Length) > 0)
|
||||
;
|
||||
/* read will close this entry */
|
||||
return;
|
||||
}
|
||||
csize -= inf.TotalIn;
|
||||
avail = inf.RemainingInput;
|
||||
}
|
||||
if (avail > csize && csize >= 0) {
|
||||
avail -= csize;
|
||||
} else {
|
||||
csize -= avail;
|
||||
avail = 0;
|
||||
while (csize != 0) {
|
||||
int skipped = (int)base.Skip(csize & 0xFFFFFFFFL);
|
||||
|
||||
if (skipped <= 0) {
|
||||
throw new ZipException("zip archive ends early.");
|
||||
}
|
||||
|
||||
csize -= skipped;
|
||||
}
|
||||
}
|
||||
|
||||
size = 0;
|
||||
crc.Reset();
|
||||
if (method == ZipOutputStream.DEFLATED) {
|
||||
inf.Reset();
|
||||
}
|
||||
entry = null;
|
||||
}
|
||||
|
||||
public override int Available {
|
||||
get {
|
||||
return entry != null ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte from the current zip entry.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the byte or -1 on EOF.
|
||||
/// </returns>
|
||||
/// <exception name="System.IO.IOException">
|
||||
/// IOException if a i/o error occured.
|
||||
/// </exception>
|
||||
/// <exception name="ICSharpCode.SharpZipLib.ZipException">
|
||||
/// ZipException if the deflated stream is corrupted.
|
||||
/// </exception>
|
||||
public override int ReadByte()
|
||||
{
|
||||
byte[] b = new byte[1];
|
||||
if (Read(b, 0, 1) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
return b[0] & 0xff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a block of bytes from the current zip entry.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the number of bytes read (may be smaller, even before EOF), or -1 on EOF.
|
||||
/// </returns>
|
||||
/// <exception name="Exception">
|
||||
/// IOException if a i/o error occured.
|
||||
/// ZipException if the deflated stream is corrupted.
|
||||
/// </exception>
|
||||
public override int Read(byte[] b, int off, int len)
|
||||
{
|
||||
if (crc == null) {
|
||||
throw new InvalidOperationException("Closed.");
|
||||
}
|
||||
if (entry == null) {
|
||||
return -1;
|
||||
}
|
||||
bool finished = false;
|
||||
|
||||
switch (method) {
|
||||
case ZipOutputStream.DEFLATED:
|
||||
len = base.Read(b, off, len);
|
||||
if (len < 0) {
|
||||
if (!inf.IsFinished) {
|
||||
throw new ZipException("Inflater not finished!?");
|
||||
}
|
||||
avail = inf.RemainingInput;
|
||||
if ((flags & 8) != 0) {
|
||||
ReadDataDescr();
|
||||
}
|
||||
|
||||
if (inf.TotalIn != csize || inf.TotalOut != size) {
|
||||
throw new ZipException("size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut);
|
||||
}
|
||||
inf.Reset();
|
||||
finished = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ZipOutputStream.STORED:
|
||||
|
||||
if (len > csize && csize >= 0) {
|
||||
len = (int)csize;
|
||||
}
|
||||
len = ReadBuf(b, off, len);
|
||||
if (len > 0) {
|
||||
csize -= len;
|
||||
size -= len;
|
||||
}
|
||||
|
||||
if (csize == 0) {
|
||||
finished = true;
|
||||
} else {
|
||||
if (len < 0) {
|
||||
throw new ZipException("EOF in stored block");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
crc.Update(b, off, len);
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
if ((crc.Value & 0xFFFFFFFFL) != entry.Crc) {
|
||||
throw new ZipException("CRC mismatch");
|
||||
}
|
||||
crc.Reset();
|
||||
entry = null;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the zip file.
|
||||
/// </summary>
|
||||
/// <exception name="Exception">
|
||||
/// if a i/o error occured.
|
||||
/// </exception>
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
crc = null;
|
||||
entry = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
// ZipOutputStream.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip {
|
||||
|
||||
/// <summary>
|
||||
/// This is a FilterOutputStream that writes the files into a zip
|
||||
/// archive one after another. It has a special method to start a new
|
||||
/// zip entry. The zip entries contains information about the file name
|
||||
/// size, compressed size, CRC, etc.
|
||||
///
|
||||
/// It includes support for STORED and DEFLATED entries.
|
||||
/// This class is not thread safe.
|
||||
///
|
||||
/// author of the original java version : Jochen Hoenicke
|
||||
/// </summary>
|
||||
/// <example> This sample shows how to create a zip file
|
||||
/// <code>
|
||||
/// using System;
|
||||
/// using System.IO;
|
||||
///
|
||||
/// using NZlib.Zip;
|
||||
///
|
||||
/// class MainClass
|
||||
/// {
|
||||
/// public static void Main(string[] args)
|
||||
/// {
|
||||
/// string[] filenames = Directory.GetFiles(args[0]);
|
||||
///
|
||||
/// ZipOutputStream s = new ZipOutputStream(File.Create(args[1]));
|
||||
///
|
||||
/// s.SetLevel(5); // 0 - store only to 9 - means best compression
|
||||
///
|
||||
/// foreach (string file in filenames) {
|
||||
/// FileStream fs = File.OpenRead(file);
|
||||
///
|
||||
/// byte[] buffer = new byte[fs.Length];
|
||||
/// fs.Read(buffer, 0, buffer.Length);
|
||||
///
|
||||
/// ZipEntry entry = new ZipEntry(file);
|
||||
///
|
||||
/// s.PutNextEntry(entry);
|
||||
///
|
||||
/// s.Write(buffer, 0, buffer.Length);
|
||||
///
|
||||
/// }
|
||||
///
|
||||
/// s.Finish();
|
||||
/// s.Close();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class ZipOutputStream : DeflaterOutputStream
|
||||
{
|
||||
private ArrayList entries = new ArrayList();
|
||||
private Crc32 crc = new Crc32();
|
||||
private ZipEntry curEntry = null;
|
||||
|
||||
private CompressionMethod curMethod;
|
||||
private int size;
|
||||
private int offset = 0;
|
||||
|
||||
private byte[] zipComment = new byte[0];
|
||||
private int defaultMethod = DEFLATED;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Our Zip version is hard coded to 1.0 resp. 2.0
|
||||
/// </summary>
|
||||
private const int ZIP_STORED_VERSION = 10;
|
||||
private const int ZIP_DEFLATED_VERSION = 20;
|
||||
|
||||
/// <summary>
|
||||
/// Compression method. This method doesn't compress at all.
|
||||
/// </summary>
|
||||
public const int STORED = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Compression method. This method uses the Deflater.
|
||||
/// </summary>
|
||||
public const int DEFLATED = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Zip output stream, writing a zip archive.
|
||||
/// </summary>
|
||||
/// <param name="baseOutputStream">
|
||||
/// the output stream to which the zip archive is written.
|
||||
/// </param>
|
||||
public ZipOutputStream(Stream baseOutputStream) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the zip file comment.
|
||||
/// </summary>
|
||||
/// <param name="comment">
|
||||
/// the comment.
|
||||
/// </param>
|
||||
/// <exception name ="ArgumentException">
|
||||
/// if UTF8 encoding of comment is longer than 0xffff bytes.
|
||||
/// </exception>
|
||||
public void SetComment(string comment)
|
||||
{
|
||||
byte[] commentBytes = ZipConstants.ConvertToArray(comment);
|
||||
if (commentBytes.Length > 0xffff) {
|
||||
throw new ArgumentException("Comment too long.");
|
||||
}
|
||||
zipComment = commentBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets default compression method. If the Zip entry specifies
|
||||
/// another method its method takes precedence.
|
||||
/// </summary>
|
||||
/// <param name = "method">
|
||||
/// the method.
|
||||
/// </param>
|
||||
/// <exception name = "ArgumentException">
|
||||
/// if method is not supported.
|
||||
/// </exception>
|
||||
public void SetMethod(int method)
|
||||
{
|
||||
if (method != STORED && method != DEFLATED) {
|
||||
throw new ArgumentException("Method not supported.");
|
||||
}
|
||||
defaultMethod = method;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets default compression level. The new level will be activated
|
||||
/// immediately.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// if level is not supported.
|
||||
/// </exception>
|
||||
/// <see cref="Deflater"/>
|
||||
public void SetLevel(int level)
|
||||
{
|
||||
def.SetLevel(level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an unsigned short in little endian byte order.
|
||||
/// </summary>
|
||||
private void WriteLeShort(int value)
|
||||
{
|
||||
baseOutputStream.WriteByte((byte)value);
|
||||
baseOutputStream.WriteByte((byte)(value >> 8));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an int in little endian byte order.
|
||||
/// </summary>
|
||||
private void WriteLeInt(int value)
|
||||
{
|
||||
WriteLeShort(value);
|
||||
WriteLeShort(value >> 16);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an int in little endian byte order.
|
||||
/// </summary>
|
||||
private void WriteLeLong(long value)
|
||||
{
|
||||
WriteLeInt((int)value);
|
||||
WriteLeInt((int)(value >> 32));
|
||||
}
|
||||
|
||||
|
||||
bool shouldWriteBack = false;
|
||||
long seekPos = -1;
|
||||
/// <summary>
|
||||
/// Starts a new Zip entry. It automatically closes the previous
|
||||
/// entry if present. If the compression method is stored, the entry
|
||||
/// must have a valid size and crc, otherwise all elements (except
|
||||
/// name) are optional, but must be correct if present. If the time
|
||||
/// is not set in the entry, the current time is used.
|
||||
/// </summary>
|
||||
/// <param name="entry">
|
||||
/// the entry.
|
||||
/// </param>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// if an I/O error occured.
|
||||
/// </exception>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if stream was finished
|
||||
/// </exception>
|
||||
public void PutNextEntry(ZipEntry entry)
|
||||
{
|
||||
if (entries == null) {
|
||||
throw new InvalidOperationException("ZipOutputStream was finished");
|
||||
}
|
||||
|
||||
CompressionMethod method = entry.CompressionMethod;
|
||||
int flags = 0;
|
||||
|
||||
switch (method) {
|
||||
case CompressionMethod.Stored:
|
||||
if (entry.CompressedSize >= 0) {
|
||||
if (entry.Size < 0) {
|
||||
entry.Size = entry.CompressedSize;
|
||||
} else if (entry.Size != entry.CompressedSize) {
|
||||
throw new ZipException("Method STORED, but compressed size != size");
|
||||
}
|
||||
} else {
|
||||
entry.CompressedSize = entry.Size;
|
||||
}
|
||||
|
||||
if (entry.Size < 0) {
|
||||
throw new ZipException("Method STORED, but size not set");
|
||||
} else if (entry.Crc < 0) {
|
||||
throw new ZipException("Method STORED, but crc not set");
|
||||
}
|
||||
break;
|
||||
case CompressionMethod.Deflated:
|
||||
if (entry.CompressedSize < 0 || entry.Size < 0 || entry.Crc < 0) {
|
||||
flags |= 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (curEntry != null) {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
// if (entry.DosTime < 0) {
|
||||
// entry.Time = System.Environment.TickCount;
|
||||
// }
|
||||
|
||||
entry.flags = flags;
|
||||
entry.offset = offset;
|
||||
entry.CompressionMethod = (CompressionMethod)method;
|
||||
|
||||
curMethod = method;
|
||||
// Write the local file header
|
||||
WriteLeInt(ZipConstants.LOCSIG);
|
||||
|
||||
// write ZIP version
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
if ((flags & 8) == 0) {
|
||||
WriteLeShort(flags);
|
||||
WriteLeShort((byte)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
WriteLeInt((int)entry.Crc);
|
||||
WriteLeInt((int)entry.CompressedSize);
|
||||
WriteLeInt((int)entry.Size);
|
||||
} else {
|
||||
if (baseOutputStream.CanSeek) {
|
||||
shouldWriteBack = true;
|
||||
WriteLeShort((short)(flags & ~8));
|
||||
} else {
|
||||
shouldWriteBack = false;
|
||||
WriteLeShort(flags);
|
||||
}
|
||||
WriteLeShort((byte)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
seekPos = baseOutputStream.Position;
|
||||
WriteLeInt(0);
|
||||
WriteLeInt(0);
|
||||
WriteLeInt(0);
|
||||
}
|
||||
byte[] name = ZipConstants.ConvertToArray(entry.Name);
|
||||
|
||||
if (name.Length > 0xFFFF) {
|
||||
throw new ZipException("Name too long.");
|
||||
}
|
||||
byte[] extra = entry.ExtraData;
|
||||
if (extra == null) {
|
||||
extra = new byte[0];
|
||||
}
|
||||
if (extra.Length > 0xFFFF) {
|
||||
throw new ZipException("Extra data too long.");
|
||||
}
|
||||
|
||||
WriteLeShort(name.Length);
|
||||
WriteLeShort(extra.Length);
|
||||
baseOutputStream.Write(name, 0, name.Length);
|
||||
baseOutputStream.Write(extra, 0, extra.Length);
|
||||
|
||||
offset += ZipConstants.LOCHDR + name.Length + extra.Length;
|
||||
|
||||
/* Activate the entry. */
|
||||
curEntry = entry;
|
||||
crc.Reset();
|
||||
if (method == CompressionMethod.Deflated) {
|
||||
def.Reset();
|
||||
}
|
||||
size = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the current entry.
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// if an I/O error occured.
|
||||
/// </exception>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no entry is active.
|
||||
/// </exception>
|
||||
public void CloseEntry()
|
||||
{
|
||||
if (curEntry == null) {
|
||||
throw new InvalidOperationException("No open entry");
|
||||
}
|
||||
|
||||
/* First finish the deflater, if appropriate */
|
||||
if (curMethod == CompressionMethod.Deflated) {
|
||||
base.Finish();
|
||||
}
|
||||
|
||||
int csize = curMethod == CompressionMethod.Deflated ? def.TotalOut : size;
|
||||
|
||||
if (curEntry.Size < 0) {
|
||||
curEntry.Size = size;
|
||||
} else if (curEntry.Size != size) {
|
||||
throw new ZipException("size was " + size +
|
||||
", but I expected " + curEntry.Size);
|
||||
}
|
||||
|
||||
if (curEntry.CompressedSize < 0) {
|
||||
curEntry.CompressedSize = csize;
|
||||
} else if (curEntry.CompressedSize != csize) {
|
||||
throw new ZipException("compressed size was " + csize +
|
||||
", but I expected " + curEntry.CompressedSize);
|
||||
}
|
||||
|
||||
if (curEntry.Crc < 0) {
|
||||
curEntry.Crc = crc.Value;
|
||||
} else if (curEntry.Crc != crc.Value) {
|
||||
throw new ZipException("crc was " + crc.Value +
|
||||
", but I expected " +
|
||||
curEntry.Crc);
|
||||
}
|
||||
|
||||
offset += csize;
|
||||
|
||||
/* Now write the data descriptor entry if needed. */
|
||||
if (curMethod == CompressionMethod.Deflated && (curEntry.flags & 8) != 0) {
|
||||
if (shouldWriteBack) {
|
||||
long curPos = baseOutputStream.Position;
|
||||
baseOutputStream.Seek(seekPos, SeekOrigin.Begin);
|
||||
WriteLeInt((int)curEntry.Crc);
|
||||
WriteLeInt((int)curEntry.CompressedSize);
|
||||
WriteLeInt((int)curEntry.Size);
|
||||
baseOutputStream.Seek(curPos, SeekOrigin.Begin);
|
||||
shouldWriteBack = false;
|
||||
} else {
|
||||
WriteLeInt(ZipConstants.EXTSIG);
|
||||
WriteLeInt((int)curEntry.Crc);
|
||||
WriteLeInt((int)curEntry.CompressedSize);
|
||||
WriteLeInt((int)curEntry.Size);
|
||||
offset += ZipConstants.EXTHDR;
|
||||
}
|
||||
}
|
||||
|
||||
entries.Add(curEntry);
|
||||
curEntry = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes the given buffer to the current entry.
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// if an I/O error occured.
|
||||
/// </exception>
|
||||
/// <exception cref="System.InvalidOperationException">
|
||||
/// if no entry is active.
|
||||
/// </exception>
|
||||
public override void Write(byte[] b, int off, int len)
|
||||
{
|
||||
if (curEntry == null) {
|
||||
throw new InvalidOperationException("No open entry.");
|
||||
}
|
||||
|
||||
switch (curMethod) {
|
||||
case CompressionMethod.Deflated:
|
||||
base.Write(b, off, len);
|
||||
break;
|
||||
case CompressionMethod.Stored:
|
||||
baseOutputStream.Write(b, off, len);
|
||||
break;
|
||||
}
|
||||
|
||||
crc.Update(b, off, len);
|
||||
size += len;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finishes the stream. This will write the central directory at the
|
||||
/// end of the zip file and flush the stream.
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// if an I/O error occured.
|
||||
/// </exception>
|
||||
public override void Finish()
|
||||
{
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
if (curEntry != null) {
|
||||
CloseEntry();
|
||||
}
|
||||
|
||||
int numEntries = 0;
|
||||
int sizeEntries = 0;
|
||||
|
||||
foreach (ZipEntry entry in entries) {
|
||||
// TODO : check the appnote file for compilance with the central directory standard
|
||||
CompressionMethod method = entry.CompressionMethod;
|
||||
WriteLeInt(ZipConstants.CENSIG);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
WriteLeShort(method == CompressionMethod.Stored ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
|
||||
WriteLeShort(entry.flags);
|
||||
WriteLeShort((short)method);
|
||||
WriteLeInt(entry.DosTime);
|
||||
WriteLeInt((int)entry.Crc);
|
||||
WriteLeInt((int)entry.CompressedSize);
|
||||
WriteLeInt((int)entry.Size);
|
||||
|
||||
byte[] name = ZipConstants.ConvertToArray(entry.Name);
|
||||
|
||||
if (name.Length > 0xffff) {
|
||||
throw new ZipException("Name too long.");
|
||||
}
|
||||
byte[] extra = entry.ExtraData;
|
||||
if (extra == null) {
|
||||
extra = new byte[0];
|
||||
}
|
||||
string strComment = entry.Comment;
|
||||
byte[] comment = strComment != null ? ZipConstants.ConvertToArray(strComment) : new byte[0];
|
||||
if (comment.Length > 0xffff) {
|
||||
throw new ZipException("Comment too long.");
|
||||
}
|
||||
|
||||
WriteLeShort(name.Length);
|
||||
WriteLeShort(extra.Length);
|
||||
WriteLeShort(comment.Length);
|
||||
WriteLeShort(0); /* disk number */
|
||||
WriteLeShort(0); /* internal file attr */
|
||||
WriteLeInt(0); /* external file attr */
|
||||
WriteLeInt(entry.offset);
|
||||
|
||||
baseOutputStream.Write(name, 0, name.Length);
|
||||
baseOutputStream.Write(extra, 0, extra.Length);
|
||||
baseOutputStream.Write(comment, 0, comment.Length);
|
||||
++numEntries;
|
||||
sizeEntries += ZipConstants.CENHDR + name.Length + extra.Length + comment.Length;
|
||||
}
|
||||
|
||||
WriteLeInt(ZipConstants.ENDSIG);
|
||||
WriteLeShort(0); /* disk number */
|
||||
WriteLeShort(0); /* disk with start of central dir */
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeShort(numEntries);
|
||||
WriteLeInt(sizeEntries);
|
||||
WriteLeInt(offset);
|
||||
WriteLeShort(zipComment.Length);
|
||||
baseOutputStream.Write(zipComment, 0, zipComment.Length);
|
||||
baseOutputStream.Flush();
|
||||
entries = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// ZipException.cs
|
||||
// Copyright (C) 2001 Mike Krueger
|
||||
//
|
||||
// This file was translated from java, it was part of the GNU Classpath
|
||||
// Copyright (C) 1998, 1999, 2000, 2001 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
|
||||
// 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.
|
||||
//
|
||||
// Linking this library statically or dynamically with other modules is
|
||||
// making a combined work based on this library. Thus, the terms and
|
||||
// conditions of the GNU General Public License cover the whole
|
||||
// combination.
|
||||
//
|
||||
// As a special exception, the copyright holders of this library give you
|
||||
// permission to link this library with independent modules to produce an
|
||||
// executable, regardless of the license terms of these independent
|
||||
// modules, and to copy and distribute the resulting executable under
|
||||
// terms of your choice, provided that you also meet, for each linked
|
||||
// independent module, the terms and conditions of the license of that
|
||||
// module. An independent module is a module which is not derived from
|
||||
// or based on this library. If you modify this library, you may extend
|
||||
// this exception to your version of the library, but you are not
|
||||
// obligated to do so. If you do not wish to do so, delete this
|
||||
// exception statement from your version.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib {
|
||||
|
||||
/// <summary>
|
||||
/// Is thrown during the creation or input of a zip file.
|
||||
/// </summary>
|
||||
public class ZipException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ZipException class with default properties.
|
||||
/// </summary>
|
||||
public ZipException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ZipException class with a specified error message.
|
||||
/// </summary>
|
||||
public ZipException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
This directory contains a local copy of the Zip library from the NZipLib project.
|
||||
|
||||
I have added this as a temporary measure to simplify the building and development
|
||||
of the Mono Documentation browser, but ideally it should use the real
|
||||
library. Do not fix bugs here, fix it on the original, and incorporate them
|
||||
here.
|
||||
|
||||
This code is released under this license, from:
|
||||
|
||||
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
|
||||
|
||||
Here it is:
|
||||
|
||||
The library is released under the GPL with the following exception:
|
||||
|
||||
Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
|
||||
|
||||
|
||||
Miguel. Jan, 2003
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<!-- NAnt build file for System.Data.dll -->
|
||||
|
||||
<project name="System.Data" default="build">
|
||||
<property name="debug" value="false"/>
|
||||
|
||||
<target name="build">
|
||||
<csc target="library" output="../lib/ICSharpCode.SharpZipLib.dll" debug="${debug}">
|
||||
<arg value="/nowarn:1595"/>
|
||||
<arg value="/nowarn:0067"/>
|
||||
<arg value="/nowarn:0109"/>
|
||||
<arg value="/nowarn:0169"/>
|
||||
<arg value="/nowarn:0679"/>
|
||||
<arg value="/nowarn:0649"/>
|
||||
<arg value="/unsafe"/>
|
||||
<arg value="/noconfig"/>
|
||||
<arg value="/r:System.dll"/>
|
||||
<arg value="/r:System.Xml.dll"/>
|
||||
<sources>
|
||||
<includes name="**/*.cs"/>
|
||||
<includes name="**/**/*.cs"/>
|
||||
<includes name="**/**/**/*.cs"/>
|
||||
</sources>
|
||||
<references>
|
||||
<includes name="../lib/corlib.dll"/>
|
||||
<includes name="../lib/System.dll"/>
|
||||
<includes name="../lib/System.Xml.dll"/>
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
<target name="test" depends="build">
|
||||
<nant basedir="Test" target="test"/>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete file="../lib/ICSharpCode.SharpZipLib.dll" failonerror="false"/>
|
||||
</target>
|
||||
</project>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
./ICSharpCode.SharpZipLib/BZip2/BZip2.cs
|
||||
./ICSharpCode.SharpZipLib/BZip2/BZip2Constants.cs
|
||||
./ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs
|
||||
./ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Checksums/Adler32.cs
|
||||
./ICSharpCode.SharpZipLib/Checksums/Crc32.cs
|
||||
./ICSharpCode.SharpZipLib/Checksums/IChecksum.cs
|
||||
./ICSharpCode.SharpZipLib/Checksums/StrangeCrc.cs
|
||||
./ICSharpCode.SharpZipLib/GZip/GZipConstants.cs
|
||||
./ICSharpCode.SharpZipLib/GZip/GZipInputStream.cs
|
||||
./ICSharpCode.SharpZipLib/GZip/GZipOutputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/InvalidHeaderException.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarArchive.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarBuffer.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarEntry.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarHeader.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarInputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Tar/TarOutputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Deflater.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/DeflaterConstants.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/DeflaterEngine.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/DeflaterPending.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Inflater.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/InflaterDynHeader.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Streams/OutputWindow.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/ZipConstants.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/ZipEntry.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/ZipFile.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/ZipInputStream.cs
|
||||
./ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs
|
||||
./ICSharpCode.SharpZipLib/AssemblyInfo.cs
|
||||
./ICSharpCode.SharpZipLib/ZipException.cs
|
||||
@@ -0,0 +1,14 @@
|
||||
topdir = ../..
|
||||
|
||||
TEST_DIR=
|
||||
LIBRARY = $(topdir)/class/lib/ICSharpCode.SharpZipLib.dll
|
||||
|
||||
LIB_LIST = list
|
||||
LIB_FLAGS = -r corlib -r System -r System.Xml
|
||||
|
||||
SOURCES_INCLUDE=*.cs
|
||||
SOURCES_EXCLUDE=
|
||||
|
||||
export MONO_PATH_PREFIX = $(topdir)/class/lib:
|
||||
|
||||
include $(topdir)/class/library.make
|
||||
@@ -3,8 +3,10 @@
|
||||
//
|
||||
// Author:
|
||||
// Chris J Breisch ([email protected])
|
||||
// Francesco Delfino ([email protected])
|
||||
//
|
||||
// (C) 2002 Chris J Breisch
|
||||
// 2002 [email protected]
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -13,29 +15,107 @@ namespace Microsoft.VisualBasic
|
||||
{
|
||||
sealed public class ErrObject {
|
||||
// Declarations
|
||||
int pHelpContext;
|
||||
int pLastDllError;
|
||||
int pNumber;
|
||||
int pErl;
|
||||
string pSource;
|
||||
string pHelpFile;
|
||||
string pDescription;
|
||||
System.Exception pException;
|
||||
// Constructors
|
||||
// Properties
|
||||
[MonoTODO]
|
||||
public System.Int32 HelpContext { get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } }
|
||||
public System.Int32 HelpContext
|
||||
{
|
||||
get {
|
||||
return pHelpContext;
|
||||
}
|
||||
set {
|
||||
pHelpContext = value;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.Int32 LastDllError { get { throw new NotImplementedException (); } }
|
||||
public System.Int32 LastDllError {
|
||||
get {
|
||||
return pLastDllError;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.Int32 Number { get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } }
|
||||
public System.Int32 Number {
|
||||
get {
|
||||
return pNumber;
|
||||
}
|
||||
set {
|
||||
pNumber = value;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.Int32 Erl { get { throw new NotImplementedException (); } }
|
||||
public System.Int32 Erl {
|
||||
get {
|
||||
return pErl;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.String Source { get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } }
|
||||
public System.String Source {
|
||||
get {
|
||||
return pSource;
|
||||
}
|
||||
set {
|
||||
pSource = value;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.String HelpFile { get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } }
|
||||
public System.String HelpFile {
|
||||
get {
|
||||
return pHelpFile;
|
||||
}
|
||||
set {
|
||||
pHelpFile = value;
|
||||
}
|
||||
}
|
||||
[MonoTODO]
|
||||
public System.String Description { get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } }
|
||||
public System.String Description {
|
||||
get {
|
||||
return pDescription;
|
||||
}
|
||||
set {
|
||||
pDescription = value;
|
||||
}
|
||||
}
|
||||
// Methods
|
||||
[MonoTODO("We should parse the exception object to obtain VB-like error code. Not a trivial task!")]
|
||||
internal void SetException (Exception ex)
|
||||
{
|
||||
if (pException != ex)
|
||||
{
|
||||
pNumber = 0xFFFF;
|
||||
pSource = ex.Source;
|
||||
pDescription = ex.Message + "\n" + ex.StackTrace;
|
||||
}
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public System.Exception GetException () { throw new NotImplementedException (); }
|
||||
public System.Exception GetException ()
|
||||
{
|
||||
return pException;
|
||||
}
|
||||
[MonoTODO]
|
||||
public void Clear () { throw new NotImplementedException (); }
|
||||
public void Clear () {
|
||||
pHelpContext=0;
|
||||
pLastDllError=0;
|
||||
pNumber=0;
|
||||
pErl=0;
|
||||
pSource="";
|
||||
pHelpFile="";
|
||||
pDescription="";
|
||||
pException= null;
|
||||
}
|
||||
[MonoTODO]
|
||||
public void Raise (System.Int32 Number, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object Source, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object Description, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object HelpFile, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object HelpContext) { throw new NotImplementedException (); }
|
||||
public void Raise (System.Int32 Number, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object Source, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object Description, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object HelpFile, [System.Runtime.InteropServices.Optional] [System.ComponentModel.DefaultValue(null)] System.Object HelpContext)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
// Events
|
||||
};
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1474 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user