Compare commits
1377 Commits
curl-7_19_
...
curl-7_20_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81219e8030 | ||
|
|
92b387f57a | ||
|
|
6432fafa1a | ||
|
|
9c7a9f8329 | ||
|
|
6ab2cae55e | ||
|
|
a8f85e778f | ||
|
|
f6b7471f40 | ||
|
|
32edba1999 | ||
|
|
5ccd7c1807 | ||
|
|
4f9b47de8c | ||
|
|
f9db721c1c | ||
|
|
cf9145973b | ||
|
|
d18fb4a129 | ||
|
|
26e3c74ab7 | ||
|
|
753b2a0086 | ||
|
|
7427acc472 | ||
|
|
02892e4fd8 | ||
|
|
10977f57de | ||
|
|
ef1ac363ee | ||
|
|
e6858e267b | ||
|
|
ff8711135e | ||
|
|
7425db3fab | ||
|
|
64ac64e783 | ||
|
|
e7e37a246a | ||
|
|
78b284014b | ||
|
|
9c049e109b | ||
|
|
49f3160d69 | ||
|
|
e78e584035 | ||
|
|
a681d46c1b | ||
|
|
1d265692b7 | ||
|
|
7b913444ec | ||
|
|
909fdc07bf | ||
|
|
8c6793d79a | ||
|
|
643ae2ca8b | ||
|
|
d1837ad90a | ||
|
|
fd10ed56d5 | ||
|
|
7e22d6332b | ||
|
|
3ec7543007 | ||
|
|
604a2bdac8 | ||
|
|
69ccc9f861 | ||
|
|
302507d5dc | ||
|
|
7784e3309d | ||
|
|
0eda142e90 | ||
|
|
e2bd52e553 | ||
|
|
d4fbf2c3f0 | ||
|
|
2b0c2ac49c | ||
|
|
7de44e0a42 | ||
|
|
05de2cf180 | ||
|
|
93e6b1cb7c | ||
|
|
5e1859014b | ||
|
|
e1c38791b7 | ||
|
|
ac8b2ef563 | ||
|
|
efcf372d86 | ||
|
|
675330b8df | ||
|
|
a1a66c7cd6 | ||
|
|
bed30bc6df | ||
|
|
d610519246 | ||
|
|
4f44717590 | ||
|
|
49d309866c | ||
|
|
481c61d060 | ||
|
|
ff438c994e | ||
|
|
5709a0dca2 | ||
|
|
05632d5db9 | ||
|
|
c245a8f92e | ||
|
|
d42f9329dc | ||
|
|
c869ae7447 | ||
|
|
9828b926ae | ||
|
|
8aa68b4cad | ||
|
|
1ac168e576 | ||
|
|
50b51161c9 | ||
|
|
661888c303 | ||
|
|
be28825b2d | ||
|
|
2309b4e330 | ||
|
|
dd0c31ce38 | ||
|
|
123c6d5c82 | ||
|
|
3f96b7827b | ||
|
|
4259d2df7d | ||
|
|
4b351d018e | ||
|
|
e32fe30d0c | ||
|
|
f5857a59bb | ||
|
|
7fd32ce73d | ||
|
|
2a94293efd | ||
|
|
b33ddd615a | ||
|
|
d4cd5411a6 | ||
|
|
6657f12fff | ||
|
|
3cd5b1cfb0 | ||
|
|
6572514ae5 | ||
|
|
abcea311e3 | ||
|
|
c8bfb9e58a | ||
|
|
9599837e63 | ||
|
|
1609685fc2 | ||
|
|
e1d6034977 | ||
|
|
3d3900f032 | ||
|
|
ad76d58e7f | ||
|
|
930742776a | ||
|
|
b40acd8009 | ||
|
|
19ca0c0fbe | ||
|
|
6728334edb | ||
|
|
749fd2f9e9 | ||
|
|
d9291eb4b8 | ||
|
|
8d6e8e00e1 | ||
|
|
12bb308cab | ||
|
|
733f794cb8 | ||
|
|
52cd332b95 | ||
|
|
3709ffc700 | ||
|
|
e37d1b1ee3 | ||
|
|
c7e647b88a | ||
|
|
5bb8bbed1e | ||
|
|
a09be6410f | ||
|
|
e262aaae2b | ||
|
|
a0c3edcc37 | ||
|
|
a24a67bd1e | ||
|
|
3036abb90c | ||
|
|
2e9eb1a2ac | ||
|
|
f5d8c0befc | ||
|
|
21f331ead2 | ||
|
|
f933747088 | ||
|
|
ce54bd113b | ||
|
|
f4551a9678 | ||
|
|
52f088ec1b | ||
|
|
a0fba2f66b | ||
|
|
013d5a72d4 | ||
|
|
9b2cce236f | ||
|
|
cd465e4ada | ||
|
|
6bf071df7e | ||
|
|
7c028a8332 | ||
|
|
13ac29382f | ||
|
|
8719398d05 | ||
|
|
53aa6b21fe | ||
|
|
7842704ee7 | ||
|
|
496002ea1c | ||
|
|
1a1ffb10d0 | ||
|
|
2a056ba49e | ||
|
|
eef316f099 | ||
|
|
03a57308b9 | ||
|
|
507d58435a | ||
|
|
dc21a5e5a1 | ||
|
|
cef95aadeb | ||
|
|
697496ff99 | ||
|
|
bcd1c7c2e9 | ||
|
|
87428e07ca | ||
|
|
01fb0d8497 | ||
|
|
cce81a7f45 | ||
|
|
4ad984043e | ||
|
|
6a8aa246ff | ||
|
|
e25c5283d8 | ||
|
|
5695c4db86 | ||
|
|
aa0f8593b9 | ||
|
|
4186b5b41f | ||
|
|
8904064c3a | ||
|
|
5b778a7ca4 | ||
|
|
439f62bfa8 | ||
|
|
693abbae3a | ||
|
|
e1625ba727 | ||
|
|
338553eda3 | ||
|
|
2abcd132f8 | ||
|
|
dc9f0a9758 | ||
|
|
10affed097 | ||
|
|
25a49ccd21 | ||
|
|
9ac65581bb | ||
|
|
a4a60afabb | ||
|
|
a434cb43e8 | ||
|
|
846b926a3f | ||
|
|
f0d3930346 | ||
|
|
a6fb6b70c7 | ||
|
|
2179ef9fa9 | ||
|
|
048438345a | ||
|
|
6e461e45c3 | ||
|
|
19e089702a | ||
|
|
23bab783d4 | ||
|
|
46b112bcd4 | ||
|
|
f442dd6496 | ||
|
|
bb2d9c3704 | ||
|
|
d5b2d8e081 | ||
|
|
4b43d18c4a | ||
|
|
2596fe0cb7 | ||
|
|
f1106049d9 | ||
|
|
a07bc79117 | ||
|
|
2268657272 | ||
|
|
68d83a8142 | ||
|
|
b4ff6d3007 | ||
|
|
68b73bcfba | ||
|
|
ac04add596 | ||
|
|
c703d01a23 | ||
|
|
975814368a | ||
|
|
dc6adb54fb | ||
|
|
2138ee7628 | ||
|
|
4258e943a1 | ||
|
|
c3b87d1b4f | ||
|
|
547931366d | ||
|
|
b41d3be7fa | ||
|
|
07fc7852d7 | ||
|
|
99f366adf9 | ||
|
|
d20a2469ea | ||
|
|
1abff19a5f | ||
|
|
77066c6e47 | ||
|
|
f2f07dad34 | ||
|
|
06ae8ca5a6 | ||
|
|
d33da42334 | ||
|
|
e118cd4ca0 | ||
|
|
71593dfe57 | ||
|
|
0f4a91afde | ||
|
|
2c2464a682 | ||
|
|
880452d2ed | ||
|
|
e3009f2950 | ||
|
|
cad9c3f55f | ||
|
|
12d01bc5f7 | ||
|
|
bc7615ae2d | ||
|
|
7aef172a34 | ||
|
|
f47b84b57f | ||
|
|
1a5749424b | ||
|
|
a9a5a8e45c | ||
|
|
8044366134 | ||
|
|
15efa262bb | ||
|
|
429e544556 | ||
|
|
680434f313 | ||
|
|
c9f46446d5 | ||
|
|
b77d0db59e | ||
|
|
3205ac35b0 | ||
|
|
381a4d6efe | ||
|
|
f6d288a397 | ||
|
|
013ec6a92f | ||
|
|
e2fc294470 | ||
|
|
d1717e7c90 | ||
|
|
e569ff959f | ||
|
|
839b61c32a | ||
|
|
d28b8d3158 | ||
|
|
2dfbd0d050 | ||
|
|
54879d7763 | ||
|
|
49ba75af26 | ||
|
|
232d17ec64 | ||
|
|
bafba6946c | ||
|
|
da23b16ad8 | ||
|
|
46de140aca | ||
|
|
17a2c32ca9 | ||
|
|
9f6c4daa27 | ||
|
|
ea72194650 | ||
|
|
35e220606d | ||
|
|
55f1e787f3 | ||
|
|
516cf5c8dd | ||
|
|
35fbeda003 | ||
|
|
715e3a806f | ||
|
|
6ebd71d186 | ||
|
|
4ee4e66c4f | ||
|
|
4d19ebe738 | ||
|
|
5312fdcd73 | ||
|
|
fce02e1cab | ||
|
|
15ddc1f134 | ||
|
|
d65cf7889b | ||
|
|
ddab9bd2ec | ||
|
|
eff18763a1 | ||
|
|
3e21f1e971 | ||
|
|
ccffed997e | ||
|
|
6259bcd51f | ||
|
|
a4031dbd85 | ||
|
|
2f3bce1193 | ||
|
|
3cb76e5ebb | ||
|
|
6418c0588d | ||
|
|
124b35aafe | ||
|
|
bbefdf88fd | ||
|
|
06c96d01d2 | ||
|
|
83e91586ef | ||
|
|
c82a1f95eb | ||
|
|
d34982bb65 | ||
|
|
22ed0f5059 | ||
|
|
9bc897f380 | ||
|
|
9b0e57b0f7 | ||
|
|
1d86ebfc88 | ||
|
|
a9b860765d | ||
|
|
483ff1ca75 | ||
|
|
c054b8bfa7 | ||
|
|
340ab2f87f | ||
|
|
f8b16e5ccb | ||
|
|
4bb80cfd75 | ||
|
|
de2cc11a73 | ||
|
|
c656098ee0 | ||
|
|
94f33457d3 | ||
|
|
80675818e0 | ||
|
|
b0e2d47a3e | ||
|
|
0abd928d3d | ||
|
|
597ad5a2ce | ||
|
|
703fa98a48 | ||
|
|
ec4647c0f9 | ||
|
|
33ce0ec1f1 | ||
|
|
1435864030 | ||
|
|
4a8a731476 | ||
|
|
6636fbf238 | ||
|
|
c94d44505f | ||
|
|
0032ce762e | ||
|
|
bdb338b3c7 | ||
|
|
099eed7bf1 | ||
|
|
bc253a4d5f | ||
|
|
a771fb0d41 | ||
|
|
c047fe8e90 | ||
|
|
e45eefcb90 | ||
|
|
844c19cc5b | ||
|
|
4a8570313a | ||
|
|
e59a5cbe4e | ||
|
|
bfc4c33985 | ||
|
|
5af20c70e4 | ||
|
|
bd7430c1ee | ||
|
|
6e5acc2fc1 | ||
|
|
abe3e6b36c | ||
|
|
105e430641 | ||
|
|
4a349f7a54 | ||
|
|
2f9a17fc44 | ||
|
|
bc4582b68a | ||
|
|
e09718d457 | ||
|
|
2c0418f154 | ||
|
|
a74e885bef | ||
|
|
6291a1cf23 | ||
|
|
a872ff742c | ||
|
|
58a1557088 | ||
|
|
422a7869be | ||
|
|
471e8eefb6 | ||
|
|
d2e1ec58f2 | ||
|
|
48032c0880 | ||
|
|
877dad1e24 | ||
|
|
01030e9240 | ||
|
|
a5ca3f1754 | ||
|
|
77a17a21d1 | ||
|
|
6035a4b044 | ||
|
|
469d3ed591 | ||
|
|
3afe2b65b6 | ||
|
|
afdc3d81e9 | ||
|
|
ccfe279117 | ||
|
|
5b5ff41ef1 | ||
|
|
0a713139f6 | ||
|
|
0687bc6bd6 | ||
|
|
424a8882fb | ||
|
|
3fdced357b | ||
|
|
ce2ac665e4 | ||
|
|
0375f70b5c | ||
|
|
7f8980114b | ||
|
|
312494f25f | ||
|
|
8d97b33347 | ||
|
|
b51b703a5b | ||
|
|
071c38988d | ||
|
|
365e75a270 | ||
|
|
b992928f3d | ||
|
|
32413a8e34 | ||
|
|
ada2774ab2 | ||
|
|
a644af129e | ||
|
|
7624527591 | ||
|
|
383bf1e476 | ||
|
|
8c8df3966b | ||
|
|
4344215309 | ||
|
|
0643829444 | ||
|
|
7525670610 | ||
|
|
b32a96eda0 | ||
|
|
82f5ffff8f | ||
|
|
3fd67b5f36 | ||
|
|
1647d64a4b | ||
|
|
d17416190b | ||
|
|
2158e234aa | ||
|
|
cb348a5b1f | ||
|
|
377b2db05b | ||
|
|
78b7d7f7a8 | ||
|
|
5bec1b1cf0 | ||
|
|
cd7b12edff | ||
|
|
1103d0c718 | ||
|
|
aae97c998a | ||
|
|
017c14cc99 | ||
|
|
b90703f594 | ||
|
|
552c3de357 | ||
|
|
aa2f447400 | ||
|
|
184f92d243 | ||
|
|
a1d701d05a | ||
|
|
a114b7b1c0 | ||
|
|
8524c04ca9 | ||
|
|
31630203b1 | ||
|
|
d37a9c4f87 | ||
|
|
88944eb13a | ||
|
|
bd8096b42b | ||
|
|
1e87e4bb4e | ||
|
|
9bd03483ce | ||
|
|
2e83006603 | ||
|
|
fd903eb6be | ||
|
|
2c93ec5303 | ||
|
|
d79b5a0613 | ||
|
|
a62f32d3c2 | ||
|
|
241c0ad5bd | ||
|
|
605bbfc4c0 | ||
|
|
42d365f199 | ||
|
|
31266ca92a | ||
|
|
3f3f6be825 | ||
|
|
01682cca55 | ||
|
|
99a5a5a3e9 | ||
|
|
eb0479575a | ||
|
|
97141d08f7 | ||
|
|
99e9938617 | ||
|
|
6c6dc3f879 | ||
|
|
a1311e5a24 | ||
|
|
5e6ffe353a | ||
|
|
d7cd761047 | ||
|
|
05488d63d0 | ||
|
|
3184a91ec8 | ||
|
|
0dde9056d7 | ||
|
|
a487c80535 | ||
|
|
1e9a946e6d | ||
|
|
7cd5ffc1bf | ||
|
|
fa6631edd5 | ||
|
|
e70c0913b1 | ||
|
|
5b2a31ae41 | ||
|
|
c796f2646e | ||
|
|
d0f6bde732 | ||
|
|
1bd5784a13 | ||
|
|
1f7d9f4f7b | ||
|
|
b6ac8d62a1 | ||
|
|
4ec17a08bc | ||
|
|
aefe0299e0 | ||
|
|
b89789d82f | ||
|
|
a218235964 | ||
|
|
73ad32e125 | ||
|
|
77625f8560 | ||
|
|
1af64730e0 | ||
|
|
eacf62792f | ||
|
|
6ce407305b | ||
|
|
ae3892e8ab | ||
|
|
c74875d94e | ||
|
|
271dc9c582 | ||
|
|
7bede9180d | ||
|
|
f0917cabb5 | ||
|
|
96395a908a | ||
|
|
e9a993b9e9 | ||
|
|
982fe33924 | ||
|
|
fa188eec7b | ||
|
|
bdd3763980 | ||
|
|
1cfa52b67d | ||
|
|
57d3488a0d | ||
|
|
83d34a246e | ||
|
|
76b3c9d70f | ||
|
|
d911e22d8f | ||
|
|
efd1d9dc04 | ||
|
|
88a0060b2e | ||
|
|
4adf7d62d4 | ||
|
|
6add5baa3a | ||
|
|
2a3dafc0cd | ||
|
|
f912f8d5d2 | ||
|
|
af7a5b297f | ||
|
|
344bbcf259 | ||
|
|
240fa29e94 | ||
|
|
010fe5acd5 | ||
|
|
aeec8e0b38 | ||
|
|
2d15ac3d4e | ||
|
|
53deae3781 | ||
|
|
39cc424e81 | ||
|
|
4d0b0cae9e | ||
|
|
8343cb8910 | ||
|
|
a75d9d9169 | ||
|
|
54c60d0067 | ||
|
|
91d05903b4 | ||
|
|
10a11e3abe | ||
|
|
414180b363 | ||
|
|
7603a29fc3 | ||
|
|
002ed5f298 | ||
|
|
044ba6dad2 | ||
|
|
3802d027cd | ||
|
|
3111701c38 | ||
|
|
2c9644b812 | ||
|
|
99daca5a48 | ||
|
|
a6abbb120e | ||
|
|
b0f548fb56 | ||
|
|
364d76aca7 | ||
|
|
6e9a484ea6 | ||
|
|
303f74c740 | ||
|
|
4ea8ad584b | ||
|
|
19b8a80ee9 | ||
|
|
30eb452adf | ||
|
|
92b9b46831 | ||
|
|
83a6b34803 | ||
|
|
43fefab2a1 | ||
|
|
ec3bb8f727 | ||
|
|
463d2d395c | ||
|
|
2fc1752d6e | ||
|
|
296ebf382c | ||
|
|
b91ed67276 | ||
|
|
315253b367 | ||
|
|
3b1de97eaa | ||
|
|
5ce6454d33 | ||
|
|
0653fa107f | ||
|
|
ebe5339003 | ||
|
|
95362af43c | ||
|
|
d14bf09ab8 | ||
|
|
636d2fe00a | ||
|
|
fb2425b147 | ||
|
|
2286f566d0 | ||
|
|
ed2aa87e63 | ||
|
|
f0826974f2 | ||
|
|
d61690ef46 | ||
|
|
a72ce23f16 | ||
|
|
bfae1bd999 | ||
|
|
8a7231d7ae | ||
|
|
4d922545d5 | ||
|
|
1fc32d866a | ||
|
|
230dc699e2 | ||
|
|
3f6854272f | ||
|
|
448f6684bb | ||
|
|
af06a0e497 | ||
|
|
6e38cc9048 | ||
|
|
a240f4d1df | ||
|
|
6f273b1a5f | ||
|
|
f07f17f2a4 | ||
|
|
c713627412 | ||
|
|
b1a35cd3ac | ||
|
|
9cbf69ca0b | ||
|
|
c7d2e4c1e1 | ||
|
|
cbd527843b | ||
|
|
fba233bb34 | ||
|
|
8b49428298 | ||
|
|
19f79e5a79 | ||
|
|
e20f3ecd7e | ||
|
|
c83f7ede26 | ||
|
|
f385fdefbe | ||
|
|
88fe6557e9 | ||
|
|
405e18571e | ||
|
|
094afbeb56 | ||
|
|
1fddcb3f88 | ||
|
|
b723500af0 | ||
|
|
4bfa0b08de | ||
|
|
e536cb085f | ||
|
|
083e2df4ed | ||
|
|
b7997d8a3b | ||
|
|
c80b593e5b | ||
|
|
e37f8164a9 | ||
|
|
35d4c57051 | ||
|
|
f6114f2ec4 | ||
|
|
f9e55c9908 | ||
|
|
3005e63b02 | ||
|
|
65e628cc97 | ||
|
|
738e547815 | ||
|
|
5ec8a3ae06 | ||
|
|
fdfbc5d8da | ||
|
|
504e6d7ae6 | ||
|
|
c3266a5eb1 | ||
|
|
ced1e1e726 | ||
|
|
a41493b3b0 | ||
|
|
6da73d09f1 | ||
|
|
4c0ffd33f5 | ||
|
|
99363a0ee1 | ||
|
|
71260534f9 | ||
|
|
5e62be1d8c | ||
|
|
7e6a67b436 | ||
|
|
5a0a473c30 | ||
|
|
5129442ee7 | ||
|
|
e8fd5d8062 | ||
|
|
2f6dcaa644 | ||
|
|
59939313f8 | ||
|
|
961c504ca5 | ||
|
|
b32d1a9a1d | ||
|
|
4c8adc8fee | ||
|
|
69ac7b0cf8 | ||
|
|
09526fc9e9 | ||
|
|
f0068267ee | ||
|
|
7db7c0af4f | ||
|
|
6bf10a111f | ||
|
|
530fde3a22 | ||
|
|
5b3be2ee35 | ||
|
|
3b8d7fddf7 | ||
|
|
0e80f0e4c4 | ||
|
|
a2ddb0a61b | ||
|
|
581ce03345 | ||
|
|
f7f76e17c3 | ||
|
|
1cbc93fb54 | ||
|
|
a8ddd6ce31 | ||
|
|
eb16c0e1eb | ||
|
|
9c49e51f7e | ||
|
|
90bc6ee8f3 | ||
|
|
5e75817d44 | ||
|
|
a7e4022d6b | ||
|
|
4999847625 | ||
|
|
d26a92493a | ||
|
|
05a4abea04 | ||
|
|
c1f9440aca | ||
|
|
011a2818db | ||
|
|
571309dc3e | ||
|
|
d547d00f2c | ||
|
|
668dc0ad87 | ||
|
|
0b7e0eed49 | ||
|
|
9b7e45e874 | ||
|
|
40c2c3270d | ||
|
|
b3e8cf539d | ||
|
|
fb5f332834 | ||
|
|
107c4d878a | ||
|
|
5d786d0e97 | ||
|
|
5f77eea408 | ||
|
|
a0905ec0ab | ||
|
|
d7470a3629 | ||
|
|
2287e7ba8b | ||
|
|
16a1e251cd | ||
|
|
1aa320dedb | ||
|
|
d17ce4e9f1 | ||
|
|
50c3417686 | ||
|
|
46f294dbb0 | ||
|
|
d7231f54d7 | ||
|
|
809f2a190c | ||
|
|
4f62cdf6f9 | ||
|
|
b8012ea251 | ||
|
|
02673a8900 | ||
|
|
676e0c28e7 | ||
|
|
55e68ba333 | ||
|
|
3f56d12830 | ||
|
|
257f2376d5 | ||
|
|
1d8d389bce | ||
|
|
99e43046a7 | ||
|
|
a5460f2431 | ||
|
|
6bf9d56485 | ||
|
|
367114bc87 | ||
|
|
81d45ed3a2 | ||
|
|
7d74e02519 | ||
|
|
7611d30a05 | ||
|
|
3704375292 | ||
|
|
ea1f30e686 | ||
|
|
9732b7cebe | ||
|
|
f39380b1ac | ||
|
|
c8da2980ed | ||
|
|
b19dc0eeb0 | ||
|
|
41de897b6b | ||
|
|
108b414bb8 | ||
|
|
be7af8beaa | ||
|
|
db1281fa9b | ||
|
|
223d848104 | ||
|
|
d8884168e3 | ||
|
|
5dd64e9e4b | ||
|
|
ce6731baf1 | ||
|
|
2c0b65d37b | ||
|
|
a76f4ab7dd | ||
|
|
d68f215f03 | ||
|
|
0a5ac52b49 | ||
|
|
8acb3803e4 | ||
|
|
ac62a94de3 | ||
|
|
0abcb37e3f | ||
|
|
7da5efd55c | ||
|
|
d4ff44d5f6 | ||
|
|
fff706d702 | ||
|
|
eac4310b2e | ||
|
|
e87ee29e32 | ||
|
|
61ebbc01ed | ||
|
|
15f425bdb8 | ||
|
|
861092637b | ||
|
|
3717b7a792 | ||
|
|
950a034895 | ||
|
|
982e655c07 | ||
|
|
308497ffc6 | ||
|
|
b205525d34 | ||
|
|
654b6b6c63 | ||
|
|
3b908ed143 | ||
|
|
265ed24ac0 | ||
|
|
57eeee2ec3 | ||
|
|
6a79b0e859 | ||
|
|
0d9f14f5c1 | ||
|
|
9fced16efb | ||
|
|
f16868d301 | ||
|
|
21af9bf1cd | ||
|
|
b2f4308980 | ||
|
|
6a37135f4d | ||
|
|
b8e1e63379 | ||
|
|
448d2b5f49 | ||
|
|
7867d44251 | ||
|
|
2380ca1714 | ||
|
|
a1cc78d5a1 | ||
|
|
7531ac89d6 | ||
|
|
72acffc66c | ||
|
|
525549f204 | ||
|
|
3f8d3e9c50 | ||
|
|
1951cd1eee | ||
|
|
55aee95f11 | ||
|
|
777134a07b | ||
|
|
4b8ce9423f | ||
|
|
051ab439a9 | ||
|
|
12e60c6d4e | ||
|
|
ff3223259f | ||
|
|
3da1ade4e5 | ||
|
|
ff40c83aa7 | ||
|
|
f49427d364 | ||
|
|
04e8ff84fe | ||
|
|
6f4a5a4612 | ||
|
|
6d4e6cc813 | ||
|
|
86cec97b22 | ||
|
|
e5ee822745 | ||
|
|
167a92810a | ||
|
|
b8b8c3d538 | ||
|
|
21105ab344 | ||
|
|
e49d928ce4 | ||
|
|
5e253785af | ||
|
|
3cbc8d1ba3 | ||
|
|
b4af26a188 | ||
|
|
6daede08cb | ||
|
|
3669ff3c1e | ||
|
|
9afdb05fe8 | ||
|
|
4d9279cb3b | ||
|
|
640e49976f | ||
|
|
f1aa936d2c | ||
|
|
a5ba25a5f6 | ||
|
|
b4e6418aef | ||
|
|
0077a6d51b | ||
|
|
4798f4e652 | ||
|
|
b38e28b6bc | ||
|
|
052dac0d3f | ||
|
|
2eeafcf9a6 | ||
|
|
45e093fc45 | ||
|
|
e593715d72 | ||
|
|
1209f2c014 | ||
|
|
7c821a85f8 | ||
|
|
cf367a62ce | ||
|
|
b233957885 | ||
|
|
492aed1450 | ||
|
|
cd91a1eeca | ||
|
|
5ed274d0b7 | ||
|
|
4271f44a9e | ||
|
|
78d07cb0f9 | ||
|
|
5b11e3883c | ||
|
|
7d22ce5573 | ||
|
|
b64dd3c63d | ||
|
|
0ea6abe7df | ||
|
|
8646cecb78 | ||
|
|
867a0de670 | ||
|
|
4f47fc4e14 | ||
|
|
8d39a31e89 | ||
|
|
66fcebdc9e | ||
|
|
af9ce990f0 | ||
|
|
e3d623f190 | ||
|
|
15be441ad8 | ||
|
|
c7c84e7420 | ||
|
|
37489a855f | ||
|
|
f03130a36e | ||
|
|
a1d18227e5 | ||
|
|
1549605c55 | ||
|
|
14a3f4cd54 | ||
|
|
9448659fc6 | ||
|
|
4002714825 | ||
|
|
61ea058d9f | ||
|
|
0fdb77d643 | ||
|
|
0c90cb7b83 | ||
|
|
ede2ac0ea2 | ||
|
|
d006efebc0 | ||
|
|
f2f45339dc | ||
|
|
be5c815f63 | ||
|
|
31e106ced2 | ||
|
|
250ba99498 | ||
|
|
c2c3a46e3e | ||
|
|
3eee678ab1 | ||
|
|
62ed553054 | ||
|
|
e3049e98d8 | ||
|
|
86f9168797 | ||
|
|
f7690db37d | ||
|
|
7e0b0763fc | ||
|
|
c67c4e7095 | ||
|
|
64a05e540e | ||
|
|
beb0a345ac | ||
|
|
f60cb60fc6 | ||
|
|
4002fbe1f5 | ||
|
|
7ff4b4f2b5 | ||
|
|
945feafe25 | ||
|
|
5389ac0ddf | ||
|
|
5d4a1e245b | ||
|
|
3c199daa95 | ||
|
|
4dd33ac575 | ||
|
|
bb3bbfe56d | ||
|
|
f09de577f5 | ||
|
|
c2ce4e55f0 | ||
|
|
5e3796349a | ||
|
|
56a161e09a | ||
|
|
2786ecaeef | ||
|
|
1486a11839 | ||
|
|
c4c15288d2 | ||
|
|
aaed838872 | ||
|
|
43fba2627a | ||
|
|
7df26a5415 | ||
|
|
f3611c2773 | ||
|
|
d5de849552 | ||
|
|
6569a23890 | ||
|
|
2cf0f80e9f | ||
|
|
223c0b980b | ||
|
|
7ab1139f07 | ||
|
|
d055226949 | ||
|
|
cf910f3097 | ||
|
|
183c9ce1cf | ||
|
|
777168cb77 | ||
|
|
0dd6c329e3 | ||
|
|
7a642c8bf1 | ||
|
|
e47c939822 | ||
|
|
a0bbe25eef | ||
|
|
b96f11f7ec | ||
|
|
7e07da977c | ||
|
|
ddb1fb7535 | ||
|
|
ea2754e028 | ||
|
|
ceda7e98f8 | ||
|
|
2d0aca3b92 | ||
|
|
4e9d3c26ed | ||
|
|
f3bd0c3fc3 | ||
|
|
eb438719f7 | ||
|
|
44e2832b2a | ||
|
|
9539d32298 | ||
|
|
60c0994677 | ||
|
|
e7f81d59b0 | ||
|
|
f1320d6733 | ||
|
|
68f7d5b8d3 | ||
|
|
e8baa332d7 | ||
|
|
39704bec3c | ||
|
|
fad14bca01 | ||
|
|
9e8eec4816 | ||
|
|
fa2ea23c96 | ||
|
|
1a255e0e28 | ||
|
|
1d92cf1dab | ||
|
|
8d1e46bdcc | ||
|
|
b0b2824b58 | ||
|
|
0cb6f3053f | ||
|
|
95c2b205a4 | ||
|
|
6ede4ce79d | ||
|
|
10f2fa9c72 | ||
|
|
8b5102ca83 | ||
|
|
1048043963 | ||
|
|
2c4fcf2ea8 | ||
|
|
681162510a | ||
|
|
5c59ee9488 | ||
|
|
9075195ec4 | ||
|
|
62960f8a42 | ||
|
|
6293fe98a0 | ||
|
|
5c716247aa | ||
|
|
daf688eba6 | ||
|
|
c6712a0c6c | ||
|
|
4d74b52656 | ||
|
|
be2fcbcbf1 | ||
|
|
6247b6d468 | ||
|
|
966cb698e6 | ||
|
|
4b44638f4d | ||
|
|
13afff5752 | ||
|
|
e73fe837a8 | ||
|
|
a9caeb1064 | ||
|
|
171eef68c3 | ||
|
|
33368ebd02 | ||
|
|
501f9f8309 | ||
|
|
9fe787fc1f | ||
|
|
0dec3e5e6a | ||
|
|
66f5baa16e | ||
|
|
1cb921b7f3 | ||
|
|
0cf6721898 | ||
|
|
97c8bc9757 | ||
|
|
2cad095425 | ||
|
|
37d509f04f | ||
|
|
35eb9fc6ad | ||
|
|
df09088a96 | ||
|
|
1a14966577 | ||
|
|
0606b792f0 | ||
|
|
a53525e930 | ||
|
|
3a9c03bef3 | ||
|
|
f0dbdcff9d | ||
|
|
9d03dd7fb8 | ||
|
|
781b82baf5 | ||
|
|
2838362a7b | ||
|
|
0b66efac9c | ||
|
|
47a9660ec1 | ||
|
|
aabf62e7d2 | ||
|
|
6d891d2a3b | ||
|
|
c0e8bed5bf | ||
|
|
0dce2ff8a0 | ||
|
|
2642638fca | ||
|
|
8b0fc9819f | ||
|
|
bf5f91244b | ||
|
|
e8e84cf1da | ||
|
|
0179dbe1c2 | ||
|
|
8978b87728 | ||
|
|
0684128209 | ||
|
|
9b5c00a664 | ||
|
|
b347a7a96e | ||
|
|
240bfaa69e | ||
|
|
7dc48e57a6 | ||
|
|
8570883412 | ||
|
|
1d5627b181 | ||
|
|
038fff6c9f | ||
|
|
21dd9a8021 | ||
|
|
59934c1176 | ||
|
|
2f6ff57d96 | ||
|
|
77eba8727d | ||
|
|
47c392e135 | ||
|
|
9cff716925 | ||
|
|
4c207a004c | ||
|
|
650543a042 | ||
|
|
5f0cae8037 | ||
|
|
95c2ab77e7 | ||
|
|
d7f33b7e4e | ||
|
|
56e6441ceb | ||
|
|
b74b5e0602 | ||
|
|
b4dcbbfabd | ||
|
|
6dd0277c22 | ||
|
|
fb08218a04 | ||
|
|
08d95bff5e | ||
|
|
b476530755 | ||
|
|
a8ea1e9ef4 | ||
|
|
6dade671ad | ||
|
|
38b88b5892 | ||
|
|
340e3b952f | ||
|
|
35c91f6ea9 | ||
|
|
f5f9354093 | ||
|
|
600460ffc6 | ||
|
|
18b3833f90 | ||
|
|
f671d0513c | ||
|
|
100f6b7703 | ||
|
|
4e75c70874 | ||
|
|
bdbfe1f8a9 | ||
|
|
bea9d2cafd | ||
|
|
d709cb2ae3 | ||
|
|
444bb03fab | ||
|
|
966cc10fcc | ||
|
|
0c7087c41f | ||
|
|
c42a06bc1f | ||
|
|
b4c00a8fb0 | ||
|
|
f3403d4c5b | ||
|
|
5cf78472e1 | ||
|
|
2aaff16a87 | ||
|
|
6236198d43 | ||
|
|
83fb285d40 | ||
|
|
3050f10676 | ||
|
|
175fc5096d | ||
|
|
18f238dd53 | ||
|
|
4f551259dd | ||
|
|
9cb68c6e32 | ||
|
|
a9a89c604a | ||
|
|
e96a9190a3 | ||
|
|
1ff4e9008b | ||
|
|
2d716517a8 | ||
|
|
22226a8aec | ||
|
|
9b8e56c97c | ||
|
|
ad1bfc5468 | ||
|
|
2c0c05e96d | ||
|
|
d6d63147b6 | ||
|
|
98f7771d74 | ||
|
|
37eba37019 | ||
|
|
40b2f2553b | ||
|
|
d3e35d49ae | ||
|
|
a0474685c1 | ||
|
|
0b317b72ae | ||
|
|
afe06d1563 | ||
|
|
c40365e9b6 | ||
|
|
4b6d3a2bfd | ||
|
|
7ae624e700 | ||
|
|
c32cf33a16 | ||
|
|
7eb59de7df | ||
|
|
5931cf77f4 | ||
|
|
989aace192 | ||
|
|
65cf30e441 | ||
|
|
d4480c979d | ||
|
|
169e94d68b | ||
|
|
0cc8184057 | ||
|
|
a7c75142fa | ||
|
|
02d3c452e4 | ||
|
|
1c148575ea | ||
|
|
d1a1865650 | ||
|
|
067544abc5 | ||
|
|
77da57057f | ||
|
|
aa1da57c37 | ||
|
|
c2ce2aa4de | ||
|
|
90c9fd55fc | ||
|
|
47e403640b | ||
|
|
4ea513cc38 | ||
|
|
3ca0b9bb47 | ||
|
|
e592da5a59 | ||
|
|
2c93f889fd | ||
|
|
6173ce6463 | ||
|
|
065a51d2e1 | ||
|
|
7edcc22136 | ||
|
|
352177090f | ||
|
|
9d18c0b156 | ||
|
|
ec65a9a364 | ||
|
|
5c4b6a8ef0 | ||
|
|
5d502eb90c | ||
|
|
d6662d8442 | ||
|
|
1d97f13462 | ||
|
|
2c16681225 | ||
|
|
065047dc62 | ||
|
|
eba8d6d5f5 | ||
|
|
744dceaffe | ||
|
|
8740d147c9 | ||
|
|
16ae283fb4 | ||
|
|
312600fe9c | ||
|
|
3e0c067e43 | ||
|
|
f90551ff41 | ||
|
|
9442fc0b52 | ||
|
|
dbb93a2718 | ||
|
|
242cf423f8 | ||
|
|
217faf778b | ||
|
|
01b74950b7 | ||
|
|
420bfbcf40 | ||
|
|
89f6567fda | ||
|
|
efec05d581 | ||
|
|
47198dce5d | ||
|
|
f45500c612 | ||
|
|
6f3e817372 | ||
|
|
cfda5df020 | ||
|
|
2b4f41603d | ||
|
|
448f448d14 | ||
|
|
ee6a618116 | ||
|
|
e08f81c891 | ||
|
|
9324f1c29f | ||
|
|
d71c1514f2 | ||
|
|
2df75e84e7 | ||
|
|
9ab89734de | ||
|
|
960c0319c4 | ||
|
|
439891cb9f | ||
|
|
bdfb3ef11c | ||
|
|
8d581f7fe4 | ||
|
|
262907d0a3 | ||
|
|
15be673054 | ||
|
|
16a5649670 | ||
|
|
6582895b51 | ||
|
|
e3d65389d7 | ||
|
|
027cb376f3 | ||
|
|
f1261bcdd7 | ||
|
|
2e7b36d04f | ||
|
|
ce1a58414a | ||
|
|
1012c5705a | ||
|
|
1c2947581b | ||
|
|
00883822be | ||
|
|
13fdb9d8a5 | ||
|
|
52b2bc4109 | ||
|
|
b59b3a5152 | ||
|
|
fe6c03370e | ||
|
|
e3f128875c | ||
|
|
7bf82a814b | ||
|
|
e1270928a3 | ||
|
|
6fce5b54a8 | ||
|
|
3c38eafd75 | ||
|
|
9dcc1b3370 | ||
|
|
e3c37aac28 | ||
|
|
61a967095d | ||
|
|
c0e004ec1c | ||
|
|
0a1b7296b9 | ||
|
|
cd5e6743f7 | ||
|
|
2091fe530f | ||
|
|
cda8d63d43 | ||
|
|
bef1b140e9 | ||
|
|
c9188e2260 | ||
|
|
15eaf27bc7 | ||
|
|
bf2277e263 | ||
|
|
348ffbc47e | ||
|
|
f13cbcf175 | ||
|
|
9418c56fd3 | ||
|
|
7dbd502931 | ||
|
|
0bf9c1e881 | ||
|
|
bf07d37737 | ||
|
|
eecb713616 | ||
|
|
bf085e2c4b | ||
|
|
ce1a97d6c8 | ||
|
|
34c9ec4e1a | ||
|
|
e73fb6808a | ||
|
|
1c93d9dcfe | ||
|
|
675d6ec5e6 | ||
|
|
1ad43c54c0 | ||
|
|
1cf6c15ab4 | ||
|
|
8fc17ed764 | ||
|
|
26028068e8 | ||
|
|
8519682564 | ||
|
|
5ca0c73e98 | ||
|
|
4c979aa44f | ||
|
|
274dc3ecac | ||
|
|
5e2b5edde5 | ||
|
|
b8b6521659 | ||
|
|
e37b1b0623 | ||
|
|
4a79462c3e | ||
|
|
c328cc9608 | ||
|
|
cf2d39220a | ||
|
|
7dbd649f60 | ||
|
|
4282199bb4 | ||
|
|
7071dd0162 | ||
|
|
e61a687eda | ||
|
|
7e85d2fbd4 | ||
|
|
969ab28261 | ||
|
|
90d36cc630 | ||
|
|
1bb68cbcfa | ||
|
|
de7a14003c | ||
|
|
e3ead9f585 | ||
|
|
a461b0ae44 | ||
|
|
1b28f9fa89 | ||
|
|
dff8076022 | ||
|
|
dd3c187484 | ||
|
|
4677778f85 | ||
|
|
f96204dbe0 | ||
|
|
0427b783e2 | ||
|
|
4650732f4a | ||
|
|
1e138c1401 | ||
|
|
89fb7c85bf | ||
|
|
0e51fc90e3 | ||
|
|
1b6c683ca6 | ||
|
|
501e72c3de | ||
|
|
a450efb483 | ||
|
|
0cf8d4f8e8 | ||
|
|
084447e414 | ||
|
|
4c9c9f0b89 | ||
|
|
13db2916de | ||
|
|
2d64cd55a1 | ||
|
|
60a6af7498 | ||
|
|
3cb06eb2b2 | ||
|
|
b8e73495a5 | ||
|
|
187cfc1594 | ||
|
|
90cd2a4753 | ||
|
|
f3e6a582d4 | ||
|
|
3ae470eedf | ||
|
|
6595592a71 | ||
|
|
199389c94a | ||
|
|
c31438b2f2 | ||
|
|
843f73ecaa | ||
|
|
86f043a66c | ||
|
|
80d2df7789 | ||
|
|
f882a63cba | ||
|
|
611b3584d6 | ||
|
|
a1f13dd31b | ||
|
|
966e7d0e36 | ||
|
|
44103abdb7 | ||
|
|
8f9d4b2b50 | ||
|
|
78c674a685 | ||
|
|
197830a57d | ||
|
|
3d024d5fce | ||
|
|
5763743614 | ||
|
|
54da964a99 | ||
|
|
e25cff9328 | ||
|
|
36b397be9f | ||
|
|
468019e947 | ||
|
|
7e941baa26 | ||
|
|
63270b0665 | ||
|
|
bcdbba05d3 | ||
|
|
51d1f309cd | ||
|
|
f04720afb8 | ||
|
|
e6e6c6e635 | ||
|
|
1f340a262f | ||
|
|
242a17b9e0 | ||
|
|
6e1632c606 | ||
|
|
56dab605f1 | ||
|
|
3aa3d7e629 | ||
|
|
75585f771a | ||
|
|
9a9f35039e | ||
|
|
e6f84b8cc8 | ||
|
|
72f15da2ed | ||
|
|
effbd99384 | ||
|
|
d1ba4324de | ||
|
|
c0b5d378dc | ||
|
|
b8c438f22d | ||
|
|
a85271ce0a | ||
|
|
fd5e69f769 | ||
|
|
ddb0b8d8b8 | ||
|
|
1345226bc9 | ||
|
|
fb202e9de7 | ||
|
|
5dcb5fa862 | ||
|
|
f77f2709a9 | ||
|
|
bc852bca48 | ||
|
|
9314e9e853 | ||
|
|
838ddf8f55 | ||
|
|
619869c639 | ||
|
|
31baaf72b4 | ||
|
|
c92b996942 | ||
|
|
e84c7db049 | ||
|
|
9ef7b6afe2 | ||
|
|
c5c03ac556 | ||
|
|
6ca321ca75 | ||
|
|
9c788a529b | ||
|
|
6159c356c9 | ||
|
|
ac9d92587e | ||
|
|
f32dc6b828 | ||
|
|
7a928b40f3 | ||
|
|
172501e10c | ||
|
|
317e030de0 | ||
|
|
cfda3e6a48 | ||
|
|
4d522b8f31 | ||
|
|
e93c81196f | ||
|
|
7bdd14a994 | ||
|
|
afe06b48d6 | ||
|
|
63c5ed3798 | ||
|
|
77bb536542 | ||
|
|
7c6e0d5981 | ||
|
|
a1708730c3 | ||
|
|
d33ca87e4c | ||
|
|
3c509c5f68 | ||
|
|
a840cc700a | ||
|
|
b40b989523 | ||
|
|
5eba93c4e7 | ||
|
|
915dfb494e | ||
|
|
a16cca7680 | ||
|
|
644482fc99 | ||
|
|
8c08ecfcbf | ||
|
|
b9920bdd0e | ||
|
|
bdf71e2685 | ||
|
|
bd4fd9c28c | ||
|
|
ff3e574187 | ||
|
|
4422f80ae7 | ||
|
|
cc8c2efff2 | ||
|
|
cdaca293d9 | ||
|
|
4dbc7850bd | ||
|
|
8119379d4f | ||
|
|
9b4253fe67 | ||
|
|
b5c599c80c | ||
|
|
9137e717b0 | ||
|
|
80186aa7f4 | ||
|
|
6ac739630f | ||
|
|
80a61616b1 | ||
|
|
589d2ee7b5 | ||
|
|
0a294db912 | ||
|
|
2788aa366c | ||
|
|
0f29fdaf17 | ||
|
|
2912d993c2 | ||
|
|
62ceb118ee | ||
|
|
0569c9c1be | ||
|
|
5a91746b80 | ||
|
|
fdc091a857 | ||
|
|
8469db016d | ||
|
|
f6312b16f1 | ||
|
|
c76e538231 | ||
|
|
96ea49870c | ||
|
|
6e8c73fd38 | ||
|
|
56981a2aaf | ||
|
|
ec16121fb3 | ||
|
|
7bd9988c8e | ||
|
|
068312ecb8 | ||
|
|
d36a86a12c | ||
|
|
c174b13f8b | ||
|
|
6b95c4e358 | ||
|
|
22e2ecb003 | ||
|
|
e08296f70c | ||
|
|
dd50e5bdf2 | ||
|
|
504ecd5f7a | ||
|
|
7d1bb21c19 | ||
|
|
63dc2a843f | ||
|
|
296baeb096 | ||
|
|
01dabb774a | ||
|
|
d0fe4071a9 | ||
|
|
3d491c470b | ||
|
|
06462e8a92 | ||
|
|
dbf371344b | ||
|
|
e2c6e00570 | ||
|
|
e4a0001fc6 | ||
|
|
49400b0c7f | ||
|
|
5957498c6f | ||
|
|
b6282b99cb | ||
|
|
a8483841b5 | ||
|
|
d068001102 | ||
|
|
d576be58dc | ||
|
|
1a2b88964f | ||
|
|
f7a188a642 | ||
|
|
befbf2a206 | ||
|
|
e01b7c1ede | ||
|
|
dd8d472318 | ||
|
|
256489639c | ||
|
|
e323abe5d9 | ||
|
|
afc00b08d7 | ||
|
|
af41fb79b5 | ||
|
|
535b7c5e0f | ||
|
|
217f7a7ea7 | ||
|
|
317d351423 | ||
|
|
d27519c0ca | ||
|
|
255dc45dc9 | ||
|
|
f4d8728df9 | ||
|
|
8611631f5e | ||
|
|
1e5ed4fa33 | ||
|
|
0daeab3b8d | ||
|
|
bd27401311 | ||
|
|
14df44dd3f | ||
|
|
1272621ebc | ||
|
|
0e83482e47 | ||
|
|
c0d929bed9 | ||
|
|
828a26286d | ||
|
|
082b0d822c | ||
|
|
651b4b9efa | ||
|
|
ab1e54375f | ||
|
|
70e2db51e1 | ||
|
|
0145919a9e | ||
|
|
2236a247d9 | ||
|
|
7291f50e8d | ||
|
|
bc5677a47b | ||
|
|
137ef36757 | ||
|
|
33a3753c3f | ||
|
|
9770899a4b | ||
|
|
fe8eeb5641 | ||
|
|
8cd1f1f7f9 | ||
|
|
b84876ba69 | ||
|
|
0f1ca2939a | ||
|
|
4882078469 | ||
|
|
991b120eee | ||
|
|
f278d177f9 | ||
|
|
53b2ff4b04 | ||
|
|
0c89d71aee | ||
|
|
b746bf7814 | ||
|
|
f11969015a | ||
|
|
f1b820e5fc | ||
|
|
7356ff0b18 | ||
|
|
30f7a2ff20 | ||
|
|
f6b55fae79 | ||
|
|
8aa88f4d36 | ||
|
|
ce7b565595 | ||
|
|
41fd08bb0d | ||
|
|
d0a930cd44 | ||
|
|
9bb1854398 | ||
|
|
f7400212fc | ||
|
|
6434b42481 | ||
|
|
dd0b38b32f | ||
|
|
7816db8e8a | ||
|
|
9cc6ab3922 | ||
|
|
2c27e24bb4 | ||
|
|
c382c550e7 | ||
|
|
c663494c69 | ||
|
|
97f27ea585 | ||
|
|
379bfa5a36 | ||
|
|
235c0077b8 | ||
|
|
c621546bd6 | ||
|
|
aa330b8240 | ||
|
|
e43606eb4d | ||
|
|
6a378a28b4 | ||
|
|
95368d9cb4 | ||
|
|
74f9c570ea | ||
|
|
eed4a13b3b | ||
|
|
7e9f7659b3 | ||
|
|
4d396169c8 | ||
|
|
4cd950900b | ||
|
|
2b96c3f5ce | ||
|
|
63fad159e8 | ||
|
|
e5f1480a38 | ||
|
|
020955ebc2 | ||
|
|
3733fa02ee | ||
|
|
7037e4a4b1 | ||
|
|
0e98f938c4 | ||
|
|
55d0c29f4a | ||
|
|
59997ecad5 | ||
|
|
6e2f0833ad | ||
|
|
25f626cc52 | ||
|
|
ece891d6db | ||
|
|
702355da47 | ||
|
|
c4fba310d2 | ||
|
|
e9dd099870 | ||
|
|
070d89a561 | ||
|
|
28cc9dd331 | ||
|
|
7c1fecc94a | ||
|
|
7a9fab52be | ||
|
|
8cb8371011 | ||
|
|
875c55d86b | ||
|
|
b85154f13f | ||
|
|
06047d9103 | ||
|
|
2362637e90 | ||
|
|
edd02607e2 | ||
|
|
0211e420ed | ||
|
|
9a184e0bb1 | ||
|
|
168fb3a8d8 | ||
|
|
4c5307b456 | ||
|
|
626f9bd8c2 | ||
|
|
a06b36dee0 | ||
|
|
18e1bee8d5 | ||
|
|
41f76801eb | ||
|
|
31a7bfc47f | ||
|
|
1b6d18fcb0 | ||
|
|
57c32b709d | ||
|
|
5f19822e37 | ||
|
|
9a0c9cd6e1 | ||
|
|
0ac8e1d80b | ||
|
|
744e55ec74 | ||
|
|
74ba4d7950 | ||
|
|
fa96436661 | ||
|
|
d15b8273d6 | ||
|
|
0a5cf3a928 | ||
|
|
6173e38fdc | ||
|
|
34cd99d1d9 | ||
|
|
0922a0fc3f | ||
|
|
dd53b356ff | ||
|
|
f1db505778 | ||
|
|
662727ca3e | ||
|
|
bdec6f2b20 | ||
|
|
c86c294f55 | ||
|
|
a9a03b9708 | ||
|
|
f4e8c406bb | ||
|
|
12bfcb501c | ||
|
|
0fc1782dd4 | ||
|
|
9274d31690 | ||
|
|
983a539503 | ||
|
|
94bb7fe5cb | ||
|
|
b98e0aa09b | ||
|
|
49c6d7e32d | ||
|
|
ee73fc361b | ||
|
|
e84dbd28db | ||
|
|
02449d9aa5 | ||
|
|
2876329f16 | ||
|
|
a1f455551f |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.dsw -crlf
|
||||||
39
.cvsignore → .gitignore
vendored
39
.cvsignore → .gitignore
vendored
@@ -1,17 +1,38 @@
|
|||||||
compile
|
.deps
|
||||||
config.log
|
.libs
|
||||||
|
*.lib
|
||||||
|
*.pdb
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*.obj
|
||||||
|
.*.swp
|
||||||
|
Debug
|
||||||
|
Release
|
||||||
|
*.exp
|
||||||
Makefile
|
Makefile
|
||||||
libtool
|
|
||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
aclocal.m4.bak
|
|
||||||
configure
|
|
||||||
config.h
|
|
||||||
config.status
|
|
||||||
curl-config
|
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
depcomp
|
|
||||||
config.guess
|
config.guess
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
config.sub
|
config.sub
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
libtool
|
||||||
ltmain.sh
|
ltmain.sh
|
||||||
|
compile
|
||||||
|
curl-config
|
||||||
libcurl.pc
|
libcurl.pc
|
||||||
|
missing
|
||||||
|
curl-*.tar.gz
|
||||||
|
INSTALL
|
||||||
|
install-sh
|
||||||
|
*.o
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
mkinstalldirs
|
||||||
|
tags
|
||||||
|
TAGS
|
||||||
|
*~
|
||||||
|
aclocal.m4.bak
|
||||||
87
Android.mk
Normal file
87
Android.mk
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# Google Android makefile for curl and libcurl
|
||||||
|
#
|
||||||
|
# Place the curl source (including this makefile) into external/curl/ in the
|
||||||
|
# Android source tree. Then build them with 'make curl' or just 'make libcurl'
|
||||||
|
# from the Android root. Tested with Android 1.5
|
||||||
|
#
|
||||||
|
# Note: you must first create a curl_config.h file by running configure in the
|
||||||
|
# Android environment. The only way I've found to do this is tricky. Perform a
|
||||||
|
# normal Android build with libcurl in the source tree, providing the target
|
||||||
|
# "showcommands" to make. The build will eventually fail (because curl_config.h
|
||||||
|
# doesn't exist yet), but the compiler commands used to build curl will be
|
||||||
|
# shown. Now, from the external/curl/ directory, run curl's normal configure
|
||||||
|
# command with flags that match what Android itself uses. This will mean
|
||||||
|
# putting the compiler directory into the PATH, putting the -I, -isystem and
|
||||||
|
# -D options into CPPFLAGS, putting the -m, -f, -O and -nostdlib options into
|
||||||
|
# CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the path
|
||||||
|
# to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o. Remember
|
||||||
|
# that the paths must be absolute since you will not be running configure from
|
||||||
|
# the same directory as the Android make. The normal cross-compiler options
|
||||||
|
# must also be set.
|
||||||
|
#
|
||||||
|
# The end result will be a configure command that looks something like this
|
||||||
|
# (the environment variable A is set to the Android root path):
|
||||||
|
#
|
||||||
|
# A=`realpath ../..` && \
|
||||||
|
# PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
|
||||||
|
# ./configure --host=arm-linux CC=arm-eabi-gcc \
|
||||||
|
# CPPFLAGS="-I $A/system/core/include ..." \
|
||||||
|
# CFLAGS="-fno-exceptions -Wno-multichar ..." \
|
||||||
|
# LIB="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
|
||||||
|
# /interwork/libgcc.a ..." \
|
||||||
|
#
|
||||||
|
# Dan Fandrich
|
||||||
|
# September 2009
|
||||||
|
|
||||||
|
LOCAL_PATH:= $(call my-dir)
|
||||||
|
|
||||||
|
common_CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers -DHAVE_CONFIG_H
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Build the libcurl library
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
include $(LOCAL_PATH)/lib/Makefile.inc
|
||||||
|
CURL_HEADERS := \
|
||||||
|
curlbuild.h \
|
||||||
|
curl.h \
|
||||||
|
curlrules.h \
|
||||||
|
curlver.h \
|
||||||
|
easy.h \
|
||||||
|
mprintf.h \
|
||||||
|
multi.h \
|
||||||
|
stdcheaders.h \
|
||||||
|
typecheck-gcc.h \
|
||||||
|
types.h
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/
|
||||||
|
LOCAL_CFLAGS += $(common_CFLAGS)
|
||||||
|
|
||||||
|
LOCAL_COPY_HEADERS_TO := libcurl/curl
|
||||||
|
LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
|
||||||
|
|
||||||
|
LOCAL_MODULE:= libcurl
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Build the curl binary
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
include $(LOCAL_PATH)/src/Makefile.inc
|
||||||
|
LOCAL_SRC_FILES := $(addprefix src/,$(CURL_SOURCES))
|
||||||
|
|
||||||
|
LOCAL_MODULE := curl
|
||||||
|
LOCAL_STATIC_LIBRARIES := libcurl
|
||||||
|
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/lib
|
||||||
|
|
||||||
|
# This will also need to include $(CURLX_ONES) in order to correctly build
|
||||||
|
# a dynamic library
|
||||||
|
LOCAL_CFLAGS += $(common_CFLAGS)
|
||||||
|
|
||||||
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
||||||
2
CMake/CMakeConfigurableFile.in
Normal file
2
CMake/CMakeConfigurableFile.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@CMAKE_CONFIGURABLE_FILE_CONTENT@
|
||||||
|
|
||||||
44
CMake/CheckTypeSize.c.in
Normal file
44
CMake/CheckTypeSize.c.in
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#cmakedefine CHECK_TYPE_SIZE_TYPE @CHECK_TYPE_SIZE_TYPE@
|
||||||
|
#ifdef CHECK_TYPE_SIZE_TYPE
|
||||||
|
|
||||||
|
@CHECK_TYPE_SIZE_PREINCLUDE@
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif /* HAVE_SYS_TYPES_H */
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
# include <stdint.h>
|
||||||
|
#endif /* HAVE_STDINT_H */
|
||||||
|
|
||||||
|
#ifdef HAVE_STDDEF_H
|
||||||
|
# include <stddef.h>
|
||||||
|
#endif /* HAVE_STDDEF_H */
|
||||||
|
|
||||||
|
@CHECK_TYPE_SIZE_PREMAIN@
|
||||||
|
|
||||||
|
#ifdef __CLASSIC_C__
|
||||||
|
int main(){
|
||||||
|
int ac;
|
||||||
|
char*av[];
|
||||||
|
#else
|
||||||
|
int main(int ac, char*av[]){
|
||||||
|
#endif
|
||||||
|
if(ac > 1000){return *av[0];}
|
||||||
|
return sizeof(CHECK_TYPE_SIZE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* CHECK_TYPE_SIZE_TYPE */
|
||||||
|
|
||||||
|
# error "CHECK_TYPE_SIZE_TYPE has to specify the type"
|
||||||
|
|
||||||
|
#endif /* CHECK_TYPE_SIZE_TYPE */
|
||||||
57
CMake/CheckTypeSize.cmake
Normal file
57
CMake/CheckTypeSize.cmake
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# - Check sizeof a type
|
||||||
|
# CHECK_TYPE_SIZE(TYPE VARIABLE)
|
||||||
|
# Check if the type exists and determine size of type. if the type
|
||||||
|
# exists, the size will be stored to the variable.
|
||||||
|
#
|
||||||
|
# VARIABLE - variable to store size if the type exists.
|
||||||
|
# HAVE_${VARIABLE} - does the variable exists or not
|
||||||
|
|
||||||
|
macro(CHECK_TYPE_SIZE TYPE VARIABLE)
|
||||||
|
set(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
|
||||||
|
if(NOT DEFINED ${VARIABLE})
|
||||||
|
if("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
|
||||||
|
set(CHECK_TYPE_SIZE_TYPE "${TYPE}")
|
||||||
|
set(MACRO_CHECK_TYPE_SIZE_FLAGS
|
||||||
|
"${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
foreach(def HAVE_SYS_TYPES_H
|
||||||
|
HAVE_STDINT_H HAVE_STDDEF_H HAVE_SYS_SOCKET_H)
|
||||||
|
if("${def}")
|
||||||
|
set(MACRO_CHECK_TYPE_SIZE_FLAGS
|
||||||
|
"${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}")
|
||||||
|
endif("${def}")
|
||||||
|
endforeach(def)
|
||||||
|
set(CHECK_TYPE_SIZE_PREMAIN)
|
||||||
|
foreach(def ${CMAKE_EXTRA_INCLUDE_FILES})
|
||||||
|
set(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n")
|
||||||
|
endforeach(def)
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/CheckTypeSize.c.in"
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c"
|
||||||
|
IMMEDIATE @ONLY)
|
||||||
|
file(READ
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c"
|
||||||
|
CHECK_TYPE_SIZE_FILE_CONTENT)
|
||||||
|
message(STATUS "Check size of ${TYPE}")
|
||||||
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CHECK_TYPE_SIZE_ADD_LIBRARIES
|
||||||
|
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
try_run(${VARIABLE} HAVE_${VARIABLE}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckTypeSize.c"
|
||||||
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS}
|
||||||
|
"${CHECK_TYPE_SIZE_ADD_LIBRARIES}"
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
if(HAVE_${VARIABLE})
|
||||||
|
message(STATUS "Check size of ${TYPE} - done")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
"Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n")
|
||||||
|
else(HAVE_${VARIABLE})
|
||||||
|
message(STATUS "Check size of ${TYPE} - failed")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSize.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n")
|
||||||
|
endif(HAVE_${VARIABLE})
|
||||||
|
endif("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
|
||||||
|
endif(NOT DEFINED ${VARIABLE})
|
||||||
|
set(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS )
|
||||||
|
endmacro(CHECK_TYPE_SIZE)
|
||||||
75
CMake/CurlCheckCSourceCompiles.cmake
Normal file
75
CMake/CurlCheckCSourceCompiles.cmake
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# - Check if the source code provided in the SOURCE argument compiles.
|
||||||
|
# CURL_CHECK_C_SOURCE_COMPILES(SOURCE VAR)
|
||||||
|
# - macro which checks if the source code compiles
|
||||||
|
# SOURCE - source code to try to compile
|
||||||
|
# VAR - variable to store whether the source code compiled
|
||||||
|
#
|
||||||
|
# The following variables may be set before calling this macro to
|
||||||
|
# modify the way the check is run:
|
||||||
|
#
|
||||||
|
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||||
|
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||||
|
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||||
|
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||||
|
|
||||||
|
macro(CURL_CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||||
|
if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN")
|
||||||
|
set(message "${VAR}")
|
||||||
|
# If the number of arguments is greater than 2 (SOURCE VAR)
|
||||||
|
if(${ARGC} GREATER 2)
|
||||||
|
# then add the third argument as a message
|
||||||
|
set(message "${ARGV2} (${VAR})")
|
||||||
|
endif(${ARGC} GREATER 2)
|
||||||
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
|
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
else(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
|
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
if(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||||
|
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||||
|
else(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||||
|
endif(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(src "")
|
||||||
|
foreach(def ${EXTRA_DEFINES})
|
||||||
|
set(src "${src}#define ${def} 1\n")
|
||||||
|
endforeach(def)
|
||||||
|
foreach(inc ${HEADER_INCLUDES})
|
||||||
|
set(src "${src}#include <${inc}>\n")
|
||||||
|
endforeach(inc)
|
||||||
|
|
||||||
|
set(src "${src}\nint main() { ${SOURCE} ; return 0; }")
|
||||||
|
set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}")
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
|
||||||
|
IMMEDIATE)
|
||||||
|
message(STATUS "Performing Test ${message}")
|
||||||
|
try_compile(${VAR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||||
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
|
"${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
||||||
|
"${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
if(${VAR})
|
||||||
|
set(${VAR} 1 CACHE INTERNAL "Test ${message}")
|
||||||
|
message(STATUS "Performing Test ${message} - Success")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
"Performing C SOURCE FILE Test ${message} succeded with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Source file was:\n${src}\n")
|
||||||
|
else(${VAR})
|
||||||
|
message(STATUS "Performing Test ${message} - Failed")
|
||||||
|
set(${VAR} "" CACHE INTERNAL "Test ${message}")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Performing C SOURCE FILE Test ${message} failed with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Source file was:\n${src}\n")
|
||||||
|
endif(${VAR})
|
||||||
|
endif("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN")
|
||||||
|
endmacro(CURL_CHECK_C_SOURCE_COMPILES)
|
||||||
83
CMake/CurlCheckCSourceRuns.cmake
Normal file
83
CMake/CurlCheckCSourceRuns.cmake
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# - Check if the source code provided in the SOURCE argument compiles and runs.
|
||||||
|
# CURL_CHECK_C_SOURCE_RUNS(SOURCE VAR)
|
||||||
|
# - macro which checks if the source code runs
|
||||||
|
# SOURCE - source code to try to compile
|
||||||
|
# VAR - variable to store size if the type exists.
|
||||||
|
#
|
||||||
|
# The following variables may be set before calling this macro to
|
||||||
|
# modify the way the check is run:
|
||||||
|
#
|
||||||
|
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||||
|
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||||
|
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||||
|
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||||
|
|
||||||
|
macro(CURL_CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||||
|
if("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN")
|
||||||
|
set(message "${VAR}")
|
||||||
|
# If the number of arguments is greater than 2 (SOURCE VAR)
|
||||||
|
if(${ARGC} GREATER 2)
|
||||||
|
# then add the third argument as a message
|
||||||
|
set(message "${ARGV2} (${VAR})")
|
||||||
|
endif(${ARGC} GREATER 2)
|
||||||
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
|
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
else(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
|
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
if(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||||
|
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||||
|
else(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||||
|
endif(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
set(src "")
|
||||||
|
foreach(def ${EXTRA_DEFINES})
|
||||||
|
set(src "${src}#define ${def} 1\n")
|
||||||
|
endforeach(def)
|
||||||
|
foreach(inc ${HEADER_INCLUDES})
|
||||||
|
set(src "${src}#include <${inc}>\n")
|
||||||
|
endforeach(inc)
|
||||||
|
|
||||||
|
set(src "${src}\nint main() { ${SOURCE} ; return 0; }")
|
||||||
|
set(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}")
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
|
||||||
|
IMMEDIATE)
|
||||||
|
message(STATUS "Performing Test ${message}")
|
||||||
|
try_run(${VAR} ${VAR}_COMPILED
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||||
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
|
"${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
||||||
|
"${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
# if it did not compile make the return value fail code of 1
|
||||||
|
if(NOT ${VAR}_COMPILED)
|
||||||
|
set(${VAR} 1)
|
||||||
|
endif(NOT ${VAR}_COMPILED)
|
||||||
|
# if the return value was 0 then it worked
|
||||||
|
set(result_var ${${VAR}})
|
||||||
|
if("${result_var}" EQUAL 0)
|
||||||
|
set(${VAR} 1 CACHE INTERNAL "Test ${message}")
|
||||||
|
message(STATUS "Performing Test ${message} - Success")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
"Performing C SOURCE FILE Test ${message} succeded with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Return value: ${${VAR}}\n"
|
||||||
|
"Source file was:\n${src}\n")
|
||||||
|
else("${result_var}" EQUAL 0)
|
||||||
|
message(STATUS "Performing Test ${message} - Failed")
|
||||||
|
set(${VAR} "" CACHE INTERNAL "Test ${message}")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Performing C SOURCE FILE Test ${message} failed with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Return value: ${result_var}\n"
|
||||||
|
"Source file was:\n${src}\n")
|
||||||
|
endif("${result_var}" EQUAL 0)
|
||||||
|
endif("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN")
|
||||||
|
endmacro(CURL_CHECK_C_SOURCE_RUNS)
|
||||||
690
CMake/CurlTests.c
Normal file
690
CMake/CurlTests.c
Normal file
@@ -0,0 +1,690 @@
|
|||||||
|
#ifdef TIME_WITH_SYS_TIME
|
||||||
|
/* Time with sys/time test */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if ((struct tm *) 0)
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL_O_NONBLOCK
|
||||||
|
|
||||||
|
/* headers for FCNTL_O_NONBLOCK test */
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
/* */
|
||||||
|
#if defined(sun) || defined(__sun__) || \
|
||||||
|
defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||||
|
# if defined(__SVR4) || defined(__srv4__)
|
||||||
|
# define PLATFORM_SOLARIS
|
||||||
|
# else
|
||||||
|
# define PLATFORM_SUNOS4
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
|
||||||
|
# define PLATFORM_AIX_V3
|
||||||
|
#endif
|
||||||
|
/* */
|
||||||
|
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
|
||||||
|
#error "O_NONBLOCK does not work on this platform"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
/* O_NONBLOCK source test */
|
||||||
|
int flags = 0;
|
||||||
|
if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_5
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
struct hostent_data hdata;
|
||||||
|
int rc;
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
rc = gethostbyaddr_r(address, length, type, &h, &hdata);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;q
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
struct hostent_data hdata;
|
||||||
|
int rc;
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
rc = gethostbyaddr_r(address, length, type, &h, &hdata);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_7
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
char buffer[8192];
|
||||||
|
int h_errnop;
|
||||||
|
struct hostent * hp;
|
||||||
|
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
hp = gethostbyaddr_r(address, length, type, &h,
|
||||||
|
buffer, 8192, &h_errnop);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
char buffer[8192];
|
||||||
|
int h_errnop;
|
||||||
|
struct hostent * hp;
|
||||||
|
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
hp = gethostbyaddr_r(address, length, type, &h,
|
||||||
|
buffer, 8192, &h_errnop);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_8
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
char buffer[8192];
|
||||||
|
int h_errnop;
|
||||||
|
struct hostent * hp;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
rc = gethostbyaddr_r(address, length, type, &h,
|
||||||
|
buffer, 8192, &hp, &h_errnop);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
char * address;
|
||||||
|
int length;
|
||||||
|
int type;
|
||||||
|
struct hostent h;
|
||||||
|
char buffer[8192];
|
||||||
|
int h_errnop;
|
||||||
|
struct hostent * hp;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
#ifndef gethostbyaddr_r
|
||||||
|
(void)gethostbyaddr_r;
|
||||||
|
#endif
|
||||||
|
rc = gethostbyaddr_r(address, length, type, &h,
|
||||||
|
buffer, 8192, &hp, &h_errnop);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_3
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
struct hostent_data data;
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
struct hostent_data data;
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_5
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL, 0, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL, 0, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_6
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#undef NULL
|
||||||
|
#define NULL (void *)0
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifndef gethostbyname_r
|
||||||
|
(void)gethostbyname_r;
|
||||||
|
#endif
|
||||||
|
gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SOCKLEN_T
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if ((socklen_t *) 0)
|
||||||
|
return 0;
|
||||||
|
if (sizeof (socklen_t))
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IN_ADDR_T
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if ((in_addr_t *) 0)
|
||||||
|
return 0;
|
||||||
|
if (sizeof (in_addr_t))
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BOOL_T
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDBOOL_H
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if (sizeof (bool *) )
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <float.h>
|
||||||
|
int main() { return 0; }
|
||||||
|
#endif
|
||||||
|
#ifdef RETSIGTYPE_TEST
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#ifdef signal
|
||||||
|
# undef signal
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" void (*signal (int, void (*)(int)))(int);
|
||||||
|
#else
|
||||||
|
void (*signal ()) ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_INET_NTOA_R_DECL
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
typedef void (*func_type)();
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#ifndef inet_ntoa_r
|
||||||
|
func_type func;
|
||||||
|
func = (func_type)inet_ntoa_r;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_INET_NTOA_R_DECL_REENTRANT
|
||||||
|
#define _REENTRANT
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
typedef void (*func_type)();
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#ifndef inet_ntoa_r
|
||||||
|
func_type func;
|
||||||
|
func = (func_type)&inet_ntoa_r;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETADDRINFO
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
struct addrinfo hints, *ai;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
#ifndef getaddrinfo
|
||||||
|
(void)getaddrinfo;
|
||||||
|
#endif
|
||||||
|
error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
|
||||||
|
if (error) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_FILE_OFFSET_BITS
|
||||||
|
#ifdef _FILE_OFFSET_BITS
|
||||||
|
#undef _FILE_OFFSET_BITS
|
||||||
|
#endif
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#include <sys/types.h>
|
||||||
|
/* Check that off_t can represent 2**63 - 1 correctly.
|
||||||
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
|
since some C++ compilers masquerading as C compilers
|
||||||
|
incorrectly reject 9223372036854775807. */
|
||||||
|
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||||
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
|
? 1 : -1];
|
||||||
|
int main () { ; return 0; }
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTLSOCKET
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_WINSOCK_H
|
||||||
|
# include <winsock.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* ioctlsocket source code */
|
||||||
|
int socket;
|
||||||
|
unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTLSOCKET_CAMEL
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_WINSOCK_H
|
||||||
|
# include <winsock.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* IoctlSocket source code */
|
||||||
|
if(0 != IoctlSocket(0, 0, 0))
|
||||||
|
return 1;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_WINSOCK_H
|
||||||
|
# include <winsock.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* IoctlSocket source code */
|
||||||
|
long flags = 0;
|
||||||
|
if(0 != ioctlsocket(0, FIONBIO, &flags))
|
||||||
|
return 1;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTLSOCKET_FIONBIO
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_WINSOCK_H
|
||||||
|
# include <winsock.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
int flags = 0;
|
||||||
|
if(0 != ioctlsocket(0, FIONBIO, &flags))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTL_FIONBIO
|
||||||
|
/* headers for FIONBIO test */
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STROPTS_H
|
||||||
|
# include <stropts.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
int flags = 0;
|
||||||
|
if(0 != ioctl(0, FIONBIO, &flags))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_IOCTL_SIOCGIFADDR
|
||||||
|
/* headers for FIONBIO test */
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STROPTS_H
|
||||||
|
# include <stropts.h>
|
||||||
|
#endif
|
||||||
|
#include <net/if.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
if(0 != ioctl(0, SIOCGIFADDR, &ifr))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef HAVE_WINSOCK2_H
|
||||||
|
# include <winsock2.h>
|
||||||
|
# else
|
||||||
|
# ifdef HAVE_WINSOCK_H
|
||||||
|
# include <winsock.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
/* includes start */
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
/* includes end */
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
|
||||||
|
return 1;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GLIBC_STRERROR_R
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
int
|
||||||
|
main () {
|
||||||
|
char buffer[1024]; /* big enough to play with */
|
||||||
|
char *string =
|
||||||
|
strerror_r(EACCES, buffer, sizeof(buffer));
|
||||||
|
/* this should've returned a string */
|
||||||
|
if(!string || !string[0])
|
||||||
|
return 99;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_POSIX_STRERROR_R
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
int
|
||||||
|
main () {
|
||||||
|
char buffer[1024]; /* big enough to play with */
|
||||||
|
int error =
|
||||||
|
strerror_r(EACCES, buffer, sizeof(buffer));
|
||||||
|
/* This should've returned zero, and written an error string in the
|
||||||
|
buffer.*/
|
||||||
|
if(!buffer[0] || error)
|
||||||
|
return 99;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
42
CMake/FindCARES.cmake
Executable file
42
CMake/FindCARES.cmake
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
# - Find c-ares
|
||||||
|
# Find the c-ares includes and library
|
||||||
|
# This module defines
|
||||||
|
# CARES_INCLUDE_DIR, where to find ares.h, etc.
|
||||||
|
# CARES_LIBRARIES, the libraries needed to use c-ares.
|
||||||
|
# CARES_FOUND, If false, do not try to use c-ares.
|
||||||
|
# also defined, but not for general use are
|
||||||
|
# CARES_LIBRARY, where to find the c-ares library.
|
||||||
|
|
||||||
|
FIND_PATH(CARES_INCLUDE_DIR ares.h
|
||||||
|
/usr/local/include
|
||||||
|
/usr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(CARES_NAMES ${CARES_NAMES} cares)
|
||||||
|
FIND_LIBRARY(CARES_LIBRARY
|
||||||
|
NAMES ${CARES_NAMES}
|
||||||
|
PATHS /usr/lib /usr/local/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
|
||||||
|
SET(CARES_LIBRARIES ${CARES_LIBRARY})
|
||||||
|
SET(CARES_FOUND "YES")
|
||||||
|
ELSE (CARES_LIBRARY AND CARES_INCLUDE_DIR)
|
||||||
|
SET(CARES_FOUND "NO")
|
||||||
|
ENDIF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
IF (CARES_FOUND)
|
||||||
|
IF (NOT CARES_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found c-ares: ${CARES_LIBRARIES}")
|
||||||
|
ENDIF (NOT CARES_FIND_QUIETLY)
|
||||||
|
ELSE (CARES_FOUND)
|
||||||
|
IF (CARES_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find c-ares library")
|
||||||
|
ENDIF (CARES_FIND_REQUIRED)
|
||||||
|
ENDIF (CARES_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
CARES_LIBRARY
|
||||||
|
CARES_INCLUDE_DIR
|
||||||
|
)
|
||||||
19
CMake/FindOpenSSL.cmake
Normal file
19
CMake/FindOpenSSL.cmake
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Extension of the standard FindOpenSSL.cmake
|
||||||
|
# Adds OPENSSL_INCLUDE_DIRS and libeay32
|
||||||
|
include("${CMAKE_ROOT}/Modules/FindOpenSSL.cmake")
|
||||||
|
|
||||||
|
# Bill Hoffman told that libeay32 is necessary for him:
|
||||||
|
find_library(SSL_LIBEAY NAMES libeay32)
|
||||||
|
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
if(SSL_LIBEAY)
|
||||||
|
list(APPEND OPENSSL_LIBRARIES ${SSL_LIBEAY})
|
||||||
|
else()
|
||||||
|
set(OPENSSL_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
8
CMake/FindZLIB.cmake
Normal file
8
CMake/FindZLIB.cmake
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Locate zlib
|
||||||
|
include("${CMAKE_ROOT}/Modules/FindZLIB.cmake")
|
||||||
|
|
||||||
|
find_library(ZLIB_LIBRARY_DEBUG NAMES zd zlibd zdlld zlib1d )
|
||||||
|
|
||||||
|
if(ZLIB_FOUND AND ZLIB_LIBRARY_DEBUG)
|
||||||
|
set( ZLIB_LIBRARIES optimized "${ZLIB_LIBRARY}" debug ${ZLIB_LIBRARY_DEBUG})
|
||||||
|
endif()
|
||||||
250
CMake/OtherTests.cmake
Normal file
250
CMake/OtherTests.cmake
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
include(CurlCheckCSourceCompiles)
|
||||||
|
set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2")
|
||||||
|
set(HEADER_INCLUDES)
|
||||||
|
set(headers_hack)
|
||||||
|
|
||||||
|
macro(add_header_include check header)
|
||||||
|
if(${check})
|
||||||
|
set(headers_hack
|
||||||
|
"${headers_hack}\n#include <${header}>")
|
||||||
|
#SET(HEADER_INCLUDES
|
||||||
|
# ${HEADER_INCLUDES}
|
||||||
|
# "${header}")
|
||||||
|
endif(${check})
|
||||||
|
endmacro(add_header_include)
|
||||||
|
|
||||||
|
set(signature_call_conv)
|
||||||
|
if(HAVE_WINDOWS_H)
|
||||||
|
add_header_include(HAVE_WINDOWS_H "windows.h")
|
||||||
|
add_header_include(HAVE_WINSOCK2_H "winsock2.h")
|
||||||
|
add_header_include(HAVE_WINSOCK_H "winsock.h")
|
||||||
|
set(EXTRA_DEFINES ${EXTRA_DEFINES}
|
||||||
|
"__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3")
|
||||||
|
set(signature_call_conv "PASCAL")
|
||||||
|
else(HAVE_WINDOWS_H)
|
||||||
|
add_header_include(HAVE_SYS_TYPES_H "sys/types.h")
|
||||||
|
add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
|
||||||
|
endif(HAVE_WINDOWS_H)
|
||||||
|
|
||||||
|
set(EXTRA_DEFINES_BACKUP "${EXTRA_DEFINES}")
|
||||||
|
set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5")
|
||||||
|
curl_check_c_source_compiles("recv(0, 0, 0, 0)" curl_cv_recv)
|
||||||
|
if(curl_cv_recv)
|
||||||
|
# AC_CACHE_CHECK([types of arguments and return type for recv],
|
||||||
|
#[curl_cv_func_recv_args], [
|
||||||
|
#SET(curl_cv_func_recv_args "unknown")
|
||||||
|
#for recv_retv in 'int' 'ssize_t'; do
|
||||||
|
if(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown")
|
||||||
|
foreach(recv_retv "int" "ssize_t" )
|
||||||
|
foreach(recv_arg1 "int" "ssize_t" "SOCKET")
|
||||||
|
foreach(recv_arg2 "void *" "char *")
|
||||||
|
foreach(recv_arg3 "size_t" "int" "socklen_t" "unsigned int")
|
||||||
|
foreach(recv_arg4 "int" "unsigned int")
|
||||||
|
if(NOT curl_cv_func_recv_done)
|
||||||
|
set(curl_cv_func_recv_test "UNKNOWN")
|
||||||
|
set(extern_line "extern ${recv_retv} ${signature_call_conv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})\;")
|
||||||
|
set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5")
|
||||||
|
curl_check_c_source_compiles("
|
||||||
|
${recv_arg1} s=0;
|
||||||
|
${recv_arg2} buf=0;
|
||||||
|
${recv_arg3} len=0;
|
||||||
|
${recv_arg4} flags=0;
|
||||||
|
${recv_retv} res = recv(s, buf, len, flags)"
|
||||||
|
curl_cv_func_recv_test
|
||||||
|
"${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})")
|
||||||
|
if(curl_cv_func_recv_test)
|
||||||
|
set(curl_cv_func_recv_args
|
||||||
|
"${recv_arg1},${recv_arg2},${recv_arg3},${recv_arg4},${recv_retv}")
|
||||||
|
set(RECV_TYPE_ARG1 "${recv_arg1}")
|
||||||
|
set(RECV_TYPE_ARG2 "${recv_arg2}")
|
||||||
|
set(RECV_TYPE_ARG3 "${recv_arg3}")
|
||||||
|
set(RECV_TYPE_ARG4 "${recv_arg4}")
|
||||||
|
set(RECV_TYPE_RETV "${recv_retv}")
|
||||||
|
set(HAVE_RECV 1)
|
||||||
|
set(curl_cv_func_recv_done 1)
|
||||||
|
endif(curl_cv_func_recv_test)
|
||||||
|
endif(NOT curl_cv_func_recv_done)
|
||||||
|
endforeach(recv_arg4)
|
||||||
|
endforeach(recv_arg3)
|
||||||
|
endforeach(recv_arg2)
|
||||||
|
endforeach(recv_arg1)
|
||||||
|
endforeach(recv_retv)
|
||||||
|
else(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown")
|
||||||
|
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG3 "${curl_cv_func_recv_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" RECV_TYPE_ARG4 "${curl_cv_func_recv_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" RECV_TYPE_RETV "${curl_cv_func_recv_args}")
|
||||||
|
#MESSAGE("RECV_TYPE_ARG1 ${RECV_TYPE_ARG1}")
|
||||||
|
#MESSAGE("RECV_TYPE_ARG2 ${RECV_TYPE_ARG2}")
|
||||||
|
#MESSAGE("RECV_TYPE_ARG3 ${RECV_TYPE_ARG3}")
|
||||||
|
#MESSAGE("RECV_TYPE_ARG4 ${RECV_TYPE_ARG4}")
|
||||||
|
#MESSAGE("RECV_TYPE_RETV ${RECV_TYPE_RETV}")
|
||||||
|
endif(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown")
|
||||||
|
|
||||||
|
if("${curl_cv_func_recv_args}" STREQUAL "unknown")
|
||||||
|
message(FATAL_ERROR "Cannot find proper types to use for recv args")
|
||||||
|
endif("${curl_cv_func_recv_args}" STREQUAL "unknown")
|
||||||
|
else(curl_cv_recv)
|
||||||
|
message(FATAL_ERROR "Unable to link function recv")
|
||||||
|
endif(curl_cv_recv)
|
||||||
|
set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv")
|
||||||
|
set(HAVE_RECV 1)
|
||||||
|
|
||||||
|
curl_check_c_source_compiles("send(0, 0, 0, 0)" curl_cv_send)
|
||||||
|
if(curl_cv_send)
|
||||||
|
# AC_CACHE_CHECK([types of arguments and return type for send],
|
||||||
|
#[curl_cv_func_send_args], [
|
||||||
|
#SET(curl_cv_func_send_args "unknown")
|
||||||
|
#for send_retv in 'int' 'ssize_t'; do
|
||||||
|
if(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||||
|
foreach(send_retv "int" "ssize_t" )
|
||||||
|
foreach(send_arg1 "int" "ssize_t" "SOCKET")
|
||||||
|
foreach(send_arg2 "const void *" "void *" "char *" "const char *")
|
||||||
|
foreach(send_arg3 "size_t" "int" "socklen_t" "unsigned int")
|
||||||
|
foreach(send_arg4 "int" "unsigned int")
|
||||||
|
if(NOT curl_cv_func_send_done)
|
||||||
|
set(curl_cv_func_send_test "UNKNOWN")
|
||||||
|
set(extern_line "extern ${send_retv} ${signature_call_conv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})\;")
|
||||||
|
set(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5")
|
||||||
|
curl_check_c_source_compiles("
|
||||||
|
${send_arg1} s=0;
|
||||||
|
${send_arg2} buf=0;
|
||||||
|
${send_arg3} len=0;
|
||||||
|
${send_arg4} flags=0;
|
||||||
|
${send_retv} res = send(s, buf, len, flags)"
|
||||||
|
curl_cv_func_send_test
|
||||||
|
"${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})")
|
||||||
|
if(curl_cv_func_send_test)
|
||||||
|
#MESSAGE("Found arguments: ${curl_cv_func_send_test}")
|
||||||
|
string(REGEX REPLACE "(const) .*" "\\1" send_qual_arg2 "${send_arg2}")
|
||||||
|
string(REGEX REPLACE "const (.*)" "\\1" send_arg2 "${send_arg2}")
|
||||||
|
set(curl_cv_func_send_args
|
||||||
|
"${send_arg1},${send_arg2},${send_arg3},${send_arg4},${send_retv},${send_qual_arg2}")
|
||||||
|
set(SEND_TYPE_ARG1 "${send_arg1}")
|
||||||
|
set(SEND_TYPE_ARG2 "${send_arg2}")
|
||||||
|
set(SEND_TYPE_ARG3 "${send_arg3}")
|
||||||
|
set(SEND_TYPE_ARG4 "${send_arg4}")
|
||||||
|
set(SEND_TYPE_RETV "${send_retv}")
|
||||||
|
set(HAVE_SEND 1)
|
||||||
|
set(curl_cv_func_send_done 1)
|
||||||
|
endif(curl_cv_func_send_test)
|
||||||
|
endif(NOT curl_cv_func_send_done)
|
||||||
|
endforeach(send_arg4)
|
||||||
|
endforeach(send_arg3)
|
||||||
|
endforeach(send_arg2)
|
||||||
|
endforeach(send_arg1)
|
||||||
|
endforeach(send_retv)
|
||||||
|
else(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||||
|
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG3 "${curl_cv_func_send_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG4 "${curl_cv_func_send_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" SEND_TYPE_RETV "${curl_cv_func_send_args}")
|
||||||
|
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" SEND_QUAL_ARG2 "${curl_cv_func_send_args}")
|
||||||
|
#MESSAGE("SEND_TYPE_ARG1 ${SEND_TYPE_ARG1}")
|
||||||
|
#MESSAGE("SEND_TYPE_ARG2 ${SEND_TYPE_ARG2}")
|
||||||
|
#MESSAGE("SEND_TYPE_ARG3 ${SEND_TYPE_ARG3}")
|
||||||
|
#MESSAGE("SEND_TYPE_ARG4 ${SEND_TYPE_ARG4}")
|
||||||
|
#MESSAGE("SEND_TYPE_RETV ${SEND_TYPE_RETV}")
|
||||||
|
#MESSAGE("SEND_QUAL_ARG2 ${SEND_QUAL_ARG2}")
|
||||||
|
endif(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||||
|
|
||||||
|
if("${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||||
|
message(FATAL_ERROR "Cannot find proper types to use for send args")
|
||||||
|
endif("${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||||
|
set(SEND_QUAL_ARG2 "const")
|
||||||
|
else(curl_cv_send)
|
||||||
|
message(FATAL_ERROR "Unable to link function send")
|
||||||
|
endif(curl_cv_send)
|
||||||
|
set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send")
|
||||||
|
set(HAVE_SEND 1)
|
||||||
|
|
||||||
|
set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5")
|
||||||
|
curl_check_c_source_compiles("int flag = MSG_NOSIGNAL" HAVE_MSG_NOSIGNAL)
|
||||||
|
|
||||||
|
set(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2")
|
||||||
|
set(HEADER_INCLUDES)
|
||||||
|
set(headers_hack)
|
||||||
|
|
||||||
|
macro(add_header_include check header)
|
||||||
|
if(${check})
|
||||||
|
set(headers_hack
|
||||||
|
"${headers_hack}\n#include <${header}>")
|
||||||
|
#SET(HEADER_INCLUDES
|
||||||
|
# ${HEADER_INCLUDES}
|
||||||
|
# "${header}")
|
||||||
|
endif(${check})
|
||||||
|
endmacro(add_header_include header)
|
||||||
|
|
||||||
|
if(HAVE_WINDOWS_H)
|
||||||
|
set(EXTRA_DEFINES ${EXTRA_DEFINES}
|
||||||
|
"__unused7\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#define __unused3")
|
||||||
|
add_header_include(HAVE_WINDOWS_H "windows.h")
|
||||||
|
add_header_include(HAVE_WINSOCK2_H "winsock2.h")
|
||||||
|
add_header_include(HAVE_WINSOCK_H "winsock.h")
|
||||||
|
else(HAVE_WINDOWS_H)
|
||||||
|
add_header_include(HAVE_SYS_TYPES_H "sys/types.h")
|
||||||
|
add_header_include(HAVE_SYS_TIME_H "sys/time.h")
|
||||||
|
add_header_include(TIME_WITH_SYS_TIME "time.h")
|
||||||
|
add_header_include(HAVE_TIME_H "time.h")
|
||||||
|
endif(HAVE_WINDOWS_H)
|
||||||
|
set(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5")
|
||||||
|
curl_check_c_source_compiles("struct timeval ts;\nts.tv_sec = 0;\nts.tv_usec = 0" HAVE_STRUCT_TIMEVAL)
|
||||||
|
|
||||||
|
|
||||||
|
include(CurlCheckCSourceRuns)
|
||||||
|
set(EXTRA_DEFINES)
|
||||||
|
set(HEADER_INCLUDES)
|
||||||
|
if(HAVE_SYS_POLL_H)
|
||||||
|
set(HEADER_INCLUDES "sys/poll.h")
|
||||||
|
endif(HAVE_SYS_POLL_H)
|
||||||
|
curl_check_c_source_runs("return poll((void *)0, 0, 10 /*ms*/)" HAVE_POLL_FINE)
|
||||||
|
|
||||||
|
set(HAVE_SIG_ATOMIC_T 1)
|
||||||
|
set(EXTRA_DEFINES)
|
||||||
|
set(HEADER_INCLUDES)
|
||||||
|
if(HAVE_SIGNAL_H)
|
||||||
|
set(HEADER_INCLUDES "signal.h")
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
|
||||||
|
endif(HAVE_SIGNAL_H)
|
||||||
|
check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T)
|
||||||
|
if(HAVE_SIZEOF_SIG_ATOMIC_T)
|
||||||
|
curl_check_c_source_compiles("static volatile sig_atomic_t dummy = 0" HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
||||||
|
if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
||||||
|
set(HAVE_SIG_ATOMIC_T_VOLATILE 1)
|
||||||
|
endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
||||||
|
endif(HAVE_SIZEOF_SIG_ATOMIC_T)
|
||||||
|
|
||||||
|
set(CHECK_TYPE_SIZE_PREINCLUDE
|
||||||
|
"#undef inline")
|
||||||
|
|
||||||
|
if(HAVE_WINDOWS_H)
|
||||||
|
set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE}
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>")
|
||||||
|
if(HAVE_WINSOCK2_H)
|
||||||
|
set(CHECK_TYPE_SIZE_PREINCLUDE "${CHECK_TYPE_SIZE_PREINCLUDE}\n#include <winsock2.h>")
|
||||||
|
endif(HAVE_WINSOCK2_H)
|
||||||
|
else(HAVE_WINDOWS_H)
|
||||||
|
if(HAVE_SYS_SOCKET_H)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES}
|
||||||
|
"sys/socket.h")
|
||||||
|
endif(HAVE_SYS_SOCKET_H)
|
||||||
|
if(HAVE_NETINET_IN_H)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES}
|
||||||
|
"netinet/in.h")
|
||||||
|
endif(HAVE_NETINET_IN_H)
|
||||||
|
if(HAVE_ARPA_INET_H)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES}
|
||||||
|
"arpa/inet.h")
|
||||||
|
endif(HAVE_ARPA_INET_H)
|
||||||
|
endif(HAVE_WINDOWS_H)
|
||||||
|
|
||||||
|
check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
||||||
|
if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
||||||
|
set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
|
||||||
|
endif(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
||||||
|
|
||||||
121
CMake/Platforms/WindowsCache.cmake
Normal file
121
CMake/Platforms/WindowsCache.cmake
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
if(NOT UNIX)
|
||||||
|
if(WIN32)
|
||||||
|
set(HAVE_LIBDL 0)
|
||||||
|
set(HAVE_LIBUCB 0)
|
||||||
|
set(HAVE_LIBSOCKET 0)
|
||||||
|
set(NOT_NEED_LIBNSL 0)
|
||||||
|
set(HAVE_LIBNSL 0)
|
||||||
|
set(HAVE_LIBZ 0)
|
||||||
|
set(HAVE_LIBCRYPTO 0)
|
||||||
|
|
||||||
|
set(HAVE_DLOPEN 0)
|
||||||
|
|
||||||
|
set(HAVE_ALLOCA_H 0)
|
||||||
|
set(HAVE_ARPA_INET_H 0)
|
||||||
|
set(HAVE_DLFCN_H 0)
|
||||||
|
set(HAVE_FCNTL_H 1)
|
||||||
|
set(HAVE_FEATURES_H 0)
|
||||||
|
set(HAVE_INTTYPES_H 0)
|
||||||
|
set(HAVE_IO_H 1)
|
||||||
|
set(HAVE_MALLOC_H 1)
|
||||||
|
set(HAVE_MEMORY_H 1)
|
||||||
|
set(HAVE_NETDB_H 0)
|
||||||
|
set(HAVE_NETINET_IF_ETHER_H 0)
|
||||||
|
set(HAVE_NETINET_IN_H 0)
|
||||||
|
set(HAVE_NET_IF_H 0)
|
||||||
|
set(HAVE_PROCESS_H 1)
|
||||||
|
set(HAVE_PWD_H 0)
|
||||||
|
set(HAVE_SETJMP_H 1)
|
||||||
|
set(HAVE_SGTTY_H 0)
|
||||||
|
set(HAVE_SIGNAL_H 1)
|
||||||
|
set(HAVE_SOCKIO_H 0)
|
||||||
|
set(HAVE_STDINT_H 0)
|
||||||
|
set(HAVE_STDLIB_H 1)
|
||||||
|
set(HAVE_STRINGS_H 0)
|
||||||
|
set(HAVE_STRING_H 1)
|
||||||
|
set(HAVE_SYS_PARAM_H 0)
|
||||||
|
set(HAVE_SYS_POLL_H 0)
|
||||||
|
set(HAVE_SYS_SELECT_H 0)
|
||||||
|
set(HAVE_SYS_SOCKET_H 0)
|
||||||
|
set(HAVE_SYS_SOCKIO_H 0)
|
||||||
|
set(HAVE_SYS_STAT_H 1)
|
||||||
|
set(HAVE_SYS_TIME_H 0)
|
||||||
|
set(HAVE_SYS_TYPES_H 1)
|
||||||
|
set(HAVE_SYS_UTIME_H 1)
|
||||||
|
set(HAVE_TERMIOS_H 0)
|
||||||
|
set(HAVE_TERMIO_H 0)
|
||||||
|
set(HAVE_TIME_H 1)
|
||||||
|
set(HAVE_UNISTD_H 0)
|
||||||
|
set(HAVE_UTIME_H 0)
|
||||||
|
set(HAVE_X509_H 0)
|
||||||
|
set(HAVE_ZLIB_H 0)
|
||||||
|
|
||||||
|
set(HAVE_SIZEOF_LONG_DOUBLE 1)
|
||||||
|
set(SIZEOF_LONG_DOUBLE 8)
|
||||||
|
|
||||||
|
set(HAVE_SOCKET 1)
|
||||||
|
set(HAVE_POLL 0)
|
||||||
|
set(HAVE_SELECT 1)
|
||||||
|
set(HAVE_STRDUP 1)
|
||||||
|
set(HAVE_STRSTR 1)
|
||||||
|
set(HAVE_STRTOK_R 0)
|
||||||
|
set(HAVE_STRFTIME 1)
|
||||||
|
set(HAVE_UNAME 0)
|
||||||
|
set(HAVE_STRCASECMP 0)
|
||||||
|
set(HAVE_STRICMP 1)
|
||||||
|
set(HAVE_STRCMPI 1)
|
||||||
|
set(HAVE_GETHOSTBYADDR 1)
|
||||||
|
set(HAVE_GETTIMEOFDAY 0)
|
||||||
|
set(HAVE_INET_ADDR 1)
|
||||||
|
set(HAVE_INET_NTOA 1)
|
||||||
|
set(HAVE_INET_NTOA_R 0)
|
||||||
|
set(HAVE_TCGETATTR 0)
|
||||||
|
set(HAVE_TCSETATTR 0)
|
||||||
|
set(HAVE_PERROR 1)
|
||||||
|
set(HAVE_CLOSESOCKET 1)
|
||||||
|
set(HAVE_SETVBUF 0)
|
||||||
|
set(HAVE_SIGSETJMP 0)
|
||||||
|
set(HAVE_GETPASS_R 0)
|
||||||
|
set(HAVE_STRLCAT 0)
|
||||||
|
set(HAVE_GETPWUID 0)
|
||||||
|
set(HAVE_GETEUID 0)
|
||||||
|
set(HAVE_UTIME 1)
|
||||||
|
set(HAVE_RAND_EGD 0)
|
||||||
|
set(HAVE_RAND_SCREEN 0)
|
||||||
|
set(HAVE_RAND_STATUS 0)
|
||||||
|
set(HAVE_GMTIME_R 0)
|
||||||
|
set(HAVE_LOCALTIME_R 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R 0)
|
||||||
|
set(HAVE_SIGNAL_FUNC 1)
|
||||||
|
set(HAVE_SIGNAL_MACRO 0)
|
||||||
|
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_5 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_5_REENTRANT 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_7 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_7_REENTRANT 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_8 0)
|
||||||
|
set(HAVE_GETHOSTBYADDR_R_8_REENTRANT 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_3 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_5 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_5_REENTRANT 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_6 0)
|
||||||
|
set(HAVE_GETHOSTBYNAME_R_6_REENTRANT 0)
|
||||||
|
|
||||||
|
set(TIME_WITH_SYS_TIME 0)
|
||||||
|
set(HAVE_O_NONBLOCK 0)
|
||||||
|
set(HAVE_IN_ADDR_T 0)
|
||||||
|
set(HAVE_INET_NTOA_R_DECL 0)
|
||||||
|
set(HAVE_INET_NTOA_R_DECL_REENTRANT 0)
|
||||||
|
set(HAVE_GETADDRINFO 0)
|
||||||
|
set(STDC_HEADERS 1)
|
||||||
|
set(RETSIGTYPE_TEST 1)
|
||||||
|
|
||||||
|
set(HAVE_SIGACTION 0)
|
||||||
|
set(HAVE_MACRO_SIGSETJMP 0)
|
||||||
|
else(WIN32)
|
||||||
|
message("This file should be included on Windows platform only")
|
||||||
|
endif(WIN32)
|
||||||
|
endif(NOT UNIX)
|
||||||
|
|
||||||
31
CMake/Utilities.cmake
Normal file
31
CMake/Utilities.cmake
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# File containing various utilities
|
||||||
|
|
||||||
|
# Converts a CMake list to a string containing elements separated by spaces
|
||||||
|
function(TO_LIST_SPACES _LIST_NAME OUTPUT_VAR)
|
||||||
|
set(NEW_LIST_SPACE)
|
||||||
|
foreach(ITEM ${${_LIST_NAME}})
|
||||||
|
set(NEW_LIST_SPACE "${NEW_LIST_SPACE} ${ITEM}")
|
||||||
|
endforeach()
|
||||||
|
string(STRIP ${NEW_LIST_SPACE} NEW_LIST_SPACE)
|
||||||
|
set(${OUTPUT_VAR} "${NEW_LIST_SPACE}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Appends a lis of item to a string which is a space-separated list, if they don't already exist.
|
||||||
|
function(LIST_SPACES_APPEND_ONCE LIST_NAME)
|
||||||
|
string(REPLACE " " ";" _LIST ${${LIST_NAME}})
|
||||||
|
list(APPEND _LIST ${ARGN})
|
||||||
|
list(REMOVE_DUPLICATES _LIST)
|
||||||
|
to_list_spaces(_LIST NEW_LIST_SPACE)
|
||||||
|
set(${LIST_NAME} "${NEW_LIST_SPACE}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Convinience function that does the same as LIST(FIND ...) but with a TRUE/FALSE return value.
|
||||||
|
# Ex: IN_STR_LIST(MY_LIST "Searched item" WAS_FOUND)
|
||||||
|
function(IN_STR_LIST LIST_NAME ITEM_SEARCHED RETVAL)
|
||||||
|
list(FIND ${LIST_NAME} ${ITEM_SEARCHED} FIND_POS)
|
||||||
|
if(${FIND_POS} EQUAL -1)
|
||||||
|
set(${RETVAL} FALSE PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${RETVAL} TRUE PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
859
CMakeLists.txt
Normal file
859
CMakeLists.txt
Normal file
@@ -0,0 +1,859 @@
|
|||||||
|
# cURL/libcurl CMake script
|
||||||
|
# by Tetetest and Sukender (Benoit Neil)
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
# The output .so file lacks the soname number which we currently have within the lib/Makefile.am file
|
||||||
|
# Add full (4 or 5 libs) SSL support
|
||||||
|
# Add INSTALL target (EXTRA_DIST variables in Makefile.am may be moved to Makefile.inc so that CMake/CPack is aware of what's to include).
|
||||||
|
# Add CTests(?)
|
||||||
|
# Check on all possible platforms
|
||||||
|
# Test with as many configurations possible (With or without any option)
|
||||||
|
# Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest:
|
||||||
|
# - lists of headers that 'configure' checks for;
|
||||||
|
# - curl-specific tests (the ones that are in m4/curl-*.m4 files);
|
||||||
|
# - (most obvious thing:) curl version numbers.
|
||||||
|
# Add documentation subproject
|
||||||
|
#
|
||||||
|
# To check:
|
||||||
|
# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
|
||||||
|
# (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
|
||||||
|
cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
|
||||||
|
include(Utilities)
|
||||||
|
|
||||||
|
project( CURL C )
|
||||||
|
|
||||||
|
|
||||||
|
file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
|
||||||
|
string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)"
|
||||||
|
LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS})
|
||||||
|
string (REGEX MATCH "([0-9]+)"
|
||||||
|
LIBCURL_VERSION_MJ ${LIBCURL_VERSION_MJ})
|
||||||
|
string (REGEX MATCH
|
||||||
|
"LIBCURL_VERSION_MINOR[ \t]+([0-9]+)"
|
||||||
|
LIBCURL_VERSION_MI ${CURL_VERSION_H_CONTENTS})
|
||||||
|
string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_MI ${LIBCURL_VERSION_MI})
|
||||||
|
string (REGEX MATCH
|
||||||
|
"LIBCURL_VERSION_PATCH[ \t]+([0-9]+)"
|
||||||
|
LIBCURL_VERSION_PT ${CURL_VERSION_H_CONTENTS})
|
||||||
|
string (REGEX MATCH "([0-9]+)" LIBCURL_VERSION_PT ${LIBCURL_VERSION_PT})
|
||||||
|
set (CURL_MAJOR_VERSION ${LIBCURL_VERSION_MJ})
|
||||||
|
set (CURL_MINOR_VERSION ${LIBCURL_VERSION_MI})
|
||||||
|
set (CURL_PATCH_VERSION ${LIBCURL_VERSION_PT})
|
||||||
|
|
||||||
|
include_regular_expression("^.*$") # Sukender: Is it necessary?
|
||||||
|
|
||||||
|
# Setup package meta-data
|
||||||
|
# SET(PACKAGE "curl")
|
||||||
|
set(CURL_VERSION ${CURL_MAJOR_VERSION}.${CURL_MINOR_VERSION}.${CURL_PATCH_VERSION})
|
||||||
|
message(STATUS "curl version=[${CURL_VERSION}]")
|
||||||
|
# SET(PACKAGE_TARNAME "curl")
|
||||||
|
# SET(PACKAGE_NAME "curl")
|
||||||
|
# SET(PACKAGE_VERSION "-")
|
||||||
|
# SET(PACKAGE_STRING "curl-")
|
||||||
|
# SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/")
|
||||||
|
set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
|
||||||
|
set(OS "\"${CMAKE_SYSTEM_NAME}\"")
|
||||||
|
|
||||||
|
include_directories(${PROJECT_BINARY_DIR}/include/curl)
|
||||||
|
include_directories( ${CURL_SOURCE_DIR}/include )
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(NATIVE_WINDOWS ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON)
|
||||||
|
option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON)
|
||||||
|
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
|
||||||
|
option(CURL_USE_ARES "Set to ON to enable c-ares support" OFF)
|
||||||
|
# initialize CURL_LIBS
|
||||||
|
set(CURL_LIBS "")
|
||||||
|
|
||||||
|
if(CURL_USE_ARES)
|
||||||
|
set(USE_ARES ${CURL_USE_ARES})
|
||||||
|
find_package(CARES REQUIRED)
|
||||||
|
list(APPEND CURL_LIBS ${CARES_LIBRARY} )
|
||||||
|
set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of cURL builds here http://www.cdash.org/CDashPublic/index.php?project=CURL" OFF)
|
||||||
|
if(BUILD_DASHBOARD_REPORTS)
|
||||||
|
#INCLUDE(Dart)
|
||||||
|
include(CTest)
|
||||||
|
endif(BUILD_DASHBOARD_REPORTS)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF)
|
||||||
|
mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON)
|
||||||
|
mark_as_advanced(CURL_HIDDEN_SYMBOLS)
|
||||||
|
|
||||||
|
# IF(WIN32)
|
||||||
|
# OPTION(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON)
|
||||||
|
# MARK_AS_ADVANCED(CURL_WINDOWS_SSPI)
|
||||||
|
# ENDIF()
|
||||||
|
|
||||||
|
option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF)
|
||||||
|
mark_as_advanced(HTTP_ONLY)
|
||||||
|
option(CURL_DISABLE_FTP "disables FTP" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_FTP)
|
||||||
|
option(CURL_DISABLE_LDAP "disables LDAP" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_LDAP)
|
||||||
|
option(CURL_DISABLE_TELNET "disables Telnet" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_TELNET)
|
||||||
|
option(CURL_DISABLE_DICT "disables DICT" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_DICT)
|
||||||
|
option(CURL_DISABLE_FILE "disables FILE" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_FILE)
|
||||||
|
option(CURL_DISABLE_TFTP "disables TFTP" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_TFTP)
|
||||||
|
option(CURL_DISABLE_HTTP "disables HTTP" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_HTTP)
|
||||||
|
|
||||||
|
option(CURL_DISABLE_LDAPS "to disable LDAPS" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_LDAPS)
|
||||||
|
if(WIN32)
|
||||||
|
set(CURL_DEFAULT_DISABLE_LDAP OFF)
|
||||||
|
# some windows compilers do not have wldap32
|
||||||
|
if( NOT HAVE_WLDAP32)
|
||||||
|
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
|
||||||
|
message(STATUS "wldap32 not found CURL_DISABLE_LDAP set ON")
|
||||||
|
option(CURL_LDAP_WIN "Use W$ LDAP implementation" OFF)
|
||||||
|
else()
|
||||||
|
option(CURL_LDAP_WIN "Use W$ LDAP implementation" ON)
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(CURL_LDAP_WIN)
|
||||||
|
set(CURL_LDAP_HYBRID OFF)
|
||||||
|
else()
|
||||||
|
option(CURL_LDAP_HYBRID "W$ LDAP with non-W$ compiler" OFF)
|
||||||
|
mark_as_advanced(CURL_LDAP_HYBRID)
|
||||||
|
set(CURL_LDAP_WIN OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HTTP_ONLY)
|
||||||
|
set(CURL_DISABLE_FTP ON)
|
||||||
|
set(CURL_DISABLE_LDAP ON)
|
||||||
|
set(CURL_DISABLE_TELNET ON)
|
||||||
|
set(CURL_DISABLE_DICT ON)
|
||||||
|
set(CURL_DISABLE_FILE ON)
|
||||||
|
set(CURL_DISABLE_TFTP ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(CURL_DISABLE_COOKIES "to disable cookies support" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_COOKIES)
|
||||||
|
|
||||||
|
option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH)
|
||||||
|
option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF)
|
||||||
|
mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
|
||||||
|
option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF)
|
||||||
|
mark_as_advanced(DISABLED_THREADSAFE)
|
||||||
|
option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF)
|
||||||
|
mark_as_advanced(ENABLE_IPV6)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
list_spaces_append_once(CMAKE_C_STANDARD_LIBRARIES wsock32.lib ws2_32.lib) # bufferoverflowu.lib
|
||||||
|
if(CURL_DISABLE_LDAP)
|
||||||
|
# Remove wldap32.lib from space-separated list
|
||||||
|
string(REPLACE " " ";" _LIST ${CMAKE_C_STANDARD_LIBRARIES})
|
||||||
|
list(REMOVE_ITEM _LIST "wldap32.lib")
|
||||||
|
to_list_spaces(_LIST CMAKE_C_STANDARD_LIBRARIES)
|
||||||
|
else()
|
||||||
|
# Append wldap32.lib
|
||||||
|
list_spaces_append_once(CMAKE_C_STANDARD_LIBRARIES wldap32.lib)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}" CACHE STRING "" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# We need ansi c-flags, especially on HP
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
|
||||||
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
|
||||||
|
|
||||||
|
# Disable warnings on Borland to avoid changing 3rd party code.
|
||||||
|
if(BORLAND)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
|
||||||
|
endif(BORLAND)
|
||||||
|
|
||||||
|
# If we are on AIX, do the _ALL_SOURCE magic
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
|
||||||
|
set(_ALL_SOURCE 1)
|
||||||
|
endif(${CMAKE_SYSTEM_NAME} MATCHES AIX)
|
||||||
|
|
||||||
|
# Include all the necessary files for macros
|
||||||
|
include (CheckFunctionExists)
|
||||||
|
include (CheckIncludeFile)
|
||||||
|
include (CheckIncludeFiles)
|
||||||
|
include (CheckLibraryExists)
|
||||||
|
include (CheckSymbolExists)
|
||||||
|
# if crosscompiling is on, the CHECK_TYPE_SIZE macro coming with cmake uses
|
||||||
|
# TRY_COMPILE instead of TRY_RUN which makes crosscompiling easier, Alex
|
||||||
|
if(CMAKE_CROSSCOMPILING)
|
||||||
|
include ("${CMAKE_MODULE_PATH}/CheckTypeSize.cmake")
|
||||||
|
else(CMAKE_CROSSCOMPILING)
|
||||||
|
include (CheckTypeSize)
|
||||||
|
endif(CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
|
# On windows preload settings
|
||||||
|
if(WIN32)
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
# This macro checks if the symbol exists in the library and if it
|
||||||
|
# does, it appends library to the list.
|
||||||
|
macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
|
||||||
|
check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} ""
|
||||||
|
${VARIABLE})
|
||||||
|
if(${VARIABLE})
|
||||||
|
set(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
|
||||||
|
endif(${VARIABLE})
|
||||||
|
endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
|
||||||
|
|
||||||
|
# Check for all needed libraries
|
||||||
|
check_library_exists_concat("dl" dlopen HAVE_LIBDL)
|
||||||
|
check_library_exists_concat("socket" connect HAVE_LIBSOCKET)
|
||||||
|
check_library_exists("c" gethostbyname "" NOT_NEED_LIBNSL)
|
||||||
|
|
||||||
|
# Yellowtab Zeta needs different libraries than BeOS 5.
|
||||||
|
if(BEOS)
|
||||||
|
set(NOT_NEED_LIBNSL 1)
|
||||||
|
check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
|
||||||
|
check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
|
||||||
|
endif(BEOS)
|
||||||
|
|
||||||
|
if(NOT NOT_NEED_LIBNSL)
|
||||||
|
check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL)
|
||||||
|
endif(NOT NOT_NEED_LIBNSL)
|
||||||
|
|
||||||
|
check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
|
||||||
|
check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
|
||||||
|
check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32)
|
||||||
|
|
||||||
|
# IF(NOT CURL_SPECIAL_LIBZ)
|
||||||
|
# CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
|
||||||
|
# ENDIF(NOT CURL_SPECIAL_LIBZ)
|
||||||
|
|
||||||
|
option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
|
||||||
|
mark_as_advanced(CMAKE_USE_OPENSSL)
|
||||||
|
if(CMAKE_USE_OPENSSL)
|
||||||
|
if(WIN32)
|
||||||
|
find_package(OpenSSL)
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
set(USE_SSLEAY TRUE)
|
||||||
|
set(USE_OPENSSL TRUE)
|
||||||
|
list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} )
|
||||||
|
else()
|
||||||
|
set(CMAKE_USE_OPENSSL FALSE)
|
||||||
|
message(STATUS "OpenSSL NOT Found, disabling CMAKE_USE_OPENSSL")
|
||||||
|
endif()
|
||||||
|
else(WIN32)
|
||||||
|
check_library_exists_concat("crypto" CRYPTO_lock HAVE_LIBCRYPTO)
|
||||||
|
check_library_exists_concat("ssl" SSL_connect HAVE_LIBSSL)
|
||||||
|
endif(WIN32)
|
||||||
|
endif(CMAKE_USE_OPENSSL)
|
||||||
|
|
||||||
|
# Check for idn
|
||||||
|
check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN)
|
||||||
|
|
||||||
|
# Check for LDAP
|
||||||
|
check_library_exists_concat("ldap" ldap_init HAVE_LIBLDAP)
|
||||||
|
# if(NOT HAVE_LIBLDAP)
|
||||||
|
# SET(CURL_DISABLE_LDAP ON)
|
||||||
|
# endif(NOT HAVE_LIBLDAP)
|
||||||
|
|
||||||
|
# Check for symbol dlopen (same as HAVE_LIBDL)
|
||||||
|
check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN)
|
||||||
|
|
||||||
|
# For other tests to use the same libraries
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBS})
|
||||||
|
|
||||||
|
option(CURL_ZLIB "Set to ON to enable building cURL with zlib support." ON)
|
||||||
|
set(HAVE_LIBZ OFF)
|
||||||
|
set(HAVE_ZLIB_H OFF)
|
||||||
|
set(HAVE_ZLIB OFF)
|
||||||
|
if(CURL_ZLIB) # AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE
|
||||||
|
find_package(ZLIB QUIET)
|
||||||
|
if(ZLIB_FOUND)
|
||||||
|
set(HAVE_ZLIB_H ON)
|
||||||
|
set(HAVE_ZLIB ON)
|
||||||
|
set(HAVE_LIBZ ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If we have features.h, then do the _BSD_SOURCE magic
|
||||||
|
check_include_file("features.h" HAVE_FEATURES_H)
|
||||||
|
|
||||||
|
# Check if header file exists and add it to the list.
|
||||||
|
macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
|
||||||
|
check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
|
||||||
|
if(${VARIABLE})
|
||||||
|
set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
|
||||||
|
set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
|
||||||
|
endif(${VARIABLE})
|
||||||
|
endmacro(CHECK_INCLUDE_FILE_CONCAT)
|
||||||
|
|
||||||
|
|
||||||
|
# Check for header files
|
||||||
|
if(NOT UNIX)
|
||||||
|
check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H)
|
||||||
|
check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H)
|
||||||
|
endif(NOT UNIX)
|
||||||
|
check_include_file_concat("stdio.h" HAVE_STDIO_H)
|
||||||
|
if(NOT UNIX)
|
||||||
|
check_include_file_concat("windows.h" HAVE_WINDOWS_H)
|
||||||
|
check_include_file_concat("winsock.h" HAVE_WINSOCK_H)
|
||||||
|
endif(NOT UNIX)
|
||||||
|
|
||||||
|
check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
|
||||||
|
check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
|
||||||
|
check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
|
||||||
|
check_include_file_concat("sys/param.h" HAVE_SYS_PARAM_H)
|
||||||
|
check_include_file_concat("sys/poll.h" HAVE_SYS_POLL_H)
|
||||||
|
check_include_file_concat("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
||||||
|
check_include_file_concat("sys/select.h" HAVE_SYS_SELECT_H)
|
||||||
|
check_include_file_concat("sys/socket.h" HAVE_SYS_SOCKET_H)
|
||||||
|
check_include_file_concat("sys/sockio.h" HAVE_SYS_SOCKIO_H)
|
||||||
|
check_include_file_concat("sys/stat.h" HAVE_SYS_STAT_H)
|
||||||
|
check_include_file_concat("sys/time.h" HAVE_SYS_TIME_H)
|
||||||
|
check_include_file_concat("sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
|
check_include_file_concat("sys/uio.h" HAVE_SYS_UIO_H)
|
||||||
|
check_include_file_concat("sys/un.h" HAVE_SYS_UN_H)
|
||||||
|
check_include_file_concat("sys/utime.h" HAVE_SYS_UTIME_H)
|
||||||
|
check_include_file_concat("alloca.h" HAVE_ALLOCA_H)
|
||||||
|
check_include_file_concat("arpa/inet.h" HAVE_ARPA_INET_H)
|
||||||
|
check_include_file_concat("arpa/tftp.h" HAVE_ARPA_TFTP_H)
|
||||||
|
check_include_file_concat("assert.h" HAVE_ASSERT_H)
|
||||||
|
check_include_file_concat("crypto.h" HAVE_CRYPTO_H)
|
||||||
|
check_include_file_concat("des.h" HAVE_DES_H)
|
||||||
|
check_include_file_concat("err.h" HAVE_ERR_H)
|
||||||
|
check_include_file_concat("errno.h" HAVE_ERRNO_H)
|
||||||
|
check_include_file_concat("fcntl.h" HAVE_FCNTL_H)
|
||||||
|
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
|
||||||
|
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
|
||||||
|
check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
|
||||||
|
check_include_file_concat("idn-free.h" HAVE_IDN_FREE_H)
|
||||||
|
check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
|
||||||
|
check_include_file_concat("io.h" HAVE_IO_H)
|
||||||
|
check_include_file_concat("krb.h" HAVE_KRB_H)
|
||||||
|
check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
|
||||||
|
check_include_file_concat("libssh2.h" HAVE_LIBSSH2_H)
|
||||||
|
check_include_file_concat("limits.h" HAVE_LIMITS_H)
|
||||||
|
check_include_file_concat("locale.h" HAVE_LOCALE_H)
|
||||||
|
check_include_file_concat("net/if.h" HAVE_NET_IF_H)
|
||||||
|
check_include_file_concat("netdb.h" HAVE_NETDB_H)
|
||||||
|
check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
|
||||||
|
check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
|
||||||
|
check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
|
||||||
|
check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
|
||||||
|
check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H)
|
||||||
|
check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H)
|
||||||
|
check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
|
||||||
|
check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
|
||||||
|
check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
|
||||||
|
check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H)
|
||||||
|
check_include_file_concat("pem.h" HAVE_PEM_H)
|
||||||
|
check_include_file_concat("poll.h" HAVE_POLL_H)
|
||||||
|
check_include_file_concat("pwd.h" HAVE_PWD_H)
|
||||||
|
check_include_file_concat("rsa.h" HAVE_RSA_H)
|
||||||
|
check_include_file_concat("setjmp.h" HAVE_SETJMP_H)
|
||||||
|
check_include_file_concat("sgtty.h" HAVE_SGTTY_H)
|
||||||
|
check_include_file_concat("signal.h" HAVE_SIGNAL_H)
|
||||||
|
check_include_file_concat("ssl.h" HAVE_SSL_H)
|
||||||
|
check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
|
||||||
|
check_include_file_concat("stdint.h" HAVE_STDINT_H)
|
||||||
|
check_include_file_concat("stdio.h" HAVE_STDIO_H)
|
||||||
|
check_include_file_concat("stdlib.h" HAVE_STDLIB_H)
|
||||||
|
check_include_file_concat("string.h" HAVE_STRING_H)
|
||||||
|
check_include_file_concat("strings.h" HAVE_STRINGS_H)
|
||||||
|
check_include_file_concat("stropts.h" HAVE_STROPTS_H)
|
||||||
|
check_include_file_concat("termio.h" HAVE_TERMIO_H)
|
||||||
|
check_include_file_concat("termios.h" HAVE_TERMIOS_H)
|
||||||
|
check_include_file_concat("time.h" HAVE_TIME_H)
|
||||||
|
check_include_file_concat("tld.h" HAVE_TLD_H)
|
||||||
|
check_include_file_concat("unistd.h" HAVE_UNISTD_H)
|
||||||
|
check_include_file_concat("utime.h" HAVE_UTIME_H)
|
||||||
|
check_include_file_concat("x509.h" HAVE_X509_H)
|
||||||
|
|
||||||
|
check_include_file_concat("process.h" HAVE_PROCESS_H)
|
||||||
|
check_include_file_concat("stddef.h" HAVE_STDDEF_H)
|
||||||
|
check_include_file_concat("dlfcn.h" HAVE_DLFCN_H)
|
||||||
|
check_include_file_concat("malloc.h" HAVE_MALLOC_H)
|
||||||
|
check_include_file_concat("memory.h" HAVE_MEMORY_H)
|
||||||
|
check_include_file_concat("ldap.h" HAVE_LDAP_H)
|
||||||
|
check_include_file_concat("netinet/if_ether.h" HAVE_NETINET_IF_ETHER_H)
|
||||||
|
check_include_file_concat("stdint.h" HAVE_STDINT_H)
|
||||||
|
check_include_file_concat("sockio.h" HAVE_SOCKIO_H)
|
||||||
|
check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
|
||||||
|
check_include_file_concat("idna.h" HAVE_IDNA_H)
|
||||||
|
|
||||||
|
if(CMAKE_USE_OPENSSL)
|
||||||
|
check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H)
|
||||||
|
endif(CMAKE_USE_OPENSSL)
|
||||||
|
|
||||||
|
if(NOT HAVE_LDAP_H)
|
||||||
|
message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
|
||||||
|
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
check_type_size(size_t SIZEOF_SIZE_T)
|
||||||
|
check_type_size(ssize_t SIZEOF_SSIZE_T)
|
||||||
|
check_type_size("long long" SIZEOF_LONG_LONG)
|
||||||
|
check_type_size("long" SIZEOF_LONG)
|
||||||
|
check_type_size("short" SIZEOF_SHORT)
|
||||||
|
check_type_size("int" SIZEOF_INT)
|
||||||
|
check_type_size("__int64" SIZEOF___INT64)
|
||||||
|
check_type_size("long double" SIZEOF_LONG_DOUBLE)
|
||||||
|
check_type_size("time_t" SIZEOF_TIME_T)
|
||||||
|
if(NOT HAVE_SIZEOF_SSIZE_T)
|
||||||
|
if(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
|
||||||
|
set(ssize_t long)
|
||||||
|
endif(SIZEOF_LONG EQUAL SIZEOF_SIZE_T)
|
||||||
|
if(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
|
||||||
|
set(ssize_t __int64)
|
||||||
|
endif(NOT ssize_t AND SIZEOF___INT64 EQUAL SIZEOF_SIZE_T)
|
||||||
|
endif(NOT HAVE_SIZEOF_SSIZE_T)
|
||||||
|
|
||||||
|
# Different sizeofs, etc.
|
||||||
|
|
||||||
|
# define CURL_SIZEOF_LONG 4
|
||||||
|
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||||
|
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||||
|
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||||
|
# define CURL_FORMAT_OFF_T "%lld"
|
||||||
|
# define CURL_SIZEOF_CURL_OFF_T 8
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||||
|
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||||
|
|
||||||
|
set(CURL_SIZEOF_LONG ${SIZEOF_LONG})
|
||||||
|
|
||||||
|
if(SIZEOF_LONG EQUAL 8)
|
||||||
|
set(CURL_TYPEOF_CURL_OFF_T long)
|
||||||
|
set(CURL_SIZEOF_CURL_OFF_T 8)
|
||||||
|
set(CURL_FORMAT_CURL_OFF_T "ld")
|
||||||
|
set(CURL_FORMAT_CURL_OFF_TU "lu")
|
||||||
|
set(CURL_FORMAT_OFF_T "%ld")
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_T L)
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_TU LU)
|
||||||
|
endif(SIZEOF_LONG EQUAL 8)
|
||||||
|
|
||||||
|
if(SIZEOF_LONG_LONG EQUAL 8)
|
||||||
|
set(CURL_TYPEOF_CURL_OFF_T "long long")
|
||||||
|
set(CURL_SIZEOF_CURL_OFF_T 8)
|
||||||
|
set(CURL_FORMAT_CURL_OFF_T "lld")
|
||||||
|
set(CURL_FORMAT_CURL_OFF_TU "llu")
|
||||||
|
set(CURL_FORMAT_OFF_T "%lld")
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_T LL)
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_TU LLU)
|
||||||
|
endif(SIZEOF_LONG_LONG EQUAL 8)
|
||||||
|
|
||||||
|
if(NOT CURL_TYPEOF_CURL_OFF_T)
|
||||||
|
set(CURL_TYPEOF_CURL_OFF_T ${ssize_t})
|
||||||
|
set(CURL_SIZEOF_CURL_OFF_T ${SIZEOF_SSIZE_T})
|
||||||
|
# TODO: need adjustment here.
|
||||||
|
set(CURL_FORMAT_CURL_OFF_T "ld")
|
||||||
|
set(CURL_FORMAT_CURL_OFF_TU "lu")
|
||||||
|
set(CURL_FORMAT_OFF_T "%ld")
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_T L)
|
||||||
|
set(CURL_SUFFIX_CURL_OFF_TU LU)
|
||||||
|
endif(NOT CURL_TYPEOF_CURL_OFF_T)
|
||||||
|
|
||||||
|
if(HAVE_SIZEOF_LONG_LONG)
|
||||||
|
set(HAVE_LONGLONG 1)
|
||||||
|
set(HAVE_LL 1)
|
||||||
|
endif(HAVE_SIZEOF_LONG_LONG)
|
||||||
|
|
||||||
|
find_file(RANDOM_FILE urandom /dev)
|
||||||
|
mark_as_advanced(RANDOM_FILE)
|
||||||
|
|
||||||
|
# Check for some functions that are used
|
||||||
|
check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
|
||||||
|
check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
|
||||||
|
check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
|
||||||
|
check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
|
||||||
|
check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
|
||||||
|
check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
|
||||||
|
check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
|
||||||
|
check_symbol_exists(strftime "${CURL_INCLUDES}" HAVE_STRFTIME)
|
||||||
|
check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
|
||||||
|
check_symbol_exists(strcasecmp "${CURL_INCLUDES}" HAVE_STRCASECMP)
|
||||||
|
check_symbol_exists(stricmp "${CURL_INCLUDES}" HAVE_STRICMP)
|
||||||
|
check_symbol_exists(strcmpi "${CURL_INCLUDES}" HAVE_STRCMPI)
|
||||||
|
check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
|
||||||
|
check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
|
||||||
|
if(NOT HAVE_STRNCMPI)
|
||||||
|
set(HAVE_STRCMPI)
|
||||||
|
endif(NOT HAVE_STRNCMPI)
|
||||||
|
check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
|
||||||
|
check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
|
||||||
|
check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
|
||||||
|
check_symbol_exists(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
|
||||||
|
check_symbol_exists(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA)
|
||||||
|
check_symbol_exists(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
|
||||||
|
check_symbol_exists(tcsetattr "${CURL_INCLUDES}" HAVE_TCSETATTR)
|
||||||
|
check_symbol_exists(tcgetattr "${CURL_INCLUDES}" HAVE_TCGETATTR)
|
||||||
|
check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
|
||||||
|
check_symbol_exists(closesocket "${CURL_INCLUDES}" HAVE_CLOSESOCKET)
|
||||||
|
check_symbol_exists(setvbuf "${CURL_INCLUDES}" HAVE_SETVBUF)
|
||||||
|
check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
|
||||||
|
check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
|
||||||
|
check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
|
||||||
|
check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
|
||||||
|
check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
|
||||||
|
check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
|
||||||
|
if(CMAKE_USE_OPENSSL)
|
||||||
|
check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS)
|
||||||
|
check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
|
||||||
|
check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
|
||||||
|
check_symbol_exists(CRYPTO_cleanup_all_ex_data "${CURL_INCLUDES}"
|
||||||
|
HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
|
||||||
|
if(HAVE_LIBCRYPTO AND HAVE_LIBSSL)
|
||||||
|
set(USE_OPENSSL 1)
|
||||||
|
set(USE_SSLEAY 1)
|
||||||
|
endif(HAVE_LIBCRYPTO AND HAVE_LIBSSL)
|
||||||
|
endif(CMAKE_USE_OPENSSL)
|
||||||
|
check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
|
||||||
|
check_symbol_exists(localtime_r "${CURL_INCLUDES}" HAVE_LOCALTIME_R)
|
||||||
|
|
||||||
|
check_symbol_exists(gethostbyname "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME)
|
||||||
|
check_symbol_exists(gethostbyname_r "${CURL_INCLUDES}" HAVE_GETHOSTBYNAME_R)
|
||||||
|
|
||||||
|
check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
|
||||||
|
check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
|
||||||
|
if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
|
||||||
|
set(HAVE_SIGNAL 1)
|
||||||
|
endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
|
||||||
|
check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
|
||||||
|
check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
|
||||||
|
check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
|
||||||
|
check_symbol_exists(strerror_r "${CURL_INCLUDES}" HAVE_STRERROR_R)
|
||||||
|
check_symbol_exists(siginterrupt "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
|
||||||
|
check_symbol_exists(perror "${CURL_INCLUDES}" HAVE_PERROR)
|
||||||
|
check_symbol_exists(fork "${CURL_INCLUDES}" HAVE_FORK)
|
||||||
|
check_symbol_exists(freeaddrinfo "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
|
||||||
|
check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
|
||||||
|
check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
|
||||||
|
check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
|
||||||
|
check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
|
||||||
|
check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
|
||||||
|
check_symbol_exists(idn_free "${CURL_INCLUDES}" HAVE_IDN_FREE)
|
||||||
|
check_symbol_exists(idna_strerror "${CURL_INCLUDES}" HAVE_IDNA_STRERROR)
|
||||||
|
check_symbol_exists(tld_strerror "${CURL_INCLUDES}" HAVE_TLD_STRERROR)
|
||||||
|
check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
|
||||||
|
check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
|
||||||
|
check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
|
||||||
|
check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
|
||||||
|
check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
|
||||||
|
|
||||||
|
# symbol exists in win32, but function does not.
|
||||||
|
check_function_exists(inet_pton HAVE_INET_PTON)
|
||||||
|
|
||||||
|
# sigaction and sigsetjmp are special. Use special mechanism for
|
||||||
|
# detecting those, but only if previous attempt failed.
|
||||||
|
if(HAVE_SIGNAL_H)
|
||||||
|
check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
|
||||||
|
endif(HAVE_SIGNAL_H)
|
||||||
|
|
||||||
|
if(NOT HAVE_SIGSETJMP)
|
||||||
|
if(HAVE_SETJMP_H)
|
||||||
|
check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
|
||||||
|
if(HAVE_MACRO_SIGSETJMP)
|
||||||
|
set(HAVE_SIGSETJMP 1)
|
||||||
|
endif(HAVE_MACRO_SIGSETJMP)
|
||||||
|
endif(HAVE_SETJMP_H)
|
||||||
|
endif(NOT HAVE_SIGSETJMP)
|
||||||
|
|
||||||
|
# If there is no stricmp(), do not allow LDAP to parse URLs
|
||||||
|
if(NOT HAVE_STRICMP)
|
||||||
|
set(HAVE_LDAP_URL_PARSE 1)
|
||||||
|
endif(NOT HAVE_STRICMP)
|
||||||
|
|
||||||
|
# For other curl specific tests, use this macro.
|
||||||
|
macro(CURL_INTERNAL_TEST CURL_TEST)
|
||||||
|
if("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
|
||||||
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
|
"-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_TEST_ADD_LIBRARIES
|
||||||
|
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST}")
|
||||||
|
try_compile(${CURL_TEST}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
|
||||||
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
|
"${CURL_TEST_ADD_LIBRARIES}"
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
if(${CURL_TEST})
|
||||||
|
set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
"Performing Curl Test ${CURL_TEST} passed with the following output:\n"
|
||||||
|
"${OUTPUT}\n")
|
||||||
|
else(${CURL_TEST})
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
|
||||||
|
set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Performing Curl Test ${CURL_TEST} failed with the following output:\n"
|
||||||
|
"${OUTPUT}\n")
|
||||||
|
endif(${CURL_TEST})
|
||||||
|
endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
|
||||||
|
endmacro(CURL_INTERNAL_TEST)
|
||||||
|
|
||||||
|
macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
|
||||||
|
if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
|
||||||
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
|
"-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
set(CURL_TEST_ADD_LIBRARIES
|
||||||
|
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST}")
|
||||||
|
try_run(${CURL_TEST} ${CURL_TEST}_COMPILE
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
|
||||||
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
|
"${CURL_TEST_ADD_LIBRARIES}"
|
||||||
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
|
||||||
|
set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
|
||||||
|
else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
|
||||||
|
message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
|
||||||
|
set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
|
||||||
|
file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
|
||||||
|
"Performing Curl Test ${CURL_TEST} failed with the following output:\n"
|
||||||
|
"${OUTPUT}")
|
||||||
|
if(${CURL_TEST}_COMPILE)
|
||||||
|
file(APPEND
|
||||||
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
|
||||||
|
"There was a problem running this test\n")
|
||||||
|
endif(${CURL_TEST}_COMPILE)
|
||||||
|
file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
|
||||||
|
"\n\n")
|
||||||
|
endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
|
||||||
|
endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
|
||||||
|
endmacro(CURL_INTERNAL_TEST_RUN)
|
||||||
|
|
||||||
|
# Do curl specific tests
|
||||||
|
foreach(CURL_TEST
|
||||||
|
HAVE_FCNTL_O_NONBLOCK
|
||||||
|
HAVE_IOCTLSOCKET
|
||||||
|
HAVE_IOCTLSOCKET_CAMEL
|
||||||
|
HAVE_IOCTLSOCKET_CAMEL_FIONBIO
|
||||||
|
HAVE_IOCTLSOCKET_FIONBIO
|
||||||
|
HAVE_IOCTL_FIONBIO
|
||||||
|
HAVE_IOCTL_SIOCGIFADDR
|
||||||
|
HAVE_SETSOCKOPT_SO_NONBLOCK
|
||||||
|
HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||||
|
TIME_WITH_SYS_TIME
|
||||||
|
HAVE_O_NONBLOCK
|
||||||
|
HAVE_GETHOSTBYADDR_R_5
|
||||||
|
HAVE_GETHOSTBYADDR_R_7
|
||||||
|
HAVE_GETHOSTBYADDR_R_8
|
||||||
|
HAVE_GETHOSTBYADDR_R_5_REENTRANT
|
||||||
|
HAVE_GETHOSTBYADDR_R_7_REENTRANT
|
||||||
|
HAVE_GETHOSTBYADDR_R_8_REENTRANT
|
||||||
|
HAVE_GETHOSTBYNAME_R_3
|
||||||
|
HAVE_GETHOSTBYNAME_R_5
|
||||||
|
HAVE_GETHOSTBYNAME_R_6
|
||||||
|
HAVE_GETHOSTBYNAME_R_3_REENTRANT
|
||||||
|
HAVE_GETHOSTBYNAME_R_5_REENTRANT
|
||||||
|
HAVE_GETHOSTBYNAME_R_6_REENTRANT
|
||||||
|
HAVE_SOCKLEN_T
|
||||||
|
HAVE_IN_ADDR_T
|
||||||
|
HAVE_BOOL_T
|
||||||
|
STDC_HEADERS
|
||||||
|
RETSIGTYPE_TEST
|
||||||
|
HAVE_INET_NTOA_R_DECL
|
||||||
|
HAVE_INET_NTOA_R_DECL_REENTRANT
|
||||||
|
HAVE_GETADDRINFO
|
||||||
|
HAVE_FILE_OFFSET_BITS
|
||||||
|
)
|
||||||
|
curl_internal_test(${CURL_TEST})
|
||||||
|
endforeach(CURL_TEST)
|
||||||
|
if(HAVE_FILE_OFFSET_BITS)
|
||||||
|
set(_FILE_OFFSET_BITS 64)
|
||||||
|
endif(HAVE_FILE_OFFSET_BITS)
|
||||||
|
foreach(CURL_TEST
|
||||||
|
HAVE_GLIBC_STRERROR_R
|
||||||
|
HAVE_POSIX_STRERROR_R
|
||||||
|
)
|
||||||
|
curl_internal_test_run(${CURL_TEST})
|
||||||
|
endforeach(CURL_TEST)
|
||||||
|
|
||||||
|
# Check for reentrant
|
||||||
|
foreach(CURL_TEST
|
||||||
|
HAVE_GETHOSTBYADDR_R_5
|
||||||
|
HAVE_GETHOSTBYADDR_R_7
|
||||||
|
HAVE_GETHOSTBYADDR_R_8
|
||||||
|
HAVE_GETHOSTBYNAME_R_3
|
||||||
|
HAVE_GETHOSTBYNAME_R_5
|
||||||
|
HAVE_GETHOSTBYNAME_R_6
|
||||||
|
HAVE_INET_NTOA_R_DECL_REENTRANT)
|
||||||
|
if(NOT ${CURL_TEST})
|
||||||
|
if(${CURL_TEST}_REENTRANT)
|
||||||
|
set(NEED_REENTRANT 1)
|
||||||
|
endif(${CURL_TEST}_REENTRANT)
|
||||||
|
endif(NOT ${CURL_TEST})
|
||||||
|
endforeach(CURL_TEST)
|
||||||
|
|
||||||
|
if(NEED_REENTRANT)
|
||||||
|
foreach(CURL_TEST
|
||||||
|
HAVE_GETHOSTBYADDR_R_5
|
||||||
|
HAVE_GETHOSTBYADDR_R_7
|
||||||
|
HAVE_GETHOSTBYADDR_R_8
|
||||||
|
HAVE_GETHOSTBYNAME_R_3
|
||||||
|
HAVE_GETHOSTBYNAME_R_5
|
||||||
|
HAVE_GETHOSTBYNAME_R_6)
|
||||||
|
set(${CURL_TEST} 0)
|
||||||
|
if(${CURL_TEST}_REENTRANT)
|
||||||
|
set(${CURL_TEST} 1)
|
||||||
|
endif(${CURL_TEST}_REENTRANT)
|
||||||
|
endforeach(CURL_TEST)
|
||||||
|
endif(NEED_REENTRANT)
|
||||||
|
|
||||||
|
if(HAVE_INET_NTOA_R_DECL_REENTRANT)
|
||||||
|
set(HAVE_INET_NTOA_R_DECL 1)
|
||||||
|
set(NEED_REENTRANT 1)
|
||||||
|
endif(HAVE_INET_NTOA_R_DECL_REENTRANT)
|
||||||
|
|
||||||
|
# Some other minor tests
|
||||||
|
|
||||||
|
if(NOT HAVE_IN_ADDR_T)
|
||||||
|
set(in_addr_t "unsigned long")
|
||||||
|
endif(NOT HAVE_IN_ADDR_T)
|
||||||
|
|
||||||
|
# Fix libz / zlib.h
|
||||||
|
|
||||||
|
if(NOT CURL_SPECIAL_LIBZ)
|
||||||
|
if(NOT HAVE_LIBZ)
|
||||||
|
set(HAVE_ZLIB_H 0)
|
||||||
|
endif(NOT HAVE_LIBZ)
|
||||||
|
|
||||||
|
if(NOT HAVE_ZLIB_H)
|
||||||
|
set(HAVE_LIBZ 0)
|
||||||
|
endif(NOT HAVE_ZLIB_H)
|
||||||
|
endif(NOT CURL_SPECIAL_LIBZ)
|
||||||
|
|
||||||
|
if(_FILE_OFFSET_BITS)
|
||||||
|
set(_FILE_OFFSET_BITS 64)
|
||||||
|
endif(_FILE_OFFSET_BITS)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/curl/curl.h")
|
||||||
|
check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Check for nonblocking
|
||||||
|
set(HAVE_DISABLED_NONBLOCKING 1)
|
||||||
|
if(HAVE_FIONBIO OR
|
||||||
|
HAVE_IOCTLSOCKET OR
|
||||||
|
HAVE_IOCTLSOCKET_CASE OR
|
||||||
|
HAVE_O_NONBLOCK)
|
||||||
|
set(HAVE_DISABLED_NONBLOCKING)
|
||||||
|
endif(HAVE_FIONBIO OR
|
||||||
|
HAVE_IOCTLSOCKET OR
|
||||||
|
HAVE_IOCTLSOCKET_CASE OR
|
||||||
|
HAVE_O_NONBLOCK)
|
||||||
|
|
||||||
|
if(RETSIGTYPE_TEST)
|
||||||
|
set(RETSIGTYPE void)
|
||||||
|
else(RETSIGTYPE_TEST)
|
||||||
|
set(RETSIGTYPE int)
|
||||||
|
endif(RETSIGTYPE_TEST)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
check_c_compiler_flag(-Wno-long-double HAVE_C_FLAG_Wno_long_double)
|
||||||
|
if(HAVE_C_FLAG_Wno_long_double)
|
||||||
|
# The Mac version of GCC warns about use of long double. Disable it.
|
||||||
|
get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
|
||||||
|
if(MPRINTF_COMPILE_FLAGS)
|
||||||
|
set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
|
||||||
|
else(MPRINTF_COMPILE_FLAGS)
|
||||||
|
set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
|
||||||
|
endif(MPRINTF_COMPILE_FLAGS)
|
||||||
|
set_source_files_properties(mprintf.c PROPERTIES
|
||||||
|
COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
|
||||||
|
endif(HAVE_C_FLAG_Wno_long_double)
|
||||||
|
endif(CMAKE_COMPILER_IS_GNUCC AND APPLE)
|
||||||
|
|
||||||
|
if(HAVE_SOCKLEN_T)
|
||||||
|
set(CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t")
|
||||||
|
check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
|
||||||
|
if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(CURL_TYPEOF_CURL_SOCKLEN_T int)
|
||||||
|
set(CURL_SIZEOF_CURL_SOCKLEN_T ${SIZEOF_INT})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMake/OtherTests.cmake)
|
||||||
|
|
||||||
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|
||||||
|
# For windows, do not allow the compiler to use default target (Vista).
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-D_WIN32_WINNT=0x0501)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
|
# Sets up the dependencies (zlib, OpenSSL, etc.) of a cURL subproject according to options.
|
||||||
|
# TODO This is far to be complete!
|
||||||
|
function(SETUP_CURL_DEPENDENCIES TARGET_NAME)
|
||||||
|
if(CURL_ZLIB AND ZLIB_FOUND)
|
||||||
|
include_directories(${ZLIB_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
if(CURL_ZLIB AND ZLIB_FOUND)
|
||||||
|
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
|
||||||
|
#ADD_DEFINITIONS( -DHAVE_ZLIB_H -DHAVE_ZLIB -DHAVE_LIBZ )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
|
||||||
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
if(CMAKE_USE_OPENSSL AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||||
|
target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES})
|
||||||
|
#ADD_DEFINITIONS( -DUSE_SSLEAY )
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
|
||||||
|
function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
|
||||||
|
file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
|
||||||
|
string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
|
||||||
|
string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
|
||||||
|
|
||||||
|
string(REGEX REPLACE "\\\\\n" "<22>!<21>" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
|
||||||
|
string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*\n)" "SET(\\1 \\2)\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
|
||||||
|
string(REPLACE "<22>!<21>" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
|
||||||
|
|
||||||
|
string(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace $() with ${}
|
||||||
|
string(REGEX REPLACE "@([a-zA-Z_][a-zA-Z0-9_]*)@" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace @@ with ${}, even if that may not be read by CMake scripts.
|
||||||
|
file(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
|
if(BUILD_CURL_EXE)
|
||||||
|
add_subdirectory(src)
|
||||||
|
endif()
|
||||||
|
if(BUILD_CURL_TESTS)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# This needs to be run very last so other parts of the scripts can take advantage of this.
|
||||||
|
if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||||
|
set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
|
||||||
|
endif()
|
||||||
2
COPYING
2
COPYING
@@ -1,6 +1,6 @@
|
|||||||
COPYRIGHT AND PERMISSION NOTICE
|
COPYRIGHT AND PERMISSION NOTICE
|
||||||
|
|
||||||
Copyright (c) 1996 - 2009, Daniel Stenberg, <daniel@haxx.se>.
|
Copyright (c) 1996 - 2010, Daniel Stenberg, <daniel@haxx.se>.
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
|||||||
13
CTestConfig.cmake
Normal file
13
CTestConfig.cmake
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## This file should be placed in the root directory of your project.
|
||||||
|
## Then modify the CMakeLists.txt file in the root directory of your
|
||||||
|
## project to incorporate the testing dashboard.
|
||||||
|
## # The following are required to uses Dart and the Cdash dashboard
|
||||||
|
## ENABLE_TESTING()
|
||||||
|
## INCLUDE(Dart)
|
||||||
|
set(CTEST_PROJECT_NAME "CURL")
|
||||||
|
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
|
||||||
|
|
||||||
|
set(CTEST_DROP_METHOD "http")
|
||||||
|
set(CTEST_DROP_SITE "my.cdash.org")
|
||||||
|
set(CTEST_DROP_LOCATION "/submit.php?project=CURL")
|
||||||
|
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
_ _ ____ _
|
_ _ ____ _
|
||||||
___| | | | _ \| |
|
___| | | | _ \| |
|
||||||
/ __| | | | |_) | |
|
/ __| | | | |_) | |
|
||||||
| (__| |_| | _ <| |___
|
| (__| |_| | _ <| |___
|
||||||
\___|\___/|_| \_\_____|
|
\___|\___/|_| \_\_____|
|
||||||
|
|
||||||
CVS-INFO
|
GIT-INFO
|
||||||
|
|
||||||
This file is only present in the CVS - never in release archives. It contains
|
This file is only present in git - never in release archives. It contains
|
||||||
information about other files and things that the CVS repository keeps in its
|
information about other files and things that the git repository keeps in its
|
||||||
inner sanctum.
|
inner sanctum.
|
||||||
|
|
||||||
Compile and build instructions follow below.
|
Compile and build instructions follow below.
|
||||||
@@ -20,7 +20,7 @@ Compile and build instructions follow below.
|
|||||||
perl/ is a subdirectory with various perl scripts
|
perl/ is a subdirectory with various perl scripts
|
||||||
|
|
||||||
To build in environments that support configure, after having extracted
|
To build in environments that support configure, after having extracted
|
||||||
everything from CVS, do this:
|
everything from git, do this:
|
||||||
|
|
||||||
./buildconf
|
./buildconf
|
||||||
./configure
|
./configure
|
||||||
@@ -63,5 +63,5 @@ MAC OS X
|
|||||||
3. Install the latest version of autoconf, automake and m4 with fink
|
3. Install the latest version of autoconf, automake and m4 with fink
|
||||||
4. Install version 1.4.1 of libtool - you find it in the "unstable" section
|
4. Install version 1.4.1 of libtool - you find it in the "unstable" section
|
||||||
(read the manual to see how to get unstable versions)
|
(read the manual to see how to get unstable versions)
|
||||||
5. Get cURL from the cvs
|
5. Get cURL from git
|
||||||
6. Build cURL with "./buildconf", "./configure", "make", "sudo make install"
|
6. Build cURL with "./buildconf", "./configure", "make", "sudo make install"
|
||||||
@@ -1,49 +1,78 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This script performs all of the steps needed to build a 32 bit
|
# This script performs all of the steps needed to build a
|
||||||
# universal binary libcurl.framework for Mac OS X 10.4 or greater.
|
# universal binary libcurl.framework for Mac OS X 10.4 or greater.
|
||||||
|
|
||||||
VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`
|
VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`
|
||||||
|
|
||||||
SDK='/Developer/SDKs/MacOSX10.4u.sdk'
|
SDK32='/Developer/SDKs/MacOSX10.4u.sdk'
|
||||||
|
|
||||||
MINVER='-mmacosx-version-min=10.4'
|
MINVER32='-mmacosx-version-min=10.4'
|
||||||
|
|
||||||
ARCHES='-arch ppc -arch i386'
|
ARCHES32='-arch ppc -arch i386'
|
||||||
|
|
||||||
# Use these values instead to produce a 64 bit framework that only works on 10.5.
|
SDK64='/Developer/SDKs/MacOSX10.5.sdk'
|
||||||
# You can't currently build a combined 32/64 framework.
|
|
||||||
#SDK='/Developer/SDKs/MacOSX10.5.sdk'
|
|
||||||
#
|
|
||||||
#MINVER='-mmacosx-version-min=10.5'
|
|
||||||
#
|
|
||||||
#ARCHES='-arch ppc64 -arch x86_64'
|
|
||||||
|
|
||||||
|
MINVER64='-mmacosx-version-min=10.5'
|
||||||
|
|
||||||
if test -d $SDK; then
|
ARCHES64='-arch ppc64 -arch x86_64'
|
||||||
echo "Configuring libcurl for 32 bit universal framework..."
|
|
||||||
|
if test -d $SDK32; then
|
||||||
|
echo "----Configuring libcurl for 32 bit universal framework..."
|
||||||
./configure --disable-dependency-tracking --disable-static --with-gssapi \
|
./configure --disable-dependency-tracking --disable-static --with-gssapi \
|
||||||
CFLAGS="-isysroot $SDK $ARCHES $MINVER" \
|
CFLAGS="-Os -isysroot $SDK32 $ARCHES32 $MINVER32" \
|
||||||
LDFLAGS="-Wl,-syslibroot,$SDK $ARCHES $MINVER -Wl,-headerpad_max_install_names"
|
LDFLAGS="-Wl,-syslibroot,$SDK32 $ARCHES32 $MINVER32 -Wl,-headerpad_max_install_names" \
|
||||||
|
CC=$CC
|
||||||
echo "Building libcurl..."
|
|
||||||
|
echo "----Building 32 bit libcurl..."
|
||||||
make
|
make
|
||||||
|
|
||||||
echo "Creating framework..."
|
echo "----Creating 32 bit framework..."
|
||||||
rm -r libcurl.framework
|
rm -r libcurl.framework
|
||||||
mkdir -p libcurl.framework/Versions/A/Resources
|
mkdir -p libcurl.framework/Versions/A/Resources
|
||||||
cp lib/.libs/libcurl.dylib libcurl.framework/Versions/A/libcurl
|
cp lib/.libs/libcurl.dylib libcurl.framework/Versions/A/libcurl
|
||||||
install_name_tool -id @executable_path/../Frameworks/libcurl.framework/Versions/A/libcurl libcurl.framework/Versions/A/libcurl
|
install_name_tool -id @executable_path/../Frameworks/libcurl.framework/Versions/A/libcurl libcurl.framework/Versions/A/libcurl
|
||||||
/usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/Versions/A/Resources/Info.plist
|
/usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/Versions/A/Resources/Info.plist
|
||||||
mkdir -p libcurl.framework/Versions/A/Headers
|
mkdir -p libcurl.framework/Versions/A/Headers/curl
|
||||||
cp include/curl/*.h libcurl.framework/Versions/A/Headers
|
cp include/curl/*.h libcurl.framework/Versions/A/Headers/curl
|
||||||
cd libcurl.framework
|
pushd libcurl.framework
|
||||||
ln -fs Versions/A/libcurl libcurl
|
ln -fs Versions/A/libcurl libcurl
|
||||||
ln -fs Versions/A/Resources Resources
|
ln -fs Versions/A/Resources Resources
|
||||||
ln -fs Versions/A/Headers Headers
|
ln -fs Versions/A/Headers Headers
|
||||||
cd Versions
|
cd Versions
|
||||||
ln -fs A Current
|
ln -fs A Current
|
||||||
|
|
||||||
|
if test -d $SDK64; then
|
||||||
|
popd
|
||||||
|
make clean
|
||||||
|
echo "----Configuring libcurl for 64 bit universal framework..."
|
||||||
|
./configure --disable-dependency-tracking --disable-static --with-gssapi \
|
||||||
|
CFLAGS="-Os -isysroot $SDK64 $ARCHES64 $MINVER64" \
|
||||||
|
LDFLAGS="-Wl,-syslibroot,$SDK64 $ARCHES64 $MINVER64 -Wl,-headerpad_max_install_names" \
|
||||||
|
CC=$CC
|
||||||
|
|
||||||
|
echo "----Building 64 bit libcurl..."
|
||||||
|
make
|
||||||
|
|
||||||
|
echo "----Appending 64 bit framework to 32 bit framework..."
|
||||||
|
cp lib/.libs/libcurl.dylib libcurl.framework/Versions/A/libcurl64
|
||||||
|
install_name_tool -id @executable_path/../Frameworks/libcurl.framework/Versions/A/libcurl libcurl.framework/Versions/A/libcurl64
|
||||||
|
cp libcurl.framework/Versions/A/libcurl libcurl.framework/Versions/A/libcurl32
|
||||||
|
lipo libcurl.framework/Versions/A/libcurl32 libcurl.framework/Versions/A/libcurl64 -create -output libcurl.framework/Versions/A/libcurl
|
||||||
|
rm libcurl.framework/Versions/A/libcurl32 libcurl.framework/Versions/A/libcurl64
|
||||||
|
cp libcurl.framework/Versions/A/Headers/curl/curlbuild.h libcurl.framework/Versions/A/Headers/curl/curlbuild32.h
|
||||||
|
cp include/curl/curlbuild.h libcurl.framework/Versions/A/Headers/curl/curlbuild64.h
|
||||||
|
cat >libcurl.framework/Versions/A/Headers/curl/curlbuild.h <<EOF
|
||||||
|
#ifdef __LP64__
|
||||||
|
#include "curl/curlbuild64.h"
|
||||||
|
#else
|
||||||
|
#include "curl/curlbuild32.h"
|
||||||
|
#endif
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
lipo -info libcurl.framework/Versions/A/libcurl
|
||||||
echo "libcurl.framework is built and can now be included in other projects."
|
echo "libcurl.framework is built and can now be included in other projects."
|
||||||
|
echo "Copy libcurl.framework to your bundle's Contents/Frameworks folder, ~/Library/Frameworks or /Library/Frameworks."
|
||||||
else
|
else
|
||||||
echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4u SDK installed."
|
echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4u SDK installed."
|
||||||
fi
|
fi
|
||||||
|
|||||||
15
Makefile.am
15
Makefile.am
@@ -18,16 +18,21 @@
|
|||||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
# KIND, either express or implied.
|
# KIND, either express or implied.
|
||||||
#
|
#
|
||||||
# $Id$
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = foreign
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in \
|
CMAKE_DIST = CMakeLists.txt CMake/CheckTypeSize.c.in CMake/CheckTypeSize.cmake \
|
||||||
curl-style.el sample.emacs RELEASE-NOTES buildconf buildconf.bat \
|
CMake/CMakeConfigurableFile.in CMake/CurlCheckCSourceCompiles.cmake \
|
||||||
libcurl.pc.in vc6curl.dsw MacOSX-Framework
|
CMake/CurlCheckCSourceRuns.cmake CMake/CurlTests.c CMake/FindOpenSSL.cmake \
|
||||||
|
CMake/FindZLIB.cmake CMake/OtherTests.cmake CMake/Platforms/WindowsCache.cmake \
|
||||||
|
CMake/Utilities.cmake include/curl/curlbuild.h.cmake
|
||||||
|
|
||||||
|
EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in \
|
||||||
|
curl-style.el sample.emacs RELEASE-NOTES buildconf \
|
||||||
|
libcurl.pc.in vc6curl.dsw MacOSX-Framework Android.mk $(CMAKE_DIST)
|
||||||
|
|
||||||
bin_SCRIPTS = curl-config
|
bin_SCRIPTS = curl-config
|
||||||
|
|
||||||
@@ -40,7 +45,7 @@ pkgconfig_DATA = libcurl.pc
|
|||||||
dist-hook:
|
dist-hook:
|
||||||
rm -rf $(top_builddir)/tests/log
|
rm -rf $(top_builddir)/tests/log
|
||||||
find $(distdir) -name "*.dist" -exec rm {} \;
|
find $(distdir) -name "*.dist" -exec rm {} \;
|
||||||
(distit=`find $(srcdir) -name "*.dist"`; \
|
(distit=`find $(srcdir) -name "*.dist" | grep -v ./ares/`; \
|
||||||
for file in $$distit; do \
|
for file in $$distit; do \
|
||||||
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
|
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
|
||||||
cp $$file $(distdir)$$strip; \
|
cp $$file $(distdir)$$strip; \
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
# KIND, either express or implied.
|
# KIND, either express or implied.
|
||||||
#
|
#
|
||||||
# $Id$
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
VC=vc6
|
VC=vc6
|
||||||
@@ -130,9 +129,9 @@ vc:
|
|||||||
|
|
||||||
vc-x64:
|
vc-x64:
|
||||||
cd lib
|
cd lib
|
||||||
MACHINE=x64 nmake /f Makefile.$(VC) cfg=release
|
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release
|
||||||
cd ..\src
|
cd ..\src
|
||||||
MACHINE=x64 nmake /f Makefile.$(VC)
|
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release
|
||||||
|
|
||||||
vc-zlib:
|
vc-zlib:
|
||||||
cd lib
|
cd lib
|
||||||
@@ -152,6 +151,12 @@ vc-ssl-zlib:
|
|||||||
cd ..\src
|
cd ..\src
|
||||||
nmake /f Makefile.$(VC) cfg=release-ssl-zlib
|
nmake /f Makefile.$(VC) cfg=release-ssl-zlib
|
||||||
|
|
||||||
|
vc-x64-ssl-zlib:
|
||||||
|
cd lib
|
||||||
|
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-ssl-zlib
|
||||||
|
cd ..\src
|
||||||
|
nmake /f Makefile.$(VC) MACHINE=x64 cfg=release-ssl-zlib
|
||||||
|
|
||||||
vc-ssl-dll:
|
vc-ssl-dll:
|
||||||
cd lib
|
cd lib
|
||||||
nmake /f Makefile.$(VC) cfg=release-ssl-dll
|
nmake /f Makefile.$(VC) cfg=release-ssl-dll
|
||||||
@@ -257,15 +262,25 @@ linux: all
|
|||||||
linux-ssl: ssl
|
linux-ssl: ssl
|
||||||
|
|
||||||
|
|
||||||
vc8:
|
vc8: lib/Makefile.vc8 src/Makefile.vc8
|
||||||
@echo "generate VC8 makefiles"
|
|
||||||
|
lib/Makefile.vc8: lib/Makefile.vc6
|
||||||
|
@echo "generate $@"
|
||||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/wsock32.lib bufferoverflowu.lib/g" -e "s/VC6/VC8/g" lib/Makefile.vc6 > lib/Makefile.vc8
|
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/wsock32.lib bufferoverflowu.lib/g" -e "s/VC6/VC8/g" lib/Makefile.vc6 > lib/Makefile.vc8
|
||||||
|
|
||||||
|
src/Makefile.vc8: src/Makefile.vc6
|
||||||
|
@echo "generate $@"
|
||||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/wsock32.lib bufferoverflowu.lib/g" -e "s/VC6/VC8/g" src/Makefile.vc6 > src/Makefile.vc8
|
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/wsock32.lib bufferoverflowu.lib/g" -e "s/VC6/VC8/g" src/Makefile.vc6 > src/Makefile.vc8
|
||||||
|
|
||||||
# VC9 makefiles are for use with VS2008
|
# VC9 makefiles are for use with VS2008
|
||||||
vc9:
|
vc9: lib/Makefile.vc9 src/Makefile.vc9
|
||||||
@echo "generate VC9 makefiles"
|
|
||||||
|
lib/Makefile.vc9: lib/Makefile.vc6
|
||||||
|
@echo "generate $@"
|
||||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/ws2_32.lib/g" -e "s/vc6/vc9/g" -e "s/VC6/VC9/g" lib/Makefile.vc6 > lib/Makefile.vc9
|
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/ws2_32.lib/g" -e "s/vc6/vc9/g" -e "s/VC6/VC9/g" lib/Makefile.vc6 > lib/Makefile.vc9
|
||||||
|
|
||||||
|
src/Makefile.vc9: src/Makefile.vc6
|
||||||
|
@echo "generate $@"
|
||||||
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/ws2_32.lib/g" -e "s/vc6/vc9/g" -e "s/VC6/VC9/g" src/Makefile.vc6 > src/Makefile.vc9
|
@sed -e "s#/GX /DWIN32 /YX#/EHsc /DWIN32#" -e "s#/GZ#/RTC1#" -e "s/wsock32.lib/ws2_32.lib/g" -e "s/vc6/vc9/g" -e "s/VC6/VC9/g" src/Makefile.vc6 > src/Makefile.vc9
|
||||||
|
|
||||||
ca-bundle: lib/mk-ca-bundle.pl
|
ca-bundle: lib/mk-ca-bundle.pl
|
||||||
|
|||||||
10
README
10
README
@@ -34,15 +34,11 @@ WEB SITE
|
|||||||
|
|
||||||
http://curl.haxx.se/
|
http://curl.haxx.se/
|
||||||
|
|
||||||
CVS
|
GIT
|
||||||
|
|
||||||
To download the very latest source off the CVS server do this:
|
To download the very latest source off the GIT server do this:
|
||||||
|
|
||||||
cvs -d :pserver:anonymous@cool.haxx.se:/cvsroot/curl login
|
git clone git://github.com/bagder/curl.git
|
||||||
|
|
||||||
(just press enter when asked for password)
|
|
||||||
|
|
||||||
cvs -d :pserver:anonymous@cool.haxx.se:/cvsroot/curl co curl
|
|
||||||
|
|
||||||
(you'll get a directory named curl created, filled with the source code)
|
(you'll get a directory named curl created, filled with the source code)
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +1,51 @@
|
|||||||
Curl and libcurl 7.19.4
|
Curl and libcurl 7.20.1
|
||||||
|
|
||||||
Public curl releases: 110
|
Public curl releases: 115
|
||||||
Command line options: 132
|
Command line options: 136
|
||||||
curl_easy_setopt() options: 163
|
curl_easy_setopt() options: 174
|
||||||
Public functions in libcurl: 58
|
Public functions in libcurl: 58
|
||||||
Known libcurl bindings: 38
|
Known libcurl bindings: 39
|
||||||
Contributors: 700
|
Contributors: 776
|
||||||
|
|
||||||
This release includes the following security-related fix:
|
|
||||||
|
|
||||||
o CVE-2009-0037 with the curl advisory here:
|
|
||||||
http://curl.haxx.se/docs/adv_20090303.html
|
|
||||||
|
|
||||||
This release includes the following changes:
|
This release includes the following changes:
|
||||||
|
|
||||||
o Added CURLOPT_NOPROXY and the corresponding --noproxy
|
o The 'ares' subtree has been removed from the source repository
|
||||||
o the OpenSSL-specific code disables TICKET (rfc5077) which is enabled by
|
o smoother rate limiting
|
||||||
default in openssl 0.9.8j
|
o allow user+password in the URL for all protocols
|
||||||
o Added CURLOPT_TFTP_BLKSIZE
|
o POP3: Get message listing if no mailbox in URL
|
||||||
o Added CURLOPT_SOCKS5_GSSAPI_SERVICE and CURLOPT_SOCKS5_GSSAPI_NEC - with
|
|
||||||
the corresponding curl options --socks5-gssapi-service and
|
|
||||||
--socks5-gssapi-nec
|
|
||||||
o Improved IPv6 support when built with with c-ares >= 1.6.1
|
|
||||||
o Added CURLPROXY_HTTP_1_0 and --proxy1.0
|
|
||||||
o Added docs/libcurl/symbols-in-versions
|
|
||||||
o Added CURLINFO_CONDITION_UNMET
|
|
||||||
o Added support for Digest and NTLM authentication using GnuTLS
|
|
||||||
o CURLOPT_FTP_CREATE_MISSING_DIRS can now be set to 2 to retry the CWD even
|
|
||||||
when MKD fails
|
|
||||||
o GnuTLS initing moved to curl_global_init()
|
|
||||||
o Added CURLOPT_REDIR_PROTOCOLS and CURLOPT_PROTOCOLS
|
|
||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
o missing ssh.obj in VS makefiles
|
o VMS builder bad behavior when used in a batch job
|
||||||
o FTP ;type=i URLs now work with CURLOPT_PROXY_TRANSFER_MODE in Turkish
|
o multiple recepients with SMTP
|
||||||
locale
|
o fixed the CURL_FORMAT_* defines when building with cmake
|
||||||
o realms with quoted quotation marks in HTTP Digest headers
|
o missing quote in libcurl.m4
|
||||||
o VC9 makefiles are now really included
|
o SMTP: now waits for 250 after the DATA transfer
|
||||||
o multi interface memory leak with CURLMOPT_MAXCONNECTS set
|
o SMTP: use angle brackets in RCPT TO
|
||||||
o CURLINFO_CONTENT_LENGTH_DOWNLOAD size from file:// "transfers" with
|
o curl --trace-time not using local time
|
||||||
CURLOPT_NOBODY set true
|
o off-by-one in the chunked encoding trailer parser
|
||||||
o memory leak on some libz errors for content encodings
|
o superfluous blocking for OpenSSL-based SSL connects and multi interface
|
||||||
o NSS-enabled build is repaired
|
o TFTP upload
|
||||||
o superfluous wait in SFTP downloads removed
|
o FTP timeouts after file transferred completely
|
||||||
o FTP with the multi interface no longer kills the control connection as
|
o skip poll() on Interix
|
||||||
easily on transfer failures
|
o CURLOPT_CERTINFO memory leak
|
||||||
o compilation halting when using VS2008 to build a Windows 2000 target
|
o sub-second timeouts improvements
|
||||||
o ease creation of libcurl Mac OS X Framework
|
o configure fixes for GSSAPI
|
||||||
o CURLINFO_CONTENT_LENGTH_DOWNLOAD and CURLINFO_CONTENT_LENGTH_UPLOAD are -1
|
o threaded resolver double free when closing curl handle
|
||||||
if unknown
|
o configure fixes for building with the clang compiler
|
||||||
o Negotiate proxy authentication
|
o easy interix rate limiting logic
|
||||||
o CURLOPT_INTERFACE and CURLOPT_LOCALPORT used together
|
o curl_multi_remove_handle() caused use after free
|
||||||
|
o TFTP improved error codes
|
||||||
|
o TFTP fixed TSIZE handling for uploads
|
||||||
|
o SSL possible double free when reusing curl handle
|
||||||
|
o alarm()-based DNS timeout bug
|
||||||
|
o re-used FTP connection multi interface crash
|
||||||
|
o chunked-encoding with Content-Length: header problem
|
||||||
|
o multi interface HTTP POST over a proxy using PROXYTUNNEL
|
||||||
|
o RTSP GET_PARAMETER
|
||||||
|
o timeout after last data chunk was handled
|
||||||
|
o SFTP download hang
|
||||||
|
o FTP quote commands prefixed with '*' now can fail without aborting
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
@@ -60,11 +54,11 @@ This release includes the following known bugs:
|
|||||||
This release would not have looked like this without help, code, reports and
|
This release would not have looked like this without help, code, reports and
|
||||||
advice from friends like these:
|
advice from friends like these:
|
||||||
|
|
||||||
Lisa Xu, Daniel Fandrich, Craig A West, Alexey Borzov, Sharad Gupta,
|
Steven M. Schweda, Yang Tse, Jack Zhang, Tom Donovan, Martin Hager,
|
||||||
Peter Sylvester, Chad Monroe, Markus Moeller, Yang Tse, Scott Cantor,
|
Daniel Fandrich, Patrick Monnerat, Pat Ray, Wesley Miaw, Ben Greear,
|
||||||
Patrick Scott, Hidemoto Nakada, Jocelyn Jaubert, Andre Guibert de Bruet,
|
Ryan Chan, Markus Duft, Andrei Benea, Jacob Moshenko, Daniel Johnson,
|
||||||
Kamil Dudka, Patrik Thunstrom, Linus Nielsen Feltzing, Mark Incley,
|
Constantine Sapuntzakis, Douglas Steinwand, Thomas Lopatic, Hauke Duden,
|
||||||
Daniel Johnson, James Cheng, Brian J. Murrell, Senthil Raja Velu,
|
Akos Pasztory, Kenny To, Christopher Conroy, Massimo Callegari,
|
||||||
Markus Koetter, David Kierznowski, Michal Marek
|
Bob Richmond, Matt Wixson
|
||||||
|
|
||||||
Thanks! (and sorry if I forgot to mention someone)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
|||||||
11
TODO-RELEASE
11
TODO-RELEASE
@@ -1,11 +1,4 @@
|
|||||||
To be addressed in 7.19.5 (planned release: May 2009)
|
To be addressed in 7.20.1 (planned release: April 2010)
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
216 - Markus Moeller's "proxy question" to reverse lookup SOCKS proxys and more
|
261 -
|
||||||
|
|
||||||
215 - Patch for Metalink Support (for the curl tool)
|
|
||||||
|
|
||||||
220 - Take advantage of libssh2_version() that's been added for the upcoming
|
|
||||||
1.1, to extract the run-time version number properly.
|
|
||||||
|
|
||||||
221 -
|
|
||||||
|
|||||||
625
acinclude.m4
625
acinclude.m4
@@ -5,7 +5,7 @@
|
|||||||
# | (__| |_| | _ <| |___
|
# | (__| |_| | _ <| |___
|
||||||
# \___|\___/|_| \_\_____|
|
# \___|\___/|_| \_\_____|
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
#
|
#
|
||||||
# This software is licensed as described in the file COPYING, which
|
# This software is licensed as described in the file COPYING, which
|
||||||
# you should have received as part of this distribution. The terms
|
# you should have received as part of this distribution. The terms
|
||||||
@@ -18,57 +18,9 @@
|
|||||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
# KIND, either express or implied.
|
# KIND, either express or implied.
|
||||||
#
|
#
|
||||||
# $Id$
|
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Verifies if the compiler actually halts after the
|
|
||||||
dnl compilation phase without generating any object
|
|
||||||
dnl code file, when the source compiles with errors.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
|
|
||||||
AC_MSG_CHECKING([if compiler halts on compilation errors])
|
|
||||||
AC_COMPILE_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
]],[[
|
|
||||||
force compilation error
|
|
||||||
]])
|
|
||||||
],[
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
AC_MSG_ERROR([compiler does not halt on compilation errors.])
|
|
||||||
],[
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Verifies if the compiler actually halts after the
|
|
||||||
dnl compilation phase without generating any object
|
|
||||||
dnl code file, when the source code tries to define a
|
|
||||||
dnl type for a constant array with negative dimension.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
|
|
||||||
AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
|
|
||||||
AC_MSG_CHECKING([if compiler halts on negative sized arrays])
|
|
||||||
AC_COMPILE_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
|
|
||||||
]],[[
|
|
||||||
bad_t dummy;
|
|
||||||
]])
|
|
||||||
],[
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
|
|
||||||
],[
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
|
dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Use the C preprocessor to find out if the given object-style symbol
|
dnl Use the C preprocessor to find out if the given object-style symbol
|
||||||
@@ -118,6 +70,72 @@ CURL_DEF_TOKEN $1
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Use the C compiler to find out only if the given symbol is defined
|
||||||
|
dnl or not, this can not find out its expansion. This macro will not use
|
||||||
|
dnl default includes even if no INCLUDES argument is given. This macro
|
||||||
|
dnl will run silently when invoked with three arguments.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CHECK_DEF_CC], [
|
||||||
|
AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
|
||||||
|
ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_SOURCE(
|
||||||
|
ifelse($2,,,[$2])[[
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
#ifdef $1
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
force compilation error
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
tst_symbol_defined="yes"
|
||||||
|
],[
|
||||||
|
tst_symbol_defined="no"
|
||||||
|
])
|
||||||
|
if test "$tst_symbol_defined" = "yes"; then
|
||||||
|
AS_VAR_SET(ac_HaveDef, yes)
|
||||||
|
ifelse($3,,[AC_MSG_RESULT([yes])])
|
||||||
|
else
|
||||||
|
AS_VAR_SET(ac_HaveDef, no)
|
||||||
|
ifelse($3,,[AC_MSG_RESULT([no])])
|
||||||
|
fi
|
||||||
|
AS_VAR_POPDEF([ac_HaveDef])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_CHECK_LIB_XNET
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Verify if X/Open network library is required.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CHECK_LIB_XNET], [
|
||||||
|
AC_MSG_CHECKING([if X/Open network library is required])
|
||||||
|
tst_lib_xnet_required="no"
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_SOURCE([[
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
#if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
|
||||||
|
return 0;
|
||||||
|
#elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
force compilation error
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
tst_lib_xnet_required="yes"
|
||||||
|
LIBS="$LIBS -lxnet"
|
||||||
|
])
|
||||||
|
AC_MSG_RESULT([$tst_lib_xnet_required])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_AIX_ALL_SOURCE
|
dnl CURL_CHECK_AIX_ALL_SOURCE
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Provides a replacement of traditional AC_AIX with
|
dnl Provides a replacement of traditional AC_AIX with
|
||||||
@@ -148,7 +166,7 @@ AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
|
|||||||
|
|
||||||
dnl CURL_CHECK_HEADER_WINDOWS
|
dnl CURL_CHECK_HEADER_WINDOWS
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for compilable and valid windows.h header
|
dnl Check for compilable and valid windows.h header
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
|
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
|
||||||
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
|
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
|
||||||
@@ -221,7 +239,7 @@ AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
|
|||||||
|
|
||||||
dnl CURL_CHECK_HEADER_WINSOCK
|
dnl CURL_CHECK_HEADER_WINSOCK
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for compilable and valid winsock.h header
|
dnl Check for compilable and valid winsock.h header
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
|
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
||||||
@@ -258,7 +276,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
|
|||||||
|
|
||||||
dnl CURL_CHECK_HEADER_WINSOCK2
|
dnl CURL_CHECK_HEADER_WINSOCK2
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for compilable and valid winsock2.h header
|
dnl Check for compilable and valid winsock2.h header
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
|
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
||||||
@@ -893,108 +911,71 @@ AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_TYPE_SOCKLEN_T
|
dnl CURL_CHECK_HEADER_MEMORY
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for existing socklen_t type, and provide
|
dnl Check for compilable and valid memory.h header,
|
||||||
dnl an equivalent type if socklen_t not available
|
dnl and check if it is needed even with stdlib.h for
|
||||||
|
dnl memory related functions.
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
|
AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
|
||||||
AC_CHECK_TYPE([socklen_t], ,[
|
AC_COMPILE_IFELSE([
|
||||||
dnl socklen_t not available
|
AC_LANG_PROGRAM([[
|
||||||
AC_CACHE_CHECK([for socklen_t equivalent],
|
#include <memory.h>
|
||||||
[curl_cv_socklen_t_equiv], [
|
]],[[
|
||||||
curl_cv_socklen_t_equiv="unknown"
|
void *p = malloc(10);
|
||||||
for arg1 in 'int' 'SOCKET'; do
|
void *q = calloc(10,10);
|
||||||
for arg2 in "struct sockaddr" void; do
|
free(p);
|
||||||
for t in int size_t unsigned long "unsigned long"; do
|
free(q);
|
||||||
if test "$curl_cv_socklen_t_equiv" = "unknown"; then
|
]])
|
||||||
AC_COMPILE_IFELSE([
|
],[
|
||||||
AC_LANG_PROGRAM([[
|
ac_cv_header_memory_h="yes"
|
||||||
#undef inline
|
],[
|
||||||
#ifdef HAVE_WINDOWS_H
|
ac_cv_header_memory_h="no"
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
|
||||||
#include <winsock2.h>
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_WINSOCK_H
|
|
||||||
#include <winsock.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#define GETPEERNCALLCONV PASCAL
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#define GETPEERNCALLCONV
|
|
||||||
#endif
|
|
||||||
extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
|
|
||||||
]],[[
|
|
||||||
$t len=0;
|
|
||||||
getpeername(0,0,&len);
|
|
||||||
]])
|
|
||||||
],[
|
|
||||||
curl_cv_socklen_t_equiv="$t"
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
])
|
])
|
||||||
case "$curl_cv_socklen_t_equiv" in
|
])
|
||||||
unknown)
|
if test "$ac_cv_header_memory_h" = "yes"; then
|
||||||
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
|
||||||
;;
|
[Define to 1 if you have the memory.h header file.])
|
||||||
*)
|
#
|
||||||
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
|
AC_COMPILE_IFELSE([
|
||||||
[Type to use in place of socklen_t when system does not provide it.])
|
AC_LANG_PROGRAM([[
|
||||||
|
#include <stdlib.h>
|
||||||
|
]],[[
|
||||||
|
void *p = malloc(10);
|
||||||
|
void *q = calloc(10,10);
|
||||||
|
free(p);
|
||||||
|
free(q);
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
curl_cv_need_header_memory_h="no"
|
||||||
|
],[
|
||||||
|
curl_cv_need_header_memory_h="yes"
|
||||||
|
])
|
||||||
|
#
|
||||||
|
case "$curl_cv_need_header_memory_h" in
|
||||||
|
yes)
|
||||||
|
AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
|
||||||
|
[Define to 1 if you need the memory.h header file even with stdlib.h])
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
],[
|
fi
|
||||||
#undef inline
|
|
||||||
#ifdef HAVE_WINDOWS_H
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
|
||||||
#include <winsock2.h>
|
|
||||||
#ifdef HAVE_WS2TCPIP_H
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
])
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_FUNC_GETNAMEINFO
|
dnl CURL_CHECK_FUNC_GETNAMEINFO
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Test if the getnameinfo function is available,
|
dnl Test if the getnameinfo function is available,
|
||||||
dnl and check the types of five of its arguments.
|
dnl and check the types of five of its arguments.
|
||||||
dnl If the function succeeds HAVE_GETNAMEINFO will be
|
dnl If the function succeeds HAVE_GETNAMEINFO will be
|
||||||
dnl defined, defining the types of the arguments in
|
dnl defined, defining the types of the arguments in
|
||||||
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
|
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
|
||||||
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
|
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
|
||||||
dnl and also defining the type qualifier of first
|
dnl and also defining the type qualifier of first
|
||||||
dnl argument in GETNAMEINFO_QUAL_ARG1.
|
dnl argument in GETNAMEINFO_QUAL_ARG1.
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
|
||||||
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
|
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
|
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
|
||||||
#
|
#
|
||||||
AC_MSG_CHECKING([for getnameinfo])
|
AC_MSG_CHECKING([for getnameinfo])
|
||||||
@@ -1074,7 +1055,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
|||||||
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
|
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1085,7 +1066,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
|||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#ifdef HAVE_WS2TCPIP_H
|
#ifdef HAVE_WS2TCPIP_H
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -1185,7 +1166,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
|||||||
|
|
||||||
dnl TYPE_SOCKADDR_STORAGE
|
dnl TYPE_SOCKADDR_STORAGE
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
||||||
dnl hosts have it, but AIX 4.3 is one known exception.
|
dnl hosts have it, but AIX 4.3 is one known exception.
|
||||||
|
|
||||||
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||||
@@ -1231,7 +1212,7 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
|||||||
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
|
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
|
||||||
netdb.h netinet/in.h arpa/inet.h)
|
netdb.h netinet/in.h arpa/inet.h)
|
||||||
#
|
#
|
||||||
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
||||||
[ac_cv_working_ni_withscopeid], [
|
[ac_cv_working_ni_withscopeid], [
|
||||||
AC_RUN_IFELSE([
|
AC_RUN_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
@@ -1323,11 +1304,11 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
|||||||
|
|
||||||
dnl CURL_CHECK_FUNC_RECV
|
dnl CURL_CHECK_FUNC_RECV
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Test if the socket recv() function is available,
|
dnl Test if the socket recv() function is available,
|
||||||
dnl and check its return type and the types of its
|
dnl and check its return type and the types of its
|
||||||
dnl arguments. If the function succeeds HAVE_RECV
|
dnl arguments. If the function succeeds HAVE_RECV
|
||||||
dnl will be defined, defining the types of the arguments
|
dnl will be defined, defining the types of the arguments
|
||||||
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
|
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
|
||||||
dnl and RECV_TYPE_ARG4, defining the type of the function
|
dnl and RECV_TYPE_ARG4, defining the type of the function
|
||||||
dnl return value in RECV_TYPE_RETV.
|
dnl return value in RECV_TYPE_RETV.
|
||||||
|
|
||||||
@@ -1339,7 +1320,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
|||||||
AC_MSG_CHECKING([for recv])
|
AC_MSG_CHECKING([for recv])
|
||||||
AC_LINK_IFELSE([
|
AC_LINK_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1383,7 +1364,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
|||||||
if test "$curl_cv_func_recv_args" = "unknown"; then
|
if test "$curl_cv_func_recv_args" = "unknown"; then
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1456,13 +1437,13 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
|||||||
|
|
||||||
dnl CURL_CHECK_FUNC_SEND
|
dnl CURL_CHECK_FUNC_SEND
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Test if the socket send() function is available,
|
dnl Test if the socket send() function is available,
|
||||||
dnl and check its return type and the types of its
|
dnl and check its return type and the types of its
|
||||||
dnl arguments. If the function succeeds HAVE_SEND
|
dnl arguments. If the function succeeds HAVE_SEND
|
||||||
dnl will be defined, defining the types of the arguments
|
dnl will be defined, defining the types of the arguments
|
||||||
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
|
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
|
||||||
dnl and SEND_TYPE_ARG4, defining the type of the function
|
dnl and SEND_TYPE_ARG4, defining the type of the function
|
||||||
dnl return value in SEND_TYPE_RETV, and also defining the
|
dnl return value in SEND_TYPE_RETV, and also defining the
|
||||||
dnl type qualifier of second argument in SEND_QUAL_ARG2.
|
dnl type qualifier of second argument in SEND_QUAL_ARG2.
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
||||||
@@ -1473,7 +1454,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
|||||||
AC_MSG_CHECKING([for send])
|
AC_MSG_CHECKING([for send])
|
||||||
AC_LINK_IFELSE([
|
AC_LINK_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1517,7 +1498,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
|||||||
if test "$curl_cv_func_send_args" = "unknown"; then
|
if test "$curl_cv_func_send_args" = "unknown"; then
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1641,7 +1622,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
|||||||
AC_MSG_CHECKING([for recvfrom])
|
AC_MSG_CHECKING([for recvfrom])
|
||||||
AC_LINK_IFELSE([
|
AC_LINK_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1687,7 +1668,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
|||||||
if test "$curl_cv_func_recvfrom_args" = "unknown"; then
|
if test "$curl_cv_func_recvfrom_args" = "unknown"; then
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1823,7 +1804,7 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
|
|||||||
AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
|
AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1870,11 +1851,11 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
|
|||||||
AC_REQUIRE([AC_HEADER_TIME])dnl
|
AC_REQUIRE([AC_HEADER_TIME])dnl
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
|
||||||
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
|
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
|
||||||
AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
|
AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
|
||||||
AC_COMPILE_IFELSE([
|
AC_COMPILE_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
#undef inline
|
#undef inline
|
||||||
#ifdef HAVE_WINDOWS_H
|
#ifdef HAVE_WINDOWS_H
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1900,6 +1881,9 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
|
|||||||
#ifdef HAVE_TIME_H
|
#ifdef HAVE_TIME_H
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
]],[[
|
]],[[
|
||||||
struct timeval ts;
|
struct timeval ts;
|
||||||
@@ -2217,6 +2201,214 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_CHECK_LIBS_CONNECT
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Verify if network connect function is already available
|
||||||
|
dnl using current libraries or if another one is required.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
|
||||||
|
AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
|
||||||
|
AC_MSG_CHECKING([for connect in libraries])
|
||||||
|
tst_connect_save_LIBS="$LIBS"
|
||||||
|
tst_connect_need_LIBS="unknown"
|
||||||
|
for tst_lib in '' '-lsocket' ; do
|
||||||
|
if test "$tst_connect_need_LIBS" = "unknown"; then
|
||||||
|
LIBS="$tst_lib $tst_connect_save_LIBS"
|
||||||
|
AC_LINK_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
$curl_includes_winsock2
|
||||||
|
#ifndef HAVE_WINDOWS_H
|
||||||
|
int connect(int, void*, int);
|
||||||
|
#endif
|
||||||
|
]],[[
|
||||||
|
if(0 != connect(0, 0, 0))
|
||||||
|
return 1;
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
tst_connect_need_LIBS="$tst_lib"
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
LIBS="$tst_connect_save_LIBS"
|
||||||
|
#
|
||||||
|
case X-"$tst_connect_need_LIBS" in
|
||||||
|
X-unknown)
|
||||||
|
AC_MSG_RESULT([cannot find connect])
|
||||||
|
AC_MSG_ERROR([cannot find connect function in libraries.])
|
||||||
|
;;
|
||||||
|
X-)
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_RESULT([$tst_connect_need_LIBS])
|
||||||
|
LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
|
||||||
|
dnl symbol that can be further used in custom template configuration
|
||||||
|
dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
|
||||||
|
dnl argument for the description. Symbol definitions done with this
|
||||||
|
dnl macro are intended to be exclusively used in handcrafted *.h.in
|
||||||
|
dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
|
||||||
|
dnl prevents autoheader generation and insertion of symbol template
|
||||||
|
dnl stub and definition into the first configuration header file. Do
|
||||||
|
dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
|
||||||
|
dnl one serves different functional needs.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_DEFINE_UNQUOTED], [
|
||||||
|
cat >>confdefs.h <<_EOF
|
||||||
|
[@%:@define] $1 ifelse($#, 2, [$2], 1)
|
||||||
|
_EOF
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_CONFIGURE_LONG
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Find out the size of long as reported by sizeof() and define
|
||||||
|
dnl CURL_SIZEOF_LONG as appropriate to be used in template file
|
||||||
|
dnl include/curl/curlbuild.h.in to properly configure the library.
|
||||||
|
dnl The size of long is a build time characteristic and as such
|
||||||
|
dnl must be recorded in curlbuild.h
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CONFIGURE_LONG], [
|
||||||
|
if test -z "$ac_cv_sizeof_long" ||
|
||||||
|
test "$ac_cv_sizeof_long" -eq "0"; then
|
||||||
|
AC_MSG_ERROR([cannot find out size of long.])
|
||||||
|
fi
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl CURL_CONFIGURE_CURL_SOCKLEN_T
|
||||||
|
dnl -------------------------------------------------
|
||||||
|
dnl Find out suitable curl_socklen_t data type definition and size, making
|
||||||
|
dnl appropriate definitions for template file include/curl/curlbuild.h.in
|
||||||
|
dnl to properly configure and use the library.
|
||||||
|
dnl
|
||||||
|
dnl The need for the curl_socklen_t definition arises mainly to properly
|
||||||
|
dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
|
||||||
|
dnl data type which is 32 or 64-Bit wide depending on the data model being
|
||||||
|
dnl used, and that on the other hand is only actually used when interfacing
|
||||||
|
dnl the X/Open sockets provided in the xnet library.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
|
||||||
|
AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
|
||||||
|
AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
|
||||||
|
AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
|
||||||
|
#
|
||||||
|
AC_MSG_CHECKING([for curl_socklen_t data type])
|
||||||
|
curl_typeof_curl_socklen_t="unknown"
|
||||||
|
for arg1 in int SOCKET; do
|
||||||
|
for arg2 in 'struct sockaddr' void; do
|
||||||
|
for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
|
||||||
|
if test "$curl_typeof_curl_socklen_t" = "unknown"; then
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
$curl_includes_ws2tcpip
|
||||||
|
$curl_includes_sys_socket
|
||||||
|
$curl_preprocess_callconv
|
||||||
|
extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
|
||||||
|
]],[[
|
||||||
|
$t *lenptr = 0;
|
||||||
|
if(0 != getpeername(0, 0, lenptr))
|
||||||
|
return 1;
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
curl_typeof_curl_socklen_t="$t"
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
for t in socklen_t int; do
|
||||||
|
if test "$curl_typeof_curl_socklen_t" = "void"; then
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
$curl_includes_sys_socket
|
||||||
|
typedef $t curl_socklen_t;
|
||||||
|
]],[[
|
||||||
|
curl_socklen_t dummy;
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
curl_typeof_curl_socklen_t="$t"
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
|
||||||
|
if test "$curl_typeof_curl_socklen_t" = "void" ||
|
||||||
|
test "$curl_typeof_curl_socklen_t" = "unknown"; then
|
||||||
|
AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
AC_MSG_CHECKING([size of curl_socklen_t])
|
||||||
|
curl_sizeof_curl_socklen_t="unknown"
|
||||||
|
curl_pull_headers_socklen_t="unknown"
|
||||||
|
if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
|
||||||
|
tst_pull_header_checks='none ws2tcpip'
|
||||||
|
tst_size_checks='4'
|
||||||
|
else
|
||||||
|
tst_pull_header_checks='none systypes syssocket'
|
||||||
|
tst_size_checks='4 8 2'
|
||||||
|
fi
|
||||||
|
for tst_size in $tst_size_checks; do
|
||||||
|
for tst_pull_headers in $tst_pull_header_checks; do
|
||||||
|
if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
|
||||||
|
case $tst_pull_headers in
|
||||||
|
ws2tcpip)
|
||||||
|
tmp_includes="$curl_includes_ws2tcpip"
|
||||||
|
;;
|
||||||
|
systypes)
|
||||||
|
tmp_includes="$curl_includes_sys_types"
|
||||||
|
;;
|
||||||
|
syssocket)
|
||||||
|
tmp_includes="$curl_includes_sys_socket"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
tmp_includes=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
$tmp_includes
|
||||||
|
typedef $curl_typeof_curl_socklen_t curl_socklen_t;
|
||||||
|
typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
|
||||||
|
]],[[
|
||||||
|
curl_socklen_t dummy;
|
||||||
|
]])
|
||||||
|
],[
|
||||||
|
curl_sizeof_curl_socklen_t="$tst_size"
|
||||||
|
curl_pull_headers_socklen_t="$tst_pull_headers"
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
|
||||||
|
if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
|
||||||
|
AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
case $curl_pull_headers_socklen_t in
|
||||||
|
ws2tcpip)
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
|
||||||
|
;;
|
||||||
|
systypes)
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
|
||||||
|
;;
|
||||||
|
syssocket)
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
|
||||||
|
CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CHECK_FUNC_SELECT
|
dnl CURL_CHECK_FUNC_SELECT
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Test if the socket select() function is available,
|
dnl Test if the socket select() function is available,
|
||||||
@@ -2622,8 +2814,8 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if test "x$ca" != "xno"; then
|
if test "x$ca" != "xno"; then
|
||||||
CURL_CA_BUNDLE='"'$ca'"'
|
CURL_CA_BUNDLE='"'$ca'"'
|
||||||
@@ -2640,67 +2832,6 @@ AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
|
|
||||||
dnl symbol that can be further used in custom template configuration
|
|
||||||
dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
|
|
||||||
dnl argument for the description. Symbol definitions done with this
|
|
||||||
dnl macro are intended to be exclusively used in handcrafted *.h.in
|
|
||||||
dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
|
|
||||||
dnl prevents autoheader generation and insertion of symbol template
|
|
||||||
dnl stub and definition into the first configuration header file. Do
|
|
||||||
dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
|
|
||||||
dnl one serves different functional needs.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_DEFINE_UNQUOTED], [
|
|
||||||
cat >>confdefs.h <<_EOF
|
|
||||||
[@%:@define] $1 ifelse($#, 2, [$2], 1)
|
|
||||||
_EOF
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_INCLUDES_INTTYPES
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Set up variable with list of headers that must be
|
|
||||||
dnl included when inttypes.h is to be included.
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_INCLUDES_INTTYPES], [
|
|
||||||
curl_includes_inttypes="\
|
|
||||||
/* includes start */
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
# include <stdint.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_INTTYPES_H
|
|
||||||
# include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
/* includes end */"
|
|
||||||
AC_CHECK_HEADERS(
|
|
||||||
sys/types.h stdint.h inttypes.h,
|
|
||||||
[], [], [$curl_includes_inttypes])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl CURL_CONFIGURE_LONG
|
|
||||||
dnl -------------------------------------------------
|
|
||||||
dnl Find out the size of long as reported by sizeof() and define
|
|
||||||
dnl CURL_SIZEOF_LONG as appropriate to be used in template file
|
|
||||||
dnl include/curl/curlbuild.h.in to properly configure the library.
|
|
||||||
dnl The size of long is a build time characteristic and as such
|
|
||||||
dnl must be recorded in curlbuild.h
|
|
||||||
|
|
||||||
AC_DEFUN([CURL_CONFIGURE_LONG], [
|
|
||||||
if test -z "$ac_cv_sizeof_long" ||
|
|
||||||
test "$ac_cv_sizeof_long" -eq "0"; then
|
|
||||||
AC_MSG_ERROR([cannot find out size of long.])
|
|
||||||
fi
|
|
||||||
CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
|
dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
|
||||||
dnl -------------------------------------------------
|
dnl -------------------------------------------------
|
||||||
dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
|
dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
|
||||||
@@ -2911,7 +3042,7 @@ AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
|
|||||||
'__int32' \
|
'__int32' \
|
||||||
'int' ; do
|
'int' ; do
|
||||||
DO_CURL_OFF_T_CHECK([$t4], [4])
|
DO_CURL_OFF_T_CHECK([$t4], [4])
|
||||||
done
|
done
|
||||||
AC_MSG_RESULT([$curl_typeof_curl_off_t])
|
AC_MSG_RESULT([$curl_typeof_curl_off_t])
|
||||||
fi
|
fi
|
||||||
if test "$curl_typeof_curl_off_t" = "unknown"; then
|
if test "$curl_typeof_curl_off_t" = "unknown"; then
|
||||||
@@ -3058,25 +3189,53 @@ AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
|
|||||||
esac
|
esac
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl CURL_CHECK_PKGCONFIG ($module)
|
dnl CURL_EXPORT_PCDIR ($pcdir)
|
||||||
|
dnl ------------------------
|
||||||
|
dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
|
||||||
|
dnl
|
||||||
|
dnl we need this macro since pkg-config distinguishes among empty and unset
|
||||||
|
dnl variable while checking PKG_CONFIG_LIBDIR
|
||||||
|
dnl
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_EXPORT_PCDIR], [
|
||||||
|
if test -n "$1"; then
|
||||||
|
PKG_CONFIG_LIBDIR="$1"
|
||||||
|
export PKG_CONFIG_LIBDIR
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
|
||||||
dnl ------------------------
|
dnl ------------------------
|
||||||
dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
|
dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
|
||||||
dnl variable to hold the path to it, or 'no' if not found/present.
|
dnl variable to hold the path to it, or 'no' if not found/present.
|
||||||
dnl
|
dnl
|
||||||
dnl If pkg-config is present, check that it has info about the $module or return
|
dnl If pkg-config is present, check that it has info about the $module or
|
||||||
dnl "no" anyway!
|
dnl return "no" anyway!
|
||||||
|
dnl
|
||||||
|
dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
AC_DEFUN([CURL_CHECK_PKGCONFIG], [
|
AC_DEFUN([CURL_CHECK_PKGCONFIG], [
|
||||||
if test x$cross_compiling != xyes; then
|
|
||||||
dnl only do pkg-config magic when not cross-compiling
|
PKGCONFIG="no"
|
||||||
AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
|
|
||||||
|
if test x$cross_compiling = xyes; then
|
||||||
|
dnl see if there's a pkg-specific for this host setup
|
||||||
|
AC_PATH_PROG( PKGCONFIG, ${host}-pkg-config, no,
|
||||||
|
$PATH:/usr/bin:/usr/local/bin)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$PKGCONFIG = xno; then
|
||||||
|
AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$PKGCONFIG != xno; then
|
if test x$PKGCONFIG != xno; then
|
||||||
AC_MSG_CHECKING([for $1 options with pkg-config])
|
AC_MSG_CHECKING([for $1 options with pkg-config])
|
||||||
dnl ask pkg-config about $1
|
dnl ask pkg-config about $1
|
||||||
$PKGCONFIG --exists $1
|
itexists=`CURL_EXPORT_PCDIR([$2]) dnl
|
||||||
if test "$?" -ne "0"; then
|
$PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
|
||||||
|
|
||||||
|
if test -z "$itexists"; then
|
||||||
dnl pkg-config does not have info about the given module! set the
|
dnl pkg-config does not have info about the given module! set the
|
||||||
dnl variable to 'no'
|
dnl variable to 'no'
|
||||||
PKGCONFIG="no"
|
PKGCONFIG="no"
|
||||||
@@ -3085,8 +3244,4 @@ AC_DEFUN([CURL_CHECK_PKGCONFIG], [
|
|||||||
AC_MSG_RESULT([found])
|
AC_MSG_RESULT([found])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
|
||||||
PKGCONFIG="no"
|
|
||||||
fi
|
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
configure
|
|
||||||
autom4te.cache
|
|
||||||
Makefile
|
|
||||||
adig
|
|
||||||
ahost
|
|
||||||
config.log
|
|
||||||
config.status
|
|
||||||
aclocal.m4
|
|
||||||
.deps
|
|
||||||
Makefile.in
|
|
||||||
config.guess
|
|
||||||
config.h
|
|
||||||
config.h.in
|
|
||||||
config.sub
|
|
||||||
libtool
|
|
||||||
ltmain.sh
|
|
||||||
stamp-h1
|
|
||||||
*.lo
|
|
||||||
.libs
|
|
||||||
depcomp
|
|
||||||
libcares.la
|
|
||||||
missing
|
|
||||||
ares_version.h.dist
|
|
||||||
libcares.pc
|
|
||||||
37
ares/AUTHORS
37
ares/AUTHORS
@@ -1,37 +0,0 @@
|
|||||||
c-ares is based on ares, and these are the people that have worked on it since
|
|
||||||
the fork was made:
|
|
||||||
|
|
||||||
Alexander Lazic
|
|
||||||
Alexey Simak
|
|
||||||
Andreas Rieke
|
|
||||||
Ashish Sharma
|
|
||||||
Brad House
|
|
||||||
Brad Spencer
|
|
||||||
Bram Matthys
|
|
||||||
Dan Fandrich
|
|
||||||
Daniel Stenberg
|
|
||||||
Dirk Manske
|
|
||||||
Dominick Meglio
|
|
||||||
Doug Goldstein
|
|
||||||
Duncan Wilcox
|
|
||||||
Eino Tuominen
|
|
||||||
Erik Kline
|
|
||||||
George Neill
|
|
||||||
Gisle Vanem
|
|
||||||
Guilherme Balena Versiani
|
|
||||||
Gunter Knauf
|
|
||||||
Henrik Stoerner
|
|
||||||
James Bursa
|
|
||||||
Michael Wallner
|
|
||||||
Nick Mathewson
|
|
||||||
Phil Blundell
|
|
||||||
Ravi Pratap
|
|
||||||
Robin Cornelius
|
|
||||||
Sebastian at basti79.de
|
|
||||||
Shmulik Regev
|
|
||||||
Steinar H. Gunderson
|
|
||||||
Tofu Linden
|
|
||||||
Vlad Dinulescu
|
|
||||||
William Ahern
|
|
||||||
Yang Tse
|
|
||||||
liren at vivisimo.com
|
|
||||||
921
ares/CHANGES
921
ares/CHANGES
@@ -1,921 +0,0 @@
|
|||||||
Changelog for the c-ares project
|
|
||||||
|
|
||||||
* February 20 2009 (Yang Tse)
|
|
||||||
- Do not halt compilation when using VS2008 to build a Windows 2000 target.
|
|
||||||
|
|
||||||
* February 3 2009 (Phil Blundell)
|
|
||||||
- If the server returns garbage or nothing at all in response to an AAAA query,
|
|
||||||
go on and ask for A records anyway.
|
|
||||||
|
|
||||||
* January 31 2009 (Daniel Stenberg)
|
|
||||||
- ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving
|
|
||||||
either AF_INET6 or AF_INET. It works by accepting any of the looksups in the
|
|
||||||
hosts file, and it resolves the AAAA field with a fallback to A.
|
|
||||||
|
|
||||||
* January 14 2009 (Daniel Stenberg)
|
|
||||||
- ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it
|
|
||||||
now declares the private struct ares_in6_addr for all systems instead of
|
|
||||||
relying on one possibly not present in the system.
|
|
||||||
|
|
||||||
* January 13 2009 (Phil Blundell)
|
|
||||||
- ares__send_query() now varies the retry timeout pseudo-randomly to avoid
|
|
||||||
packet storms when several queries were started at the same time.
|
|
||||||
|
|
||||||
* January 11 2009 (Daniel Stenberg)
|
|
||||||
- Phil Blundell added the internal function ares__expand_name_for_response()
|
|
||||||
that is now used by the ares_parse_*_reply() functions instead of the
|
|
||||||
ares_expand_name() simply to easier return ARES_EBADRESP for the cases where
|
|
||||||
the name expansion fails as in responses that really isn't expected.
|
|
||||||
|
|
||||||
Version 1.6.0 (Dec 9, 2008)
|
|
||||||
|
|
||||||
* December 9 2008 (Gisle Vanem)
|
|
||||||
|
|
||||||
Fixes for Win32 targets using the Watt-32 tcp/ip stack.
|
|
||||||
|
|
||||||
* Dec 4 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
Gregor Jasny provided the patch that introduces ares_set_socket_callback(),
|
|
||||||
and I edited it to also get duped by ares_dup().
|
|
||||||
|
|
||||||
* Dec 3 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
API changes:
|
|
||||||
|
|
||||||
I made sure the public ares_config struct looks like before and yet it
|
|
||||||
supports the ROTATE option thanks to c-ares now storing the "optmask"
|
|
||||||
internally. Thus we should be ABI compatible with the past release(s)
|
|
||||||
now. My efforts mentioned below should not break backwards ABI compliance.
|
|
||||||
|
|
||||||
Here's how I suggest we proceed with the API:
|
|
||||||
|
|
||||||
ares_init() will be primary "channel creator" function.
|
|
||||||
|
|
||||||
ares_init_options() will continue to work exactly like now and before. For
|
|
||||||
starters, it will be the (only) way to set the existing options.
|
|
||||||
|
|
||||||
ares_save_options() will continue to work like today, but will ONLY save
|
|
||||||
options that you can set today (including ARES_OPT_ROTATE actually) but new
|
|
||||||
options that we add may not be saved with this.
|
|
||||||
|
|
||||||
Instead we introduce:
|
|
||||||
|
|
||||||
ares_dup() that instead can make a new channel and clone the config used
|
|
||||||
from an existing channel. It will then clone all config options, including
|
|
||||||
future new things we add.
|
|
||||||
|
|
||||||
ares_set_*() style functions that set (new) config options. As a start we
|
|
||||||
simply add these for new functionality, but over time we can also introduce
|
|
||||||
them for existing "struct ares_options" so that we can eventually deprecate
|
|
||||||
the two ares_*_options() functions.
|
|
||||||
|
|
||||||
ares_get_*() style functions for extracting info from a channel handle that
|
|
||||||
should be used instead of ares_save_options().
|
|
||||||
|
|
||||||
* Nov 26 2008 (Yang Tse)
|
|
||||||
- Brad Spencer provided changes to allow buildconf to work on OS X.
|
|
||||||
|
|
||||||
- Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a
|
|
||||||
buffer to shrink instead of expand if a reply contained 8 or more records.
|
|
||||||
|
|
||||||
* Nov 25 2008 (Yang Tse)
|
|
||||||
- In preparation for the upcomming IPv6 nameservers patch, the internal
|
|
||||||
ares_addr union is now changed into an internal struct which also holds
|
|
||||||
the address family.
|
|
||||||
|
|
||||||
* Nov 19 2008 (Daniel Stenberg)
|
|
||||||
- Brad Spencer brought the new function ares_gethostbyname_file() which simply
|
|
||||||
resolves a host name from the given file, using the regular hosts syntax.
|
|
||||||
|
|
||||||
* Nov 1 2008 (Daniel Stenberg)
|
|
||||||
- Carlo Contavalli added support for the glibc "rotate" option, as documented
|
|
||||||
in man resolv.conf:
|
|
||||||
|
|
||||||
causes round robin selection of nameservers from among those listed. This
|
|
||||||
has the effect of spreading the query load among all listed servers, rather
|
|
||||||
than having all clients try the first listed server first every time.
|
|
||||||
|
|
||||||
You can enable it with ARES_OPT_ROTATE
|
|
||||||
|
|
||||||
* Oct 21 2008 (Yang Tse)
|
|
||||||
Charles Hardin added handling of EINPROGRESS for UDP connects.
|
|
||||||
|
|
||||||
* Oct 18 2008 (Daniel Stenberg)
|
|
||||||
Charles Hardin made adig support a regular numerical dotted IP address for the
|
|
||||||
-s option as well.
|
|
||||||
|
|
||||||
* Oct 7 2008 (Yang Tse)
|
|
||||||
- Added --enable-optimize configure option to enable and disable compiler
|
|
||||||
optimizations to allow decoupled setting from --enable-debug.
|
|
||||||
|
|
||||||
* Oct 2 2008 (Yang Tse)
|
|
||||||
- Added --enable-warnings configure option to enable and disable strict
|
|
||||||
compiler warnings to allow decoupled setting from --enable-debug.
|
|
||||||
|
|
||||||
* Sep 17 2008 (Yang Tse)
|
|
||||||
- Code reorganization to allow internal/private use of "nameser.h" to any
|
|
||||||
system that lacks arpa/nameser.h or arpa/nameser_compat.h header files.
|
|
||||||
|
|
||||||
* Sep 16 2008 (Yang Tse)
|
|
||||||
- Code reorganization to allow internal/private use of ares_writev to any
|
|
||||||
system that lacks the writev function.
|
|
||||||
|
|
||||||
* Sep 15 2008 (Yang Tse)
|
|
||||||
- Code reorganization to allow internal/private use of ares_strcasecmp to any
|
|
||||||
system that lacks the strcasecmp function.
|
|
||||||
|
|
||||||
- Improve configure detection of some string functions.
|
|
||||||
|
|
||||||
* Sep 11 2008 (Yang Tse)
|
|
||||||
- Code reorganization to allow internal/private use of ares_strdup to any
|
|
||||||
system that lacks the strdup function.
|
|
||||||
|
|
||||||
Version 1.5.3 (Aug 29, 2008)
|
|
||||||
|
|
||||||
* Aug 25 2008 (Yang Tse)
|
|
||||||
- Improvement by Brad House:
|
|
||||||
|
|
||||||
This patch addresses an issue in which a response could be sent back to the
|
|
||||||
source port of a client from a different address than the request was made to.
|
|
||||||
This is one form of a DNS cache poisoning attack.
|
|
||||||
|
|
||||||
The patch simply uses recvfrom() rather than recv() and validates that the
|
|
||||||
address returned from recvfrom() matches the address of the server we have
|
|
||||||
connected to. Only necessary on UDP sockets as they are connection-less, TCP
|
|
||||||
is unaffected.
|
|
||||||
|
|
||||||
- Fix by George Neill:
|
|
||||||
Fixed compilation of acountry sample application failure on some systems.
|
|
||||||
|
|
||||||
* Aug 4 2008 (Daniel Stenberg)
|
|
||||||
- Fix by Tofu Linden:
|
|
||||||
|
|
||||||
The symptom:
|
|
||||||
* Users (usually, but not always) on 2-Wire routers and the Comcast service
|
|
||||||
and a wired connection to their router would find that the second and
|
|
||||||
subsequent DNS lookups from fresh processes using c-ares to resolve the same
|
|
||||||
address would cause the process to never see a reply (it keeps polling for
|
|
||||||
around 1m15s before giving up).
|
|
||||||
|
|
||||||
The repro:
|
|
||||||
* On such a machine (and yeah, it took us a lot of QA to find the systems
|
|
||||||
that reproduce such a specific problem!), do 'ahost www.secondlife.com',
|
|
||||||
then do it again. The first process's lookup will work, subsequent lookups
|
|
||||||
will time-out and fail.
|
|
||||||
|
|
||||||
The cause:
|
|
||||||
* init_id_key() was calling randomize_key() *before* it initialized
|
|
||||||
key->state, meaning that the randomness generated by randomize_key() is
|
|
||||||
immediately overwritten with deterministic values. (/dev/urandom was also
|
|
||||||
being read incorrectly in the c-ares version we were using, but this was
|
|
||||||
fixed in a later version.)
|
|
||||||
* This makes the stream of generated query-IDs from any new c-ares process
|
|
||||||
be an identical and predictable sequence of IDs.
|
|
||||||
* This makes the 2-Wire's default built-in DNS server detect these queries
|
|
||||||
as probable-duplicates and (erroneously) not respond at all.
|
|
||||||
|
|
||||||
|
|
||||||
* Aug 4 2008 (Yang Tse)
|
|
||||||
- Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use.
|
|
||||||
Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. 2.62
|
|
||||||
version of AC_AIX defines _ALL_SOURCE and other four preprocessor symbols
|
|
||||||
no matter if the system is AIX or not. To keep the traditional behaviour,
|
|
||||||
and an uniform one across autoconf versions AC_AIX is replaced with our
|
|
||||||
own internal macro CARES_CHECK_AIX_ALL_SOURCE.
|
|
||||||
|
|
||||||
* Aug 1 2008 (Yang Tse)
|
|
||||||
- Configure process now checks if the preprocessor _REENTRANT symbol is already
|
|
||||||
defined. If it isn't currently defined a set of checks are performed to test
|
|
||||||
if its definition is required to make visible to the compiler a set of *_r
|
|
||||||
functions. Finally, if _REENTRANT is already defined or needed it takes care
|
|
||||||
of making adjustments necessary to ensure that it is defined equally for the
|
|
||||||
configure process tests and generated config file.
|
|
||||||
|
|
||||||
* Jul 20 2008 (Yang Tse)
|
|
||||||
- When recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will
|
|
||||||
now cause the definition, as appropriate, of RECVFROM_TYPE_ARG2_IS_VOID,
|
|
||||||
RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID.
|
|
||||||
|
|
||||||
* Jul 17 2008 (Yang Tse)
|
|
||||||
- RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined
|
|
||||||
to the data type pointed by its respective argument and not the pointer type.
|
|
||||||
|
|
||||||
* Jul 16 2008 (Yang Tse)
|
|
||||||
- Improved configure detection of number of arguments for getservbyport_r.
|
|
||||||
Detection is now based on compilation checks instead of linker ones.
|
|
||||||
|
|
||||||
- Configure process now checks availability of recvfrom() socket function and
|
|
||||||
finds out its return type and the types of its arguments. Added definitions
|
|
||||||
for non-configure systems config files, and introduced macro sreadfrom which
|
|
||||||
will be used on udp sockets as a recvfrom() wrapper in the future.
|
|
||||||
|
|
||||||
* Jul 15 2008 (Yang Tse)
|
|
||||||
- Introduce definition of _REENTRANT symbol in setup.h to improve library
|
|
||||||
usability. Previously the configure process only used the AC_SYS_LARGEFILE
|
|
||||||
macro for debug builds, now it is also used for non-debug ones enabling the
|
|
||||||
use of configure options --enable-largefile and --disable-largefile which
|
|
||||||
might be needed for library compatibility. Remove checking the size of
|
|
||||||
curl_off_t, it is no longer needed.
|
|
||||||
|
|
||||||
* Jul 3 2008 (Daniel Stenberg)
|
|
||||||
- Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and
|
|
||||||
the target host has only A records, it automatically falls back to an
|
|
||||||
AF_INET lookup and gives you the A results. However, if the target host has
|
|
||||||
a CNAME record, this behaviour is defeated since the original query does
|
|
||||||
return some data even though ares_parse_aaa_reply() doesn't consider it
|
|
||||||
relevant. Here's a small patch to make it behave the same with and without
|
|
||||||
the CNAME.
|
|
||||||
|
|
||||||
* Jul 2 2008 (Yang Tse)
|
|
||||||
- Fallback to gettimeofday when monotonic clock is unavailable at run-time.
|
|
||||||
|
|
||||||
* Jun 30 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is
|
|
||||||
not posix or anything and thus c-ares failed to build on hurd (and possibly
|
|
||||||
elsewhere). The define was also somewhat artificially used in the windows
|
|
||||||
port. Now, I instead rewrote the use of gethostbyname to enlarge the host
|
|
||||||
name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN
|
|
||||||
define. I thus also removed the defien from the namser.h file where it was
|
|
||||||
once added for the windows build.
|
|
||||||
|
|
||||||
I also fixed init_by_defaults() function to not leak memory in case if
|
|
||||||
error.
|
|
||||||
|
|
||||||
* Jun 9 2008 (Yang Tse)
|
|
||||||
|
|
||||||
- Make libcares.pc generated file for pkg-config include information relative
|
|
||||||
to the libraries needed for the static linking of c-ares.
|
|
||||||
|
|
||||||
* May 30 2008 (Yang Tse)
|
|
||||||
|
|
||||||
- Brad House fixed a missing header file inclusion in adig sample program.
|
|
||||||
|
|
||||||
Version 1.5.2 (May 29, 2008)
|
|
||||||
|
|
||||||
* May 13 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Introducing millisecond resolution support for the timeout option. See
|
|
||||||
ares_init_options()'s ARES_OPT_TIMEOUTMS.
|
|
||||||
|
|
||||||
* May 9 2008 (Yang Tse)
|
|
||||||
|
|
||||||
- Use monotonic time source if available, for private function ares__tvnow()
|
|
||||||
|
|
||||||
* May 7 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Sebastian made c-ares able to return all PTR-records when doing reverse
|
|
||||||
lookups. It is not common practice to have multiple PTR-Records for a single
|
|
||||||
IP, but its perfectly legal and some sites have those.
|
|
||||||
|
|
||||||
- Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to
|
|
||||||
autoconf 2.57 usage (which is the version you have specified as the minimum
|
|
||||||
version). It's a minor change but it does clean up some warnings with newer
|
|
||||||
autoconf (specifically 2.62).
|
|
||||||
|
|
||||||
* May 5 2008 (Yang Tse)
|
|
||||||
|
|
||||||
- Improved parsing of resolver configuration files.
|
|
||||||
|
|
||||||
* April 4 2008 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Eino Tuominen improved the code when a file is used to seed the randomizer.
|
|
||||||
|
|
||||||
- Alexey Simak made adig support NAPTR records
|
|
||||||
|
|
||||||
- Alexey Simak fixed the VC dsp file by adding the missing source file
|
|
||||||
ares_expand_string.c
|
|
||||||
|
|
||||||
* December 11 2007 (Gisle Vanem)
|
|
||||||
|
|
||||||
- Added another sample application; acountry.c which converts an
|
|
||||||
IPv4-address(es) and/or host-name(s) to country-name and country-code.
|
|
||||||
This uses the service of the DNSBL at countries.nerd.dk.
|
|
||||||
|
|
||||||
* December 3 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Brad Spencer fixed the configure script to assume that there's no
|
|
||||||
/dev/urandom when built cross-compiled as then the script cannot check for
|
|
||||||
it.
|
|
||||||
|
|
||||||
- Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat
|
|
||||||
|
|
||||||
Version 1.5.1 (Nov 21, 2007)
|
|
||||||
|
|
||||||
* November 21 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Robin Cornelius pointed out that ares_llist.h was missing in the release
|
|
||||||
archive for 1.5.0
|
|
||||||
|
|
||||||
Version 1.5.0 (Nov 21, 2007)
|
|
||||||
|
|
||||||
* October 2 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- ares_strerror() segfaulted if the input error number was out of the currently
|
|
||||||
supported range.
|
|
||||||
|
|
||||||
- Yang Tse: Avoid a segfault when generating a DNS "Transaction ID" in
|
|
||||||
internal function init_id_key() under low memory conditions.
|
|
||||||
|
|
||||||
* September 28 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI
|
|
||||||
and API changes in the progress callback (and possibly more coming up from
|
|
||||||
Steinar)
|
|
||||||
|
|
||||||
* September 28 2007 (Steinar H. Gunderson)
|
|
||||||
|
|
||||||
- Don't skip a server if it's the only one. (Bugfix from the Google tree.)
|
|
||||||
|
|
||||||
- Made the query callbacks receive the number of timeouts that happened during
|
|
||||||
the execution of a query, and updated documentation accordingly. (Patch from
|
|
||||||
the Google tree.)
|
|
||||||
|
|
||||||
- Support a few more socket options: ARES_OPT_SOCK_SNDBUF and
|
|
||||||
ARES_OPT_SOCK_RCVBUF
|
|
||||||
|
|
||||||
- Always register for TCP events even if there are no outstanding queries, as
|
|
||||||
the other side could always close the connection, which is a valid event
|
|
||||||
which should be responded to.
|
|
||||||
|
|
||||||
* September 22 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in
|
|
||||||
several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that
|
|
||||||
if it fails and the socket is closed the following code doesn't try to use
|
|
||||||
the file descriptor.
|
|
||||||
|
|
||||||
- Steinar H. Gunderson modified c-ares to now also do to DNS retries even when
|
|
||||||
TCP is used since there are several edge cases where it still makes sense.
|
|
||||||
|
|
||||||
- Brad House provided a fix for ares_save_options():
|
|
||||||
|
|
||||||
Apparently I overlooked something with the ares_save_options() where it
|
|
||||||
would try to do a malloc(0) when no options of that type needed to be saved.
|
|
||||||
On most platforms, this was fine because malloc(0) doesn't actually return
|
|
||||||
NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM.
|
|
||||||
|
|
||||||
* July 14 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- Vlad Dinulescu fixed two outstanding valgrind reports:
|
|
||||||
|
|
||||||
1. In ares_query.c , in find_query_by_id we compare q->qid (which is a short
|
|
||||||
int variable) with qid, which is declared as an int variable. Moreover,
|
|
||||||
DNS_HEADER_SET_QID is used to set the value of qid, but DNS_HEADER_SET_QID
|
|
||||||
sets only the first two bytes of qid. I think that qid should be declared as
|
|
||||||
"unsigned short" in this function.
|
|
||||||
|
|
||||||
2. The same problem occurs in ares_process.c, process_answer() . query->qid
|
|
||||||
(an unsigned short integer variable) is compared with id, which is an
|
|
||||||
integer variable. Moreover, id is initialized from DNS_HEADER_QID which sets
|
|
||||||
only the first two bytes of id. I think that the id variable should be
|
|
||||||
declared as "unsigned short" in this function.
|
|
||||||
|
|
||||||
Even after declaring these variables as "unsigned short", the valgrind
|
|
||||||
errors are still there. Which brings us to the third problem.
|
|
||||||
|
|
||||||
3. The third problem is that Valgrind assumes that query->qid is not
|
|
||||||
initialised correctly. And it does that because query->qid is set from
|
|
||||||
DNS_HEADER_QID(qbuf); Valgrind says that qbuf has unitialised bytes. And
|
|
||||||
qbuf has uninitialised bytes because of channel->next_id . And next_id is
|
|
||||||
set by ares_init.c:ares__generate_new_id() . I found that putting short r=0
|
|
||||||
in this function (instead of short r) makes all Valgrind warnings go away.
|
|
||||||
I have studied ares__rc4() too, and this is the offending line:
|
|
||||||
|
|
||||||
buffer_ptr[counter] ^= state[xorIndex]; (ares_query.c:62)
|
|
||||||
|
|
||||||
This is what triggers Valgrind.. buffer_ptr is unitialised in this function,
|
|
||||||
and by applying ^= on it, it remains unitialised.
|
|
||||||
|
|
||||||
Version 1.4.0 (June 8, 2007)
|
|
||||||
|
|
||||||
* June 4 2007 (Daniel Stenberg)
|
|
||||||
|
|
||||||
- James Bursa reported a major memory problem when resolving multi-IP names
|
|
||||||
and I found and fixed the problem. It was added by Ashish Sharma's patch
|
|
||||||
two days ago.
|
|
||||||
|
|
||||||
When I then tried to verify multiple entries in /etc/hosts after my fix, I
|
|
||||||
got another segfault and decided this code was not ripe for inclusion and I
|
|
||||||
reverted the patch.
|
|
||||||
|
|
||||||
* June 2 2007
|
|
||||||
|
|
||||||
- Brad Spencer found and fixed three flaws in the code, found with the new
|
|
||||||
gcc 4.2.0 warning: -Waddress
|
|
||||||
|
|
||||||
- Brad House fixed VS2005 compiler warnings due to time_t being 64bit.
|
|
||||||
He also made recent Microsoft compilers use _strdup() instead of strdup().
|
|
||||||
|
|
||||||
- Brad House's man pages for ares_save_options() and ares_destroy_options()
|
|
||||||
were added.
|
|
||||||
|
|
||||||
- Ashish Sharma provided a patch for supporting multiple entries in the
|
|
||||||
/etc/hosts file. Patch edited for coding style and functionality by me
|
|
||||||
(Daniel).
|
|
||||||
|
|
||||||
* May 30 2007
|
|
||||||
|
|
||||||
- Shmulik Regev brought cryptographically secure transaction IDs:
|
|
||||||
|
|
||||||
The c-ares library implementation uses a DNS "Transaction ID" field that is
|
|
||||||
seeded with a pseudo random number (based on gettimeofday) which is
|
|
||||||
incremented (++) between consecutive calls and is therefore rather
|
|
||||||
predictable. In general, predictability of DNS Transaction ID is a well
|
|
||||||
known security problem (e.g.
|
|
||||||
http://bak.spc.org/dms/archive/dns_id_attack.txt) and makes a c-ares based
|
|
||||||
implementation vulnerable to DNS poisoning. Credit goes to Amit Klein
|
|
||||||
(Trusteer) for identifying this problem.
|
|
||||||
|
|
||||||
The patch I wrote changes the implementation to use a more secure way of
|
|
||||||
generating unique IDs. It starts by obtaining a key with reasonable entropy
|
|
||||||
which is used with an RC4 stream to generate the cryptographically secure
|
|
||||||
transaction IDs.
|
|
||||||
|
|
||||||
Note that the key generation code (in ares_init:randomize_key) has two
|
|
||||||
versions, the Windows specific one uses a cryptographically safe function
|
|
||||||
provided (but undocumented :) by the operating system (described at
|
|
||||||
http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx). The
|
|
||||||
default implementation is a bit naive and uses the standard 'rand'
|
|
||||||
function. Surely a better way to generate random keys exists for other
|
|
||||||
platforms.
|
|
||||||
|
|
||||||
The patch can be tested by using the adig utility and using the '-s' option.
|
|
||||||
|
|
||||||
- Brad House added ares_save_options() and ares_destroy_options() that can be
|
|
||||||
used to keep options for later re-usal when ares_init_options() is used.
|
|
||||||
|
|
||||||
Problem: Calling ares_init() for each lookup can be unnecessarily resource
|
|
||||||
intensive. On windows, it must LoadLibrary() or search the registry
|
|
||||||
on each call to ares_init(). On unix, it must read and parse
|
|
||||||
multiple files to obtain the necessary configuration information. In
|
|
||||||
a single-threaded environment, it would make sense to only
|
|
||||||
ares_init() once, but in a heavily multi-threaded environment, it is
|
|
||||||
undesirable to ares_init() and ares_destroy() for each thread created
|
|
||||||
and track that.
|
|
||||||
|
|
||||||
Solution: Create ares_save_options() and ares_destroy_options() functions to
|
|
||||||
retrieve and free options obtained from an initialized channel. The
|
|
||||||
options populated can be used to pass back into ares_init_options(),
|
|
||||||
it should populate all needed fields and not retrieve any information
|
|
||||||
from the system. Probably wise to destroy the cache every minute or
|
|
||||||
so to prevent the data from becoming stale.
|
|
||||||
|
|
||||||
- Daniel S added ares_process_fd() to allow applications to ask for processing
|
|
||||||
on specific sockets and thus avoiding select() and associated
|
|
||||||
functions/macros. This function will be used by upcoming libcurl releases
|
|
||||||
for this very reason. It also made me export the ares_socket_t type in the
|
|
||||||
public ares.h header file, since ares_process_fd() uses that type for two of
|
|
||||||
the arguments.
|
|
||||||
|
|
||||||
* May 25 2007
|
|
||||||
|
|
||||||
- Ravi Pratap fixed a flaw in the init_by_resolv_conf() function for windows
|
|
||||||
that could cause it to return a bad return code.
|
|
||||||
|
|
||||||
* April 16 2007
|
|
||||||
|
|
||||||
- Yang Tse: Provide ares_getopt() command-line parser function as a source
|
|
||||||
code helper function, not belonging to the actual c-ares library.
|
|
||||||
|
|
||||||
* February 19 2007
|
|
||||||
|
|
||||||
- Vlad Dinulescu added ares_parse_ns_reply().
|
|
||||||
|
|
||||||
* February 13 2007
|
|
||||||
|
|
||||||
- Yang Tse: Fix failure to get the search sequence of /etc/hosts and
|
|
||||||
DNS from /etc/nsswitch.conf, /etc/host.conf or /etc/svc.conf when
|
|
||||||
/etc/resolv.conf did not exist or was unable to read it.
|
|
||||||
|
|
||||||
* November 22 2006
|
|
||||||
|
|
||||||
- Install ares_dns.h too
|
|
||||||
|
|
||||||
- Michael Wallner fixed this problem: When I set domains in the options
|
|
||||||
struct, and there are domain/search entries in /etc/resolv.conf, the domains
|
|
||||||
of the options struct will be overridden.
|
|
||||||
|
|
||||||
* November 6 2006
|
|
||||||
|
|
||||||
- Yang Tse removed a couple of potential zero size memory allocations.
|
|
||||||
|
|
||||||
- Andreas Rieke fixed the line endings in the areslib.dsp file that I (Daniel)
|
|
||||||
broke in the 1.3.2 release. We should switch to a system where that file is
|
|
||||||
auto-generated. We could rip some code for that from curl...
|
|
||||||
|
|
||||||
Version 1.3.2 (November 3, 2006)
|
|
||||||
|
|
||||||
* October 12 2006
|
|
||||||
|
|
||||||
- Prevent ares_getsock() to overflow if more than 16 sockets are used.
|
|
||||||
|
|
||||||
* September 11 2006
|
|
||||||
|
|
||||||
- Guilherme Balena Versiani: I noted a strange BUG in Win32 port
|
|
||||||
(ares_init.c/get_iphlpapi_dns_info() function): when I disable the network
|
|
||||||
by hand or disconnect the network cable in Windows 2000 or Windows XP, my
|
|
||||||
application gets 127.0.0.1 as the only name server. The problem comes from
|
|
||||||
'GetNetworkParams' function, that returns the empty string "" as the only
|
|
||||||
name server in that case. Moreover, the Windows implementation of
|
|
||||||
inet_addr() returns INADDR_LOOPBACK instead of INADDR_NONE.
|
|
||||||
|
|
||||||
* August 29 2006
|
|
||||||
|
|
||||||
- Brad Spencer did
|
|
||||||
|
|
||||||
o made ares_version.h use extern "C" for c++ compilers
|
|
||||||
o fixed compiler warnings in ares_getnameinfo.c
|
|
||||||
o fixed a buffer position init for TCP reads
|
|
||||||
|
|
||||||
* August 3 2006
|
|
||||||
|
|
||||||
- Ravi Pratap fixed ares_getsock() to actually return the proper bitmap and
|
|
||||||
not always zero!
|
|
||||||
|
|
||||||
Version 1.3.1 (June 24, 2006)
|
|
||||||
|
|
||||||
* July 23, 2006
|
|
||||||
|
|
||||||
- Gisle Vanem added getopt() to the ahost program. Currently accepts
|
|
||||||
only [-t {a|aaaa}] to specify address family in ares_gethostbyname().
|
|
||||||
|
|
||||||
* June 19, 2006
|
|
||||||
|
|
||||||
- (wahern) Removed "big endian" DNS section and RR data integer parser
|
|
||||||
macros from ares_dns.h, which break c-ares on my Sparc64. Bit-wise
|
|
||||||
operations in C operate on logical values. And in any event the octets are
|
|
||||||
already in big-endian (aka network) byte order so they're being reversed
|
|
||||||
(thus the source of the breakage).
|
|
||||||
|
|
||||||
* June 18, 2006
|
|
||||||
|
|
||||||
- William Ahern handles EAGAIN/EWOULDBLOCK errors in most of the I/O calls
|
|
||||||
from area_process.c.
|
|
||||||
|
|
||||||
TODO: Handle one last EAGAIN for a UDP socket send(2) in
|
|
||||||
ares__send_query().
|
|
||||||
|
|
||||||
* May 10, 2006
|
|
||||||
|
|
||||||
- Bram Matthys brought my attention to a libtool peculiarity where detecting
|
|
||||||
things such as C++ compiler actually is a bad thing and since we don't need
|
|
||||||
that detection I added a work-around, much inspired by a previous patch by
|
|
||||||
Paolo Bonzini. This also shortens the configure script quite a lot.
|
|
||||||
|
|
||||||
* May 3, 2006
|
|
||||||
|
|
||||||
- Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set makes
|
|
||||||
c-ares call a callback on socket state changes. A better way than the
|
|
||||||
ares_getsock() to get full control over the socket state.
|
|
||||||
|
|
||||||
* January 9, 2006
|
|
||||||
|
|
||||||
- Alexander Lazic improved the getservbyport_r() configure check.
|
|
||||||
|
|
||||||
* January 6, 2006
|
|
||||||
|
|
||||||
- Alexander Lazic pointed out that the buildconf should use the ACLOCAL_FLAGS
|
|
||||||
variable for easier controlling what it does and how it runs.
|
|
||||||
|
|
||||||
* January 5, 2006
|
|
||||||
|
|
||||||
- James Bursa fixed c-ares to find the hosts file on RISC OS, and made it
|
|
||||||
build with newer gcc versions that no longer defines "riscos".
|
|
||||||
|
|
||||||
* December 22
|
|
||||||
|
|
||||||
- Daniel Stenberg added ares_getsock() that extracts the set of sockets to
|
|
||||||
wait for action on. Similar to ares_fds() but not restricted to using
|
|
||||||
select() for the waiting.
|
|
||||||
|
|
||||||
* November 25
|
|
||||||
|
|
||||||
- Yang Tse fixed some send() / recv() compiler warnings
|
|
||||||
|
|
||||||
* September 18
|
|
||||||
|
|
||||||
- Added constants that will be used by ares_getaddrinfo
|
|
||||||
|
|
||||||
- Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it
|
|
||||||
is available to ensure it works properly in a threaded environment.
|
|
||||||
|
|
||||||
* September 10
|
|
||||||
|
|
||||||
- configure fix for detecting a member in the sockaddr_in6 struct which failed
|
|
||||||
on ipv6-enabled HP-UX 11.00
|
|
||||||
|
|
||||||
Version 1.3.0 (August 29, 2005)
|
|
||||||
|
|
||||||
* August 21
|
|
||||||
|
|
||||||
- Alfredo Tupone provided a fix for the Windows code in get_iphlpapi_dns_info()
|
|
||||||
when getting the DNS server etc.
|
|
||||||
|
|
||||||
* June 19
|
|
||||||
|
|
||||||
- Added some checks for the addrinfo structure.
|
|
||||||
|
|
||||||
* June 2
|
|
||||||
|
|
||||||
- William Ahern:
|
|
||||||
|
|
||||||
Make UDP sockets non-blocking. I've confirmed that at least on Linux 2.4 a
|
|
||||||
read event can come back from poll() on a valid SOCK_DGRAM socket but
|
|
||||||
recv(2) will still block. This patch doesn't ignore EAGAIN in
|
|
||||||
read_udp_packets(), though maybe it should. (This patch was edited by Daniel
|
|
||||||
Stenberg and a new configure test was added (imported from curl's configure)
|
|
||||||
to properly detect what non-blocking socket approach to use.)
|
|
||||||
|
|
||||||
I'm not quite sure how this was happening, but I've been seeing PTR queries
|
|
||||||
which seem to return empty responses. At least, they were empty when calling
|
|
||||||
ares_expand_name() on the record. Here's a patch which guarantees to
|
|
||||||
NUL-terminate the expanded name. The old behavior failed to NUL-terminate if
|
|
||||||
len was 0, and this was causing strlen() to run past the end of the buffer
|
|
||||||
after calling ares_expand_name() and getting ARES_SUCCESS as the return
|
|
||||||
value. If q is not greater than *s then it's equal and *s is always
|
|
||||||
allocated with at least one byte.
|
|
||||||
|
|
||||||
* May 16
|
|
||||||
|
|
||||||
- Added ares_getnameinfo which mimics the getnameinfo API (another feature
|
|
||||||
that could use testing).
|
|
||||||
|
|
||||||
* May 14
|
|
||||||
|
|
||||||
- Added an inet_ntop function from BIND for systems that do not have it.
|
|
||||||
|
|
||||||
* April 9
|
|
||||||
|
|
||||||
- Made sortlist support IPv6 (this can probably use some testing).
|
|
||||||
|
|
||||||
- Made sortlist support CIDR matching for IPv4.
|
|
||||||
|
|
||||||
* April 8
|
|
||||||
|
|
||||||
- Added preliminary IPv6 support to ares_gethostbyname. Currently, sortlist
|
|
||||||
does not work with IPv6. Also provided an implementation of bitncmp from
|
|
||||||
BIND for systems that do not supply this function. This will be used to add
|
|
||||||
IPv6 support to sortlist.
|
|
||||||
|
|
||||||
- Made ares_gethostbyaddr support IPv6 by specifying AF_INET6 as the family.
|
|
||||||
The function can lookup IPv6 addresses both from files (/etc/hosts) and
|
|
||||||
DNS lookups.
|
|
||||||
|
|
||||||
* April 7
|
|
||||||
|
|
||||||
- Tupone Alfredo fixed includes of arpa/nameser_compat.h to build fine on Mac
|
|
||||||
OS X.
|
|
||||||
|
|
||||||
* April 5
|
|
||||||
|
|
||||||
- Dominick Meglio: Provided implementations of inet_net_pton and inet_pton
|
|
||||||
from BIND for systems that do not include these functions.
|
|
||||||
|
|
||||||
* March 11, 2005
|
|
||||||
|
|
||||||
- Dominick Meglio added ares_parse_aaaa_reply.c and did various
|
|
||||||
adjustments. The first little steps towards IPv6 support!
|
|
||||||
|
|
||||||
* November 7
|
|
||||||
|
|
||||||
- Fixed the VC project and makefile to use ares_cancel and ares_version
|
|
||||||
|
|
||||||
* October 24
|
|
||||||
|
|
||||||
- The released ares_version.h from 1.2.1 says 1.2.0 due to a maketgz flaw.
|
|
||||||
This is now fixed.
|
|
||||||
|
|
||||||
Version 1.2.1 (October 20, 2004)
|
|
||||||
|
|
||||||
* September 29
|
|
||||||
|
|
||||||
- Henrik Stoerner fix: got a report that Tru64 Unix (the unix from Digital
|
|
||||||
when they made Alpha's) uses /etc/svc.conf for the purpose fixed below for
|
|
||||||
other OSes. He made c-ares check for and understand it if present.
|
|
||||||
|
|
||||||
- Now c-ares will use local host name lookup _before_ DNS resolving by default
|
|
||||||
if nothing else is told.
|
|
||||||
|
|
||||||
* September 26
|
|
||||||
|
|
||||||
- Henrik Stoerner: found out that c-ares does not look at the /etc/host.conf
|
|
||||||
file to determine the sequence in which to search /etc/hosts and DNS. So on
|
|
||||||
systems where this order is defined by /etc/host.conf instead of a "lookup"
|
|
||||||
entry in /etc/resolv.conf, c-ares will always default to looking in DNS
|
|
||||||
first, and /etc/hosts second.
|
|
||||||
|
|
||||||
c-ares now looks at
|
|
||||||
|
|
||||||
1) resolv.conf (for the "lookup" line);
|
|
||||||
2) nsswitch.fon (for the "hosts:" line);
|
|
||||||
3) host.conf (for the "order" line).
|
|
||||||
|
|
||||||
First match wins.
|
|
||||||
|
|
||||||
- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is
|
|
||||||
located in a static location. It assumed
|
|
||||||
C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact,
|
|
||||||
the location of the HOSTS file can be changed via a registry setting.
|
|
||||||
|
|
||||||
There is a key called DatabasePath which specifies the path to the HOSTS
|
|
||||||
file:
|
|
||||||
http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx
|
|
||||||
|
|
||||||
The patch will make c-ares correctly consult the registry for the location
|
|
||||||
of this file.
|
|
||||||
|
|
||||||
* August 29
|
|
||||||
|
|
||||||
- Gisle Vanem fixed the MSVC build files.
|
|
||||||
|
|
||||||
* August 20
|
|
||||||
|
|
||||||
- Gisle Vanem made c-ares build and work with his Watt-32 TCP/IP stack.
|
|
||||||
|
|
||||||
* August 13
|
|
||||||
|
|
||||||
- Harshal Pradhan made a minor syntax change in ares_init.c to make it build
|
|
||||||
fine with MSVC 7.1
|
|
||||||
|
|
||||||
* July 24
|
|
||||||
|
|
||||||
- Made the lib get built static only if --enable-debug is used.
|
|
||||||
|
|
||||||
- Gisle Vanem fixed:
|
|
||||||
|
|
||||||
Basically in loops like handle_errors(), 'query->next' was assigned a local
|
|
||||||
variable and then query was referenced after the memory was freed by
|
|
||||||
next_server(). I've changed that so next_server() and end_query() returns
|
|
||||||
the next query. So callers should use this ret-value.
|
|
||||||
|
|
||||||
The next problem was that 'server->tcp_buffer_pos' had a random value at
|
|
||||||
entry to 1st recv() (luckily causing Winsock to return ENOBUFS).
|
|
||||||
|
|
||||||
I've also added a ares_writev() for Windows to streamline the code a bit
|
|
||||||
more.
|
|
||||||
|
|
||||||
* July 20
|
|
||||||
- Fixed a few variable return types for some system calls. Made configure
|
|
||||||
check for ssize_t to make it possible to use that when receiving the send()
|
|
||||||
error code. This is necessary to prevent compiler warnings on some systems.
|
|
||||||
|
|
||||||
- Made configure create config.h, and all source files now include setup.h that
|
|
||||||
might include the proper config.h (or a handicrafted alternative).
|
|
||||||
|
|
||||||
- Switched to 'ares_socket_t' type for sockets in ares, since Windows don't
|
|
||||||
use 'int' for that.
|
|
||||||
|
|
||||||
- automake-ified and libool-ified c-ares. Now it builds libcares as a shared
|
|
||||||
lib on most platforms if wanted. (This bloated the size of the release
|
|
||||||
archive with another 200K!)
|
|
||||||
|
|
||||||
- Makefile.am now uses Makefile.inc for the c sources, h headers and man
|
|
||||||
pages, to make it easier for other makefiles to use the exact same set of
|
|
||||||
files.
|
|
||||||
|
|
||||||
- Adjusted 'maketgz' to use the new automake magic when building distribution
|
|
||||||
archives.
|
|
||||||
|
|
||||||
- Anyone desires HTML and/or PDF versions of the man pages in the release
|
|
||||||
archives?
|
|
||||||
|
|
||||||
* July 3
|
|
||||||
- G<>nter Knauf made c-ares build and run on Novell Netware.
|
|
||||||
|
|
||||||
* July 1
|
|
||||||
- Gisle Vanem provided Makefile.dj to build with djgpp, added a few more djgpp
|
|
||||||
fixes and made ares not use 'errno' to provide further info on Windows.
|
|
||||||
|
|
||||||
* June 30
|
|
||||||
- Gisle Vanem made it build with djgpp and run fine with the Watt-32 stack.
|
|
||||||
|
|
||||||
* June 10
|
|
||||||
- Gisle Vanem's init patch for Windows:
|
|
||||||
|
|
||||||
The init_by_resolv_conf() function fetches the DNS-server(s)
|
|
||||||
from a series of registry branches.
|
|
||||||
|
|
||||||
This can be wrong in the case where DHCP has assigned nameservers, but the
|
|
||||||
user has overridden these servers with other prefered settings. Then it's
|
|
||||||
wrong to use the DHCPNAMESERVER setting in registry.
|
|
||||||
|
|
||||||
In the case of no global DHCP-assigned or fixed servers, but DNS server(s)
|
|
||||||
per adapter, one has to query the adapter branches. But how can c-ares know
|
|
||||||
which adapter is valid for use? AFAICS it can't. There could be one adapter
|
|
||||||
that is down (e.g. a VPN adapter).
|
|
||||||
|
|
||||||
So it's better to leave this to the IP Helper API (iphlapi) available in
|
|
||||||
Win-98/2000 and later. My patch falls-back to the old way if not available.
|
|
||||||
|
|
||||||
* June 8
|
|
||||||
- James Bursa fixed an init issue for RISC OS.
|
|
||||||
|
|
||||||
* May 11
|
|
||||||
- Nico Stappenbelt reported that when processing domain and search lines in
|
|
||||||
the resolv.conf file, the first entry encountered is processed and used as
|
|
||||||
the search list. According to the manual pages for both Linux, Solaris and
|
|
||||||
Tru64, the last entry of either a domain or a search field is used.
|
|
||||||
|
|
||||||
This is now adjusted in the code
|
|
||||||
|
|
||||||
Version 1.2.0 (April 13, 2004)
|
|
||||||
|
|
||||||
* April 2, 2004
|
|
||||||
- Updated various man pages to look nicer when converted to HTML on the web
|
|
||||||
site.
|
|
||||||
|
|
||||||
* April 1, 2004
|
|
||||||
- Dirk Manske provided a new function that is now named ares_cancel(). It is
|
|
||||||
used to cancel/cleanup a resolve/request made using ares functions on the
|
|
||||||
given ares channel. It does not destroy/kill the ares channel itself.
|
|
||||||
|
|
||||||
- Dominick Meglio cleaned up the formatting in several man pages.
|
|
||||||
|
|
||||||
* March 30, 2004
|
|
||||||
- Dominick Meglio's new ares_expand_string. A helper function when decoding
|
|
||||||
incoming DNS packages.
|
|
||||||
|
|
||||||
- Daniel Stenberg modified the Makefile.in to use a for loop for the man page
|
|
||||||
installation to improve overview and make it easier to add man pages.
|
|
||||||
|
|
||||||
Version 1.1.0 (March 11, 2004)
|
|
||||||
|
|
||||||
* March 9, 2004
|
|
||||||
- Gisle Vanem improved build on Windows.
|
|
||||||
|
|
||||||
* February 25, 2004
|
|
||||||
- Dan Fandrich found a flaw in the Feb 22 fix.
|
|
||||||
|
|
||||||
- Added better configure --enable-debug logic (taken from the curl configure
|
|
||||||
script). Added acinclude.m4 to the tarball.
|
|
||||||
|
|
||||||
* February 23, 2004
|
|
||||||
- Removed ares_free_errmem(), the function, the file and the man page. It was
|
|
||||||
not used and it did nothing.
|
|
||||||
|
|
||||||
- Fixed a lot of code that wasn't "64bit clean" and thus caused a lot of
|
|
||||||
compiler warnings on picky compilers.
|
|
||||||
|
|
||||||
* February 22, 2004
|
|
||||||
- Dominick Meglio made ares init support multiple name servers in the
|
|
||||||
NameServer key on Windows.
|
|
||||||
|
|
||||||
* February 16, 2004
|
|
||||||
- Modified ares_private.h to include libcurl's memory debug header if
|
|
||||||
CURLDEBUG is set. This makes all the ares-functions supervised properly by
|
|
||||||
the curl test suite. This also forced me to add inclusion of the
|
|
||||||
ares_private.h header in a few more files that are using some kind of
|
|
||||||
memory-related resources.
|
|
||||||
|
|
||||||
- Made the makefile only build ahost and adig if 'make demos' is used.
|
|
||||||
|
|
||||||
* February 10, 2004
|
|
||||||
- Dirk Manske made ares_version.h installed with 'make install'
|
|
||||||
|
|
||||||
* February 4, 2004
|
|
||||||
- ares_free_errmem() is subject for removal, it is simply present for future
|
|
||||||
purposes, and since we removed the extra parameter in strerror() it won't
|
|
||||||
be used by c-ares!
|
|
||||||
- configure --enable-debug now enables picky compiler options if gcc is used
|
|
||||||
- fixed several compiler warnings --enable-debug showed and Joerg Mueller-Tolk
|
|
||||||
reported
|
|
||||||
|
|
||||||
Version 1.0.0 (February 3, 2004)
|
|
||||||
|
|
||||||
* February 3, 2004
|
|
||||||
- now we produce the libcares.a library instead of the previous libares.a
|
|
||||||
since we are no longer compatible
|
|
||||||
|
|
||||||
* February 2, 2004
|
|
||||||
|
|
||||||
- ares_strerror() has one argument less. This is the first official
|
|
||||||
modification of the existing provided ares API.
|
|
||||||
|
|
||||||
* January 29, 2004
|
|
||||||
|
|
||||||
- Dirk Manske fixed how the socket is set non-blocking.
|
|
||||||
|
|
||||||
* January 4, 2004
|
|
||||||
|
|
||||||
- Dominick Meglio made the private gettimeofday() become ares_gettimeofday()
|
|
||||||
instead in order to not pollute the name space and risk colliding with
|
|
||||||
other libraries' versions of this function.
|
|
||||||
|
|
||||||
* October 24, 2003. Daniel Stenberg
|
|
||||||
|
|
||||||
Added ares_version().
|
|
||||||
|
|
||||||
Version 1.0-pre1 (8 October 2003)
|
|
||||||
|
|
||||||
- James Bursa made it run on RISC OS
|
|
||||||
|
|
||||||
- Dominick Meglio made it run fine on NT4
|
|
||||||
|
|
||||||
- Duncan Wilcox made it work fine on Mac OS X
|
|
||||||
|
|
||||||
- Daniel Stenberg adjusted the windows port
|
|
||||||
|
|
||||||
- liren at vivisimo.com made the initial windows port
|
|
||||||
|
|
||||||
* Imported the sources from ares 1.1.1
|
|
||||||
117
ares/Makefile.am
117
ares/Makefile.am
@@ -1,117 +0,0 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
|
||||||
|
|
||||||
# Specify our include paths here, and do it relative to $(top_srcdir) and
|
|
||||||
# $(top_builddir), to ensure that these paths which belong to the library
|
|
||||||
# being currently built and tested are searched before the library which
|
|
||||||
# might possibly already be installed in the system.
|
|
||||||
#
|
|
||||||
# When using the low-level hard-hacking memory leak tracking code from
|
|
||||||
# libcurl the generated curl/curlbuild.h file must also be reachable.
|
|
||||||
# Using the libcurl lowlevel code from within c-ares library is ugly and
|
|
||||||
# only works when c-ares is built and linked with a similarly debug-build
|
|
||||||
# libcurl, but we do this anyway for convenience.
|
|
||||||
#
|
|
||||||
# $(top_builddir)/../include is for libcurl's generated curl/curlbuild.h file
|
|
||||||
# $(top_builddir) is for c-ares's generated config.h file
|
|
||||||
# $(top_srcdir) is for c-ares's lib/setup.h and other "c-ares-private" files
|
|
||||||
|
|
||||||
if CURLDEBUG
|
|
||||||
INCLUDES = -I$(top_builddir)/../include \
|
|
||||||
-I$(top_builddir) \
|
|
||||||
-I$(top_srcdir)
|
|
||||||
else
|
|
||||||
INCLUDES = -I$(top_builddir) \
|
|
||||||
-I$(top_srcdir)
|
|
||||||
endif
|
|
||||||
|
|
||||||
lib_LTLIBRARIES = libcares.la
|
|
||||||
|
|
||||||
man_MANS = $(MANPAGES)
|
|
||||||
|
|
||||||
MSVCFILES = vc/vc.dsw vc/acountry/acountry.dsp vc/adig/adig.dsp \
|
|
||||||
vc/ahost/ahost.dsp vc/areslib/areslib.dsp vc/areslib/areslib.dsw
|
|
||||||
|
|
||||||
if DEBUGBUILD
|
|
||||||
PROGS =
|
|
||||||
else
|
|
||||||
PROGS = ahost adig acountry
|
|
||||||
endif
|
|
||||||
|
|
||||||
noinst_PROGRAMS =$(PROGS)
|
|
||||||
|
|
||||||
# adig and ahost are just sample programs and thus not mentioned with the
|
|
||||||
# regular sources and headers
|
|
||||||
EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
|
|
||||||
Makefile.m32 Makefile.netware Makefile.vc6 $(man_MANS) $(MSVCFILES) \
|
|
||||||
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
|
|
||||||
TODO
|
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
|
||||||
pkgconfig_DATA = libcares.pc
|
|
||||||
|
|
||||||
VER=-version-info 2:0:0
|
|
||||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
|
||||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
|
||||||
# 1.
|
|
||||||
#
|
|
||||||
# If either revision or age are omitted, they default to 0. Also note that age
|
|
||||||
# must be less than or equal to the current interface number.
|
|
||||||
#
|
|
||||||
# Here are a set of rules to help you update your library version information:
|
|
||||||
#
|
|
||||||
# 1.Start with version information of 0:0:0 for each libtool library.
|
|
||||||
#
|
|
||||||
# 2.Update the version information only immediately before a public release of
|
|
||||||
# your software. More frequent updates are unnecessary, and only guarantee
|
|
||||||
# that the current interface number gets larger faster.
|
|
||||||
#
|
|
||||||
# 3.If the library source code has changed at all since the last update, then
|
|
||||||
# increment revision (c:r+1:a)
|
|
||||||
#
|
|
||||||
# 4.If any interfaces have been added, removed, or changed since the last
|
|
||||||
# update, increment current, and set revision to 0. (c+1:r=0:a)
|
|
||||||
#
|
|
||||||
# 5.If any interfaces have been added since the last public release, then
|
|
||||||
# increment age. (c:r:a+1)
|
|
||||||
#
|
|
||||||
# 6.If any interfaces have been removed since the last public release, then
|
|
||||||
# set age to 0. (c:r:a=0)
|
|
||||||
#
|
|
||||||
|
|
||||||
if NO_UNDEFINED
|
|
||||||
# The -no-undefined flag is crucial for this to build fine on some platforms
|
|
||||||
UNDEF = -no-undefined
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
libcares_la_LDFLAGS = $(UNDEF) $(VER)
|
|
||||||
|
|
||||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
libcares_la_SOURCES = $(CSOURCES) $(HHEADERS)
|
|
||||||
|
|
||||||
# where to install the c-ares headers
|
|
||||||
libcares_ladir = $(includedir)
|
|
||||||
# what headers to install on 'make install':
|
|
||||||
libcares_la_HEADERS = ares.h ares_version.h ares_dns.h
|
|
||||||
|
|
||||||
ahost_SOURCES = ahost.c ares_getopt.c ares_getopt.h
|
|
||||||
ahost_LDADD = $(top_builddir)/$(lib_LTLIBRARIES)
|
|
||||||
|
|
||||||
adig_SOURCES = adig.c ares_getopt.c ares_getopt.h
|
|
||||||
adig_LDADD = $(top_builddir)/$(lib_LTLIBRARIES)
|
|
||||||
|
|
||||||
acountry_SOURCES = acountry.c ares_getopt.c ares_getopt.h
|
|
||||||
acountry_LDADD = $(top_builddir)/$(lib_LTLIBRARIES)
|
|
||||||
|
|
||||||
# Make files named *.dist replace the file without .dist extension
|
|
||||||
dist-hook:
|
|
||||||
find $(distdir) -name "*.dist" -exec rm {} \;
|
|
||||||
(distit=`find $(srcdir) -name "*.dist"`; \
|
|
||||||
for file in $$distit; do \
|
|
||||||
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
|
|
||||||
cp $$file $(distdir)$$strip; \
|
|
||||||
done)
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#
|
|
||||||
# c-ares Makefile for djgpp/gcc/Watt-32.
|
|
||||||
# By Gisle Vanem <giva@bgnett.no> 2004.
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
TOPDIR = ..
|
|
||||||
|
|
||||||
include ../packages/DOS/common.dj
|
|
||||||
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET \
|
|
||||||
-DHAVE_IOCTLSOCKET_FIONBIO -DHAVE_STRUCT_IN6_ADDR \
|
|
||||||
-DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID -DHAVE_SYS_TIME_H \
|
|
||||||
-DHAVE_STRUCT_SOCKADDR_IN6 -DHAVE_STRUCT_ADDRINFO \
|
|
||||||
-DHAVE_ARPA_NAMESER_H -DHAVE_ARPA_INET_H -DHAVE_SYS_SOCKET_H \
|
|
||||||
-DHAVE_SYS_UIO_H -DHAVE_NETINET_IN_H -DHAVE_NETINET_TCP_H \
|
|
||||||
-DNS_INADDRSZ=4 -DHAVE_RECV -DHAVE_SEND -DHAVE_GETTIMEOFDAY \
|
|
||||||
-DSEND_TYPE_ARG1='int' -DSEND_QUAL_ARG2='const' \
|
|
||||||
-DSEND_TYPE_ARG2='void*' -DSEND_TYPE_ARG3='int' \
|
|
||||||
-DSEND_TYPE_ARG4='int' -DSEND_TYPE_RETV='int' \
|
|
||||||
-DRECV_TYPE_ARG1='int' -DRECV_TYPE_ARG2='void*' \
|
|
||||||
-DRECV_TYPE_ARG3='int' -DRECV_TYPE_ARG4='int' \
|
|
||||||
-DRECV_TYPE_RETV='int' -DHAVE_STRUCT_TIMEVAL \
|
|
||||||
-Dselect=select_s -Dsocklen_t=int -UHAVE_CONFIG_H \
|
|
||||||
-DRECVFROM_TYPE_ARG1='int' -DRECVFROM_TYPE_ARG2='void' \
|
|
||||||
-DRECVFROM_TYPE_ARG3='int' -DRECVFROM_TYPE_ARG4='int' \
|
|
||||||
-DRECVFROM_TYPE_ARG6='int' -DRECVFROM_TYPE_RETV='int' \
|
|
||||||
-DRECVFROM_TYPE_ARG5='struct sockaddr' -DHAVE_RECVFROM \
|
|
||||||
-DRECVFROM_TYPE_ARG2_IS_VOID -DHAVE_STRDUP -DHAVE_NETDB_H \
|
|
||||||
-DHAVE_STRCASECMP -DHAVE_STRNCASECMP -DHAVE_GETHOSTNAME
|
|
||||||
|
|
||||||
LDFLAGS = -s
|
|
||||||
|
|
||||||
ifeq ($(USE_DEBUG),1)
|
|
||||||
EX_LIBS = ../lib/libcurl.a
|
|
||||||
OBJ_HACK = $(OBJECTS)
|
|
||||||
else
|
|
||||||
OBJ_HACK = libcares.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_SSL),1)
|
|
||||||
EX_LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_ZLIB),1)
|
|
||||||
EX_LIBS += $(ZLIB_ROOT)/libz.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_IDNA),1)
|
|
||||||
EX_LIBS += $(LIBIDN_ROOT)/lib/dj_obj/libidn.a -liconv
|
|
||||||
endif
|
|
||||||
|
|
||||||
EX_LIBS += $(WATT32_ROOT)/lib/libwatt.a
|
|
||||||
|
|
||||||
OBJECTS = $(addprefix $(OBJ_DIR)/, $(CSOURCES:.c=.o))
|
|
||||||
|
|
||||||
all: $(OBJ_DIR) libcares.a ahost.exe adig.exe acountry.exe
|
|
||||||
@echo Welcome to c-ares.
|
|
||||||
|
|
||||||
libcares.a: $(OBJECTS)
|
|
||||||
ar rs $@ $?
|
|
||||||
|
|
||||||
ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
|
|
||||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
|
|
||||||
|
|
||||||
adig.exe: adig.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
|
|
||||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
|
|
||||||
|
|
||||||
acountry.exe: acountry.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
|
|
||||||
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJECTS) libcares.a
|
|
||||||
|
|
||||||
vclean realclean: clean
|
|
||||||
rm -f ahost.exe adig.exe acountry.exe depend.dj
|
|
||||||
- rmdir $(OBJ_DIR)
|
|
||||||
|
|
||||||
-include depend.dj
|
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
CSOURCES = ares_fds.c ares_getsock.c ares_process.c ares_free_hostent.c \
|
|
||||||
ares_query.c ares__close_sockets.c ares_free_string.c ares_search.c \
|
|
||||||
ares__get_hostent.c ares_gethostbyaddr.c ares_send.c ares__read_line.c \
|
|
||||||
ares_gethostbyname.c ares_strerror.c ares_cancel.c ares_init.c \
|
|
||||||
ares_timeout.c ares_destroy.c ares_mkquery.c ares_version.c \
|
|
||||||
ares_expand_name.c ares_parse_a_reply.c windows_port.c ares_strdup.c \
|
|
||||||
ares_expand_string.c ares_parse_ptr_reply.c ares_parse_aaaa_reply.c \
|
|
||||||
ares_getnameinfo.c inet_net_pton.c bitncmp.c inet_ntop.c ares_writev.c \
|
|
||||||
ares_parse_ns_reply.c ares_llist.c ares__timeval.c ares_strcasecmp.c
|
|
||||||
|
|
||||||
HHEADERS = ares.h ares_private.h setup.h ares_dns.h ares_version.h \
|
|
||||||
nameser.h inet_net_pton.h inet_ntop.h ares_ipv6.h bitncmp.h setup_once.h \
|
|
||||||
ares_llist.h ares_strdup.h ares_strcasecmp.h ares_writev.h
|
|
||||||
|
|
||||||
MANPAGES= ares_destroy.3 ares_expand_name.3 ares_expand_string.3 ares_fds.3 \
|
|
||||||
ares_free_hostent.3 ares_free_string.3 ares_gethostbyaddr.3 \
|
|
||||||
ares_gethostbyname.3 ares_init.3 ares_init_options.3 ares_mkquery.3 \
|
|
||||||
ares_parse_a_reply.3 ares_parse_ptr_reply.3 ares_process.3 \
|
|
||||||
ares_query.3 ares_search.3 ares_send.3 ares_strerror.3 ares_timeout.3 \
|
|
||||||
ares_version.3 ares_cancel.3 ares_parse_aaaa_reply.3 ares_getnameinfo.3 \
|
|
||||||
ares_getsock.3 ares_parse_ns_reply.3 ares_dup.3 \
|
|
||||||
ares_destroy_options.3 ares_save_options.3 ares_gethostbyname_file.3 \
|
|
||||||
ares_set_socket_callback.3
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#############################################################
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
## Makefile for building libcares.a with MingW32 (GCC-3.2)
|
|
||||||
## Use: make -f Makefile.m32 [demos]
|
|
||||||
##
|
|
||||||
## Quick hack by Guenter; comments to: /dev/nul
|
|
||||||
#
|
|
||||||
########################################################
|
|
||||||
## Nothing more to do below this line!
|
|
||||||
|
|
||||||
LIB = libcares.a
|
|
||||||
|
|
||||||
CC = gcc
|
|
||||||
LD = gcc
|
|
||||||
RANLIB = ranlib
|
|
||||||
#RM = rm -f
|
|
||||||
|
|
||||||
CFLAGS = -O2 -Wall
|
|
||||||
LDFLAGS = -s
|
|
||||||
LIBS = -lwsock32
|
|
||||||
|
|
||||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
|
|
||||||
|
|
||||||
|
|
||||||
$(LIB): $(OBJLIB)
|
|
||||||
ar cru $@ $^
|
|
||||||
$(RANLIB) $@
|
|
||||||
|
|
||||||
all: $(LIB) demos
|
|
||||||
|
|
||||||
demos: adig.exe ahost.exe acountry.exe
|
|
||||||
|
|
||||||
tags:
|
|
||||||
etags *.[ch]
|
|
||||||
|
|
||||||
%.exe: %.o ares_getopt.o $(LIB)
|
|
||||||
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
||||||
|
|
||||||
$(OBJLIB): ares.h ares_dns.h ares_private.h
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
$(CC) $(CFLAGS) -c $<
|
|
||||||
|
|
||||||
check:
|
|
||||||
|
|
||||||
install:
|
|
||||||
${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
|
|
||||||
${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}
|
|
||||||
${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man3
|
|
||||||
${INSTALL} -m 644 $(LIB) ${DESTDIR}${libdir}
|
|
||||||
${RANLIB} ${DESTDIR}${libdir}/$(LIB)
|
|
||||||
chmod u-w ${DESTDIR}${libdir}/$(LIB)
|
|
||||||
${INSTALL} -m 444 ${srcdir}/ares.h ${DESTDIR}${includedir}
|
|
||||||
${INSTALL} -m 444 ${srcdir}/ares_version.h ${DESTDIR}${includedir}
|
|
||||||
(for man in $(MANPAGES); do \
|
|
||||||
${INSTALL} -m 444 ${srcdir}/$${man} ${DESTDIR}${mandir}/man3; \
|
|
||||||
done)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) ares_getopt.o $(OBJLIB) $(LIB) adig.exe ahost.exe acountry.exe
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
$(RM) config.cache config.log config.status Makefile
|
|
||||||
|
|
||||||
@@ -1,413 +0,0 @@
|
|||||||
#################################################################
|
|
||||||
# $Id$
|
|
||||||
#
|
|
||||||
## Makefile for building libcares (NetWare version - gnu make)
|
|
||||||
## Use: make -f Makefile.netware
|
|
||||||
##
|
|
||||||
## Comments to: Guenter Knauf http://www.gknw.de/phpbb
|
|
||||||
#
|
|
||||||
#################################################################
|
|
||||||
|
|
||||||
# Edit the path below to point to the base of your Novell NDK.
|
|
||||||
ifndef NDKBASE
|
|
||||||
NDKBASE = c:/novell
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef INSTDIR
|
|
||||||
INSTDIR = ../ares-$(LIBCARES_VERSION_STR)-bin-nw
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Edit the vars below to change NLM target settings.
|
|
||||||
TARGETS = adig.nlm ahost.nlm acountry.nlm
|
|
||||||
LTARGET = libcares.$(LIBEXT)
|
|
||||||
VERSION = $(LIBCARES_VERSION)
|
|
||||||
COPYR = Copyright (C) 1996 - 2008, Daniel Stenberg, <daniel@haxx.se>
|
|
||||||
DESCR = cURL $(subst .def,,$(notdir $@)) $(LIBCARES_VERSION_STR) - http://curl.haxx.se
|
|
||||||
MTSAFE = YES
|
|
||||||
STACK = 64000
|
|
||||||
SCREEN = none
|
|
||||||
#EXPORTS =
|
|
||||||
# Comment the line below if you dont want to load protected automatically.
|
|
||||||
#LDRING = 3
|
|
||||||
|
|
||||||
# Edit the var below to point to your lib architecture.
|
|
||||||
ifndef LIBARCH
|
|
||||||
LIBARCH = LIBC
|
|
||||||
endif
|
|
||||||
|
|
||||||
# must be equal to NDEBUG or DEBUG, CURLDEBUG
|
|
||||||
ifndef DB
|
|
||||||
DB = NDEBUG
|
|
||||||
endif
|
|
||||||
# Optimization: -O<n> or debugging: -g
|
|
||||||
ifeq ($(DB),NDEBUG)
|
|
||||||
OPT = -O2
|
|
||||||
OBJDIR = release
|
|
||||||
else
|
|
||||||
OPT = -g
|
|
||||||
OBJDIR = debug
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include the version info retrieved from curlver.h
|
|
||||||
-include $(OBJDIR)/version.inc
|
|
||||||
|
|
||||||
# The following lines defines your compiler.
|
|
||||||
ifdef CWFolder
|
|
||||||
METROWERKS = $(CWFolder)
|
|
||||||
endif
|
|
||||||
ifdef METROWERKS
|
|
||||||
# MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support
|
|
||||||
MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support/Metrowerks Support
|
|
||||||
CC = mwccnlm
|
|
||||||
else
|
|
||||||
CC = gcc
|
|
||||||
endif
|
|
||||||
# a native win32 awk can be downloaded from here:
|
|
||||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
|
||||||
AWK = awk
|
|
||||||
YACC = bison -y
|
|
||||||
CP = cp -afv
|
|
||||||
MKDIR = mkdir
|
|
||||||
# RM = rm -f
|
|
||||||
# if you want to mark the target as MTSAFE you will need a tool for
|
|
||||||
# generating the xdc data for the linker; here's a minimal tool:
|
|
||||||
# http://www.gknw.net/development/prgtools/mkxdc.zip
|
|
||||||
MPKXDC = mkxdc
|
|
||||||
|
|
||||||
# Global flags for all compilers
|
|
||||||
CFLAGS += $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
|
|
||||||
|
|
||||||
ifeq ($(CC),mwccnlm)
|
|
||||||
LD = mwldnlm
|
|
||||||
LDFLAGS = -nostdlib $(PRELUDE) $(OBJEXE) $(<:.def=.o) -o $@ -commandfile
|
|
||||||
AR = mwldnlm
|
|
||||||
ARFLAGS = -nostdlib -type library -o
|
|
||||||
LIBEXT = lib
|
|
||||||
#RANLIB =
|
|
||||||
CFLAGS += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586
|
|
||||||
CFLAGS += -relax_pointers
|
|
||||||
#CFLAGS += -w on
|
|
||||||
ifeq ($(LIBARCH),LIBC)
|
|
||||||
PRELUDE = $(SDK_LIBC)/imports/libcpre.o
|
|
||||||
CFLAGS += -align 4
|
|
||||||
else
|
|
||||||
# PRELUDE = $(SDK_CLIB)/imports/clibpre.o
|
|
||||||
# to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
|
|
||||||
PRELUDE = "$(MWCW_PATH)/libraries/runtime/prelude.obj"
|
|
||||||
# CFLAGS += -include "$(MWCW_PATH)/headers/nlm_clib_prefix.h"
|
|
||||||
CFLAGS += -align 1
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
LD = nlmconv
|
|
||||||
LDFLAGS = -T
|
|
||||||
AR = ar
|
|
||||||
ARFLAGS = -cq
|
|
||||||
LIBEXT = a
|
|
||||||
RANLIB = ranlib
|
|
||||||
CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
|
|
||||||
CFLAGS += -Wall -Wno-format -Wno-uninitialized # -pedantic
|
|
||||||
ifeq ($(LIBARCH),LIBC)
|
|
||||||
PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
|
|
||||||
else
|
|
||||||
# PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o
|
|
||||||
# to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
|
|
||||||
# http://www.gknw.net/development/mk_nlm/gcc_pre.zip
|
|
||||||
PRELUDE = $(NDK_ROOT)/pre/prelude.o
|
|
||||||
CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
NDK_ROOT = $(NDKBASE)/ndk
|
|
||||||
SDK_CLIB = $(NDK_ROOT)/nwsdk
|
|
||||||
SDK_LIBC = $(NDK_ROOT)/libc
|
|
||||||
|
|
||||||
ifeq ($(LIBARCH),LIBC)
|
|
||||||
INCLUDES += -I$(SDK_LIBC)/include
|
|
||||||
# INCLUDES += -I$(SDK_LIBC)/include/nks
|
|
||||||
# INCLUDES += -I$(SDK_LIBC)/include/winsock
|
|
||||||
CFLAGS += -D_POSIX_SOURCE
|
|
||||||
else
|
|
||||||
INCLUDES += -I$(SDK_CLIB)/include/nlm
|
|
||||||
# INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
|
|
||||||
# INCLUDES += -I$(SDK_CLIB)/include
|
|
||||||
endif
|
|
||||||
ifeq ($(DB),CURLDEBUG)
|
|
||||||
INCLUDES += -I../include
|
|
||||||
endif
|
|
||||||
CFLAGS += -I. $(INCLUDES)
|
|
||||||
|
|
||||||
ifeq ($(MTSAFE),YES)
|
|
||||||
XDCOPT = -n
|
|
||||||
endif
|
|
||||||
ifeq ($(MTSAFE),NO)
|
|
||||||
XDCOPT = -u
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(findstring linux,$(OSTYPE)),linux)
|
|
||||||
DL = '
|
|
||||||
#-include $(NDKBASE)/nlmconv/ncpfs.inc
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
|
||||||
include Makefile.inc
|
|
||||||
|
|
||||||
OBJLIB := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(CSOURCES)))
|
|
||||||
OBJEXE = $(OBJLIB) $(OBJDIR)/ares_getopt.o
|
|
||||||
|
|
||||||
.PHONY: lib nlm prebuild dist install clean
|
|
||||||
|
|
||||||
lib: prebuild $(LTARGET)
|
|
||||||
|
|
||||||
nlm: prebuild $(TARGETS)
|
|
||||||
|
|
||||||
prebuild: $(OBJDIR) $(OBJDIR)/version.inc config.h
|
|
||||||
|
|
||||||
install: $(INSTDIR) all
|
|
||||||
@$(CP) *.nlm $(INSTDIR)
|
|
||||||
@$(CP) ../CHANGES $(INSTDIR)
|
|
||||||
@$(CP) ../COPYING $(INSTDIR)
|
|
||||||
@$(CP) ../README $(INSTDIR)
|
|
||||||
@$(CP) ../RELEASE-NOTES $(INSTDIR)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-$(RM) $(LTARGET) $(TARGETS) config.h
|
|
||||||
-$(RM) -r $(OBJDIR)
|
|
||||||
-$(RM) -r arpa
|
|
||||||
|
|
||||||
%.$(LIBEXT): $(OBJLIB)
|
|
||||||
@echo Creating $@
|
|
||||||
@-$(RM) $@
|
|
||||||
@$(AR) $(ARFLAGS) $@ $^
|
|
||||||
ifdef RANLIB
|
|
||||||
@$(RANLIB) $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
%.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc $(OBJEXE)
|
|
||||||
@echo Linking $@
|
|
||||||
@-$(RM) $@
|
|
||||||
@$(LD) $(LDFLAGS) $<
|
|
||||||
|
|
||||||
$(OBJDIR) $(INSTDIR):
|
|
||||||
@$(MKDIR) $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
# @echo Compiling $<
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/version.inc: ares_version.h $(OBJDIR)
|
|
||||||
@echo Creating $@
|
|
||||||
@$(AWK) -f get_ver.awk $< > $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.xdc: Makefile.netware
|
|
||||||
@echo Creating $@
|
|
||||||
@$(MPKXDC) $(XDCOPT) $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.def: Makefile.netware
|
|
||||||
@echo Creating $@
|
|
||||||
@echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
|
|
||||||
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
|
|
||||||
@echo $(DL)# All your changes will be lost!!$(DL) >> $@
|
|
||||||
@echo $(DL)#$(DL) >> $@
|
|
||||||
@echo $(DL)copyright "$(COPYR)"$(DL) >> $@
|
|
||||||
@echo $(DL)description "$(DESCR)"$(DL) >> $@
|
|
||||||
@echo $(DL)version $(VERSION)$(DL) >> $@
|
|
||||||
ifdef NLMTYPE
|
|
||||||
@echo $(DL)type $(NLMTYPE)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef STACK
|
|
||||||
@echo $(DL)stack $(STACK)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef SCREEN
|
|
||||||
@echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
|
|
||||||
else
|
|
||||||
@echo $(DL)screenname "DEFAULT"$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifeq ($(DB),DEBUG)
|
|
||||||
@echo $(DL)debug$(DL) >> $@
|
|
||||||
endif
|
|
||||||
@echo $(DL)threadname "$^"$(DL) >> $@
|
|
||||||
ifdef XDCOPT
|
|
||||||
@echo $(DL)xdcdata $(@:.def=.xdc)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifeq ($(LDRING),0)
|
|
||||||
@echo $(DL)flag_on 16$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifeq ($(LDRING),3)
|
|
||||||
@echo $(DL)flag_on 512$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifeq ($(LIBARCH),CLIB)
|
|
||||||
@echo $(DL)start _Prelude$(DL) >> $@
|
|
||||||
@echo $(DL)exit _Stop$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_CLIB)/imports/socklib.imp$(DL) >> $@
|
|
||||||
@echo $(DL)module clib$(DL) >> $@
|
|
||||||
else
|
|
||||||
@echo $(DL)flag_on 64$(DL) >> $@
|
|
||||||
@echo $(DL)pseudopreemption$(DL) >> $@
|
|
||||||
@echo $(DL)start _LibCPrelude$(DL) >> $@
|
|
||||||
@echo $(DL)exit _LibCPostlude$(DL) >> $@
|
|
||||||
@echo $(DL)check _LibCCheckUnload$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@
|
|
||||||
@echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@
|
|
||||||
@echo $(DL)module libc$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef MODULES
|
|
||||||
@echo $(DL)module $(MODULES)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef EXPORTS
|
|
||||||
@echo $(DL)export $(EXPORTS)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifdef IMPORTS
|
|
||||||
@echo $(DL)import $(IMPORTS)$(DL) >> $@
|
|
||||||
endif
|
|
||||||
ifeq ($(LD),nlmconv)
|
|
||||||
@echo $(DL)input $(PRELUDE)$(DL) >> $@
|
|
||||||
@echo $(DL)input $(OBJEXE)$(DL) >> $@
|
|
||||||
@echo $(DL)input $(@:.def=.o)$(DL) >> $@
|
|
||||||
@echo $(DL)output $(notdir $(@:.def=.nlm))$(DL) >> $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
config.h: Makefile.netware
|
|
||||||
@echo Creating $@
|
|
||||||
@echo $(DL)/* $@ for NetWare target.$(DL) > $@
|
|
||||||
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
|
|
||||||
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
|
|
||||||
@echo $(DL)*/$(DL) >> $@
|
|
||||||
@echo $(DL)#ifndef NETWARE$(DL) >> $@
|
|
||||||
@echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
|
|
||||||
@echo $(DL)#endif$(DL) >> $@
|
|
||||||
@echo $(DL)#define VERSION "$(LIBCARES_VERSION_STR)"$(DL) >> $@
|
|
||||||
@echo $(DL)#define PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/"$(DL) >> $@
|
|
||||||
ifeq ($(LIBARCH),CLIB)
|
|
||||||
@echo $(DL)#define OS "i586-pc-clib-NetWare"$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRICMP 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRNICMP 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define NETDB_USE_INTERNET 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG2 char *$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG3 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_RETV int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG2 char$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG3 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG6 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_RETV int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG2 char *$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
|
||||||
else
|
|
||||||
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRTOLL 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_AF_INET6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_PF_INET6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_FREEADDRINFO 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETADDRINFO 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_IN6_ADDR 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_SOCKADDR_IN6 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG2 void *$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG3 size_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECV_TYPE_RETV ssize_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG2 void$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG3 size_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG6 size_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_RETV ssize_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define RECVFROM_TYPE_ARG2_IS_VOID 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG2 void *$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG3 size_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
|
||||||
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
|
||||||
endif
|
|
||||||
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETHOSTNAME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_LL 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_RECV 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_RECVFROM 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SEND 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SIGNAL_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SIG_ATOMIC_T 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_ADDRINFO 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_STRUCT_TIMEVAL 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_IOCTL_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_UTIME 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_WRITEV 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
|
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
|
|
||||||
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
|
|
||||||
ifdef NW_WINSOCK
|
|
||||||
@echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
|
|
||||||
else
|
|
||||||
@echo $(DL)#define HAVE_SYS_TYPES_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_SOCKET_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_SYS_SOCKIO_H 1$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_NETDB_H 1$(DL) >> $@
|
|
||||||
endif
|
|
||||||
@echo $(DL)#ifdef __GNUC__$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_VARIADIC_MACROS_GCC 1$(DL) >> $@
|
|
||||||
@echo $(DL)#else$(DL) >> $@
|
|
||||||
@echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
|
|
||||||
@echo $(DL)#endif$(DL) >> $@
|
|
||||||
ifdef OLD_NOVELLSDK
|
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
# $Id$
|
|
||||||
#
|
|
||||||
# C-ares makefile for MSVC6+
|
|
||||||
# G. Vanem <giva@bgnett.no>.
|
|
||||||
#
|
|
||||||
|
|
||||||
CFG_MODEL = MD
|
|
||||||
DEBUG_MODEL = d
|
|
||||||
USE_WATT32 = 0
|
|
||||||
|
|
||||||
#
|
|
||||||
# Configurations:
|
|
||||||
# -MD - msvcrt.dll, threads, release (normal)
|
|
||||||
# -MDd - msvcrtd.dll, threads, debug
|
|
||||||
# -ML - libc, no threads, release
|
|
||||||
# -MLd - libc, no threads, debug
|
|
||||||
# -MT - libc, threads, release
|
|
||||||
# -MTd - libc, threads, debug
|
|
||||||
|
|
||||||
CC = cl
|
|
||||||
|
|
||||||
CFLAGS = -nologo -$(CFG_MODEL)$(DEBUG_MODEL) -W3 -Yd -Zi
|
|
||||||
LDFLAGS = -machine:i386 -map
|
|
||||||
|
|
||||||
OBJ_DIR = VC6_obj
|
|
||||||
DEF_FILE = cares.def
|
|
||||||
|
|
||||||
!if "$(USE_WATT32)" == "1"
|
|
||||||
CFLAGS = $(CFLAGS) -UWIN32 -DWATT32 -D_USE_32BIT_TIME_T -I$(WATT_ROOT)\inc
|
|
||||||
EX_LIBS = $(WATT_ROOT)\lib\wattcpvc_imp.lib
|
|
||||||
|
|
||||||
!else
|
|
||||||
CFLAGS = $(CFLAGS) -DWIN32 -DWIN32_LEAN_AND_MEAN
|
|
||||||
EX_LIBS = advapi32.lib ws2_32.lib
|
|
||||||
!endif
|
|
||||||
|
|
||||||
!if "$(DEBUG_MODEL)" == "d"
|
|
||||||
CFLAGS = $(CFLAGS) -D_DEBUG -GZ
|
|
||||||
LDFLAGS = $(LDFLAGS) -debug -fixed:no
|
|
||||||
|
|
||||||
!else
|
|
||||||
CFLAGS = $(CFLAGS) -O2 -Og
|
|
||||||
LDFLAGS = $(LDFLAGS) -release
|
|
||||||
!endif
|
|
||||||
|
|
||||||
OBJECTS = $(OBJ_DIR)\ares_fds.obj \
|
|
||||||
$(OBJ_DIR)\ares_process.obj \
|
|
||||||
$(OBJ_DIR)\ares_free_hostent.obj \
|
|
||||||
$(OBJ_DIR)\ares_query.obj \
|
|
||||||
$(OBJ_DIR)\ares__close_sockets.obj \
|
|
||||||
$(OBJ_DIR)\ares_free_string.obj \
|
|
||||||
$(OBJ_DIR)\ares_search.obj \
|
|
||||||
$(OBJ_DIR)\ares__get_hostent.obj \
|
|
||||||
$(OBJ_DIR)\ares_gethostbyaddr.obj \
|
|
||||||
$(OBJ_DIR)\ares_getsock.obj \
|
|
||||||
$(OBJ_DIR)\ares_send.obj \
|
|
||||||
$(OBJ_DIR)\ares__read_line.obj \
|
|
||||||
$(OBJ_DIR)\ares_gethostbyname.obj \
|
|
||||||
$(OBJ_DIR)\ares_getnameinfo.obj \
|
|
||||||
$(OBJ_DIR)\ares_strcasecmp.obj \
|
|
||||||
$(OBJ_DIR)\ares_strerror.obj \
|
|
||||||
$(OBJ_DIR)\ares_cancel.obj \
|
|
||||||
$(OBJ_DIR)\ares_init.obj \
|
|
||||||
$(OBJ_DIR)\ares_llist.obj \
|
|
||||||
$(OBJ_DIR)\ares_timeout.obj \
|
|
||||||
$(OBJ_DIR)\ares__timeval.obj \
|
|
||||||
$(OBJ_DIR)\ares_destroy.obj \
|
|
||||||
$(OBJ_DIR)\ares_mkquery.obj \
|
|
||||||
$(OBJ_DIR)\ares_version.obj \
|
|
||||||
$(OBJ_DIR)\ares_expand_name.obj \
|
|
||||||
$(OBJ_DIR)\ares_parse_a_reply.obj \
|
|
||||||
$(OBJ_DIR)\ares_parse_aaaa_reply.obj \
|
|
||||||
$(OBJ_DIR)\ares_parse_ns_reply.obj \
|
|
||||||
$(OBJ_DIR)\windows_port.obj \
|
|
||||||
$(OBJ_DIR)\ares_expand_string.obj \
|
|
||||||
$(OBJ_DIR)\ares_parse_ptr_reply.obj \
|
|
||||||
$(OBJ_DIR)\ares_writev.obj \
|
|
||||||
$(OBJ_DIR)\bitncmp.obj \
|
|
||||||
$(OBJ_DIR)\inet_net_pton.obj \
|
|
||||||
$(OBJ_DIR)\inet_ntop.obj
|
|
||||||
|
|
||||||
all: $(OBJ_DIR) cares.lib cares.dll cares_imp.lib ahost.exe adig.exe acountry.exe
|
|
||||||
@echo Welcome to c-ares library and examples
|
|
||||||
|
|
||||||
$(OBJ_DIR):
|
|
||||||
mkdir $(OBJ_DIR)
|
|
||||||
|
|
||||||
cares.lib: $(OBJ_DIR) $(OBJECTS)
|
|
||||||
lib -nologo -out:$@ $(OBJECTS)
|
|
||||||
|
|
||||||
cares_imp.lib cares.dll: $(OBJ_DIR) $(DEF_FILE) $(OBJECTS)
|
|
||||||
link $(LDFLAGS) -dll -implib:cares_imp.lib -out:cares.dll \
|
|
||||||
-def:$(DEF_FILE) $(OBJECTS) $(EX_LIBS)
|
|
||||||
|
|
||||||
$(DEF_FILE): $(OBJECTS) Makefile.VC6
|
|
||||||
@echo ; Generated. DO NOT EDIT > $@
|
|
||||||
@echo LIBRARY cares.dll >> $@
|
|
||||||
@echo EXPORTS >> $@
|
|
||||||
@echo ares_cancel >> $@
|
|
||||||
@echo ares_destroy >> $@
|
|
||||||
@echo ares_expand_name >> $@
|
|
||||||
@echo ares_expand_string >> $@
|
|
||||||
@echo ares_fds >> $@
|
|
||||||
@echo ares_free_hostent >> $@
|
|
||||||
@echo ares_free_string >> $@
|
|
||||||
@echo ares_gethostbyaddr >> $@
|
|
||||||
@echo ares_gethostbyname >> $@
|
|
||||||
@echo ares_getsock >> $@
|
|
||||||
@echo ares_init >> $@
|
|
||||||
@echo ares_init_options >> $@
|
|
||||||
@echo ares_mkquery >> $@
|
|
||||||
@echo ares_parse_a_reply >> $@
|
|
||||||
@echo ares_parse_ptr_reply >> $@
|
|
||||||
@echo ares_parse_ns_reply >> $@
|
|
||||||
@echo ares_process >> $@
|
|
||||||
@echo ares_process_fd >> $@
|
|
||||||
@echo ares_query >> $@
|
|
||||||
@echo ares_search >> $@
|
|
||||||
@echo ares_strerror >> $@
|
|
||||||
@echo ares_strncasecmp >> $@
|
|
||||||
@echo ares_strcasecmp >> $@
|
|
||||||
@echo ares_timeout >> $@
|
|
||||||
@echo ares_version >> $@
|
|
||||||
@echo ares_inet_net_pton >> $@
|
|
||||||
@echo ares_inet_ntop >> $@
|
|
||||||
@echo ares_inet_pton >> $@
|
|
||||||
@echo ares_getnameinfo >> $@
|
|
||||||
@echo ares_parse_aaaa_reply >> $@
|
|
||||||
!if "$(USE_WATT32)" == "0"
|
|
||||||
@echo ares_writev >> $@
|
|
||||||
!endif
|
|
||||||
|
|
||||||
ahost.exe: $(OBJ_DIR) $(OBJ_DIR)\ahost.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib
|
|
||||||
link $(LDFLAGS) -out:$@ $(OBJ_DIR)\ahost.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib $(EX_LIBS)
|
|
||||||
|
|
||||||
adig.exe: $(OBJ_DIR) $(OBJ_DIR)\adig.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib
|
|
||||||
link $(LDFLAGS) -out:$@ $(OBJ_DIR)\adig.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib $(EX_LIBS)
|
|
||||||
|
|
||||||
acountry.exe: $(OBJ_DIR) $(OBJ_DIR)\acountry.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib
|
|
||||||
link $(LDFLAGS) -out:$@ $(OBJ_DIR)\acountry.obj $(OBJ_DIR)\ares_getopt.obj cares_imp.lib $(EX_LIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
- del $(OBJ_DIR)\*.obj *.ilk *.pdb *.pbt *.pbi *.pbo *._xe *.map
|
|
||||||
|
|
||||||
vclean realclean: clean
|
|
||||||
- del $(DEF_FILE) cares.lib cares_imp.* cares.dll
|
|
||||||
- del ahost.exe adig.exe acountry.exe
|
|
||||||
- rd $(OBJ_DIR)
|
|
||||||
|
|
||||||
.c{$(OBJ_DIR)}.obj:
|
|
||||||
$(CC) $(CFLAGS) -Fo$*.obj -c $<
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright "gcc -MM .."
|
|
||||||
#
|
|
||||||
$(OBJ_DIR)\ares_fds.obj: ares_fds.c setup.h setup_once.h ares.h ares_private.h \
|
|
||||||
ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_process.obj: ares_process.c setup.h setup_once.h nameser.h \
|
|
||||||
ares.h ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_free_hostent.obj: ares_free_hostent.c setup.h setup_once.h \
|
|
||||||
ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_query.obj: ares_query.c setup.h setup_once.h nameser.h \
|
|
||||||
ares.h ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares__close_sockets.obj: ares__close_sockets.c setup.h setup_once.h \
|
|
||||||
ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_free_string.obj: ares_free_string.c setup.h setup_once.h ares.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_search.obj: ares_search.c setup.h setup_once.h nameser.h \
|
|
||||||
ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares__get_hostent.obj: ares__get_hostent.c setup.h setup_once.h \
|
|
||||||
ares.h ares_private.h ares_ipv6.h inet_net_pton.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_gethostbyaddr.obj: ares_gethostbyaddr.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_private.h ares_ipv6.h inet_net_pton.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_send.obj: ares_send.c setup.h setup_once.h nameser.h ares.h \
|
|
||||||
ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares__read_line.obj: ares__read_line.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_gethostbyname.obj: ares_gethostbyname.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_private.h ares_ipv6.h inet_net_pton.h bitncmp.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_strcasecmp.obj: ares_strcasecmp.c setup.h setup_once.h ares.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_strerror.obj: ares_strerror.c setup.h setup_once.h ares.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_cancel.obj: ares_cancel.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_init.obj: ares_init.c setup.h setup_once.h nameser.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h inet_net_pton.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_timeout.obj: ares_timeout.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares__timeval.obj: ares__timeval.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_destroy.obj: ares_destroy.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_mkquery.obj: ares_mkquery.c setup.h setup_once.h nameser.h \
|
|
||||||
ares.h ares_dns.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_version.obj: ares_version.c setup.h setup_once.h ares_version.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_expand_name.obj: ares_expand_name.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_parse_a_reply.obj: ares_parse_a_reply.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\windows_port.obj: windows_port.c setup.h setup_once.h nameser.h \
|
|
||||||
ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_expand_string.obj: ares_expand_string.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_parse_ptr_reply.obj: ares_parse_ptr_reply.c setup.h \
|
|
||||||
setup_once.h nameser.h ares.h ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_parse_aaaa_reply.obj: ares_parse_aaaa_reply.c setup.h \
|
|
||||||
setup_once.h nameser.h ares.h ares_dns.h inet_net_pton.h ares_private.h \
|
|
||||||
ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_parse_ns_reply.obj: ares_parse_ns_reply.c setup.h \
|
|
||||||
setup_once.h nameser.h ares.h ares_dns.h ares_private.h ares_ipv6.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_getnameinfo.obj: ares_getnameinfo.c setup.h setup_once.h \
|
|
||||||
nameser.h ares.h ares_private.h ares_ipv6.h inet_ntop.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\inet_net_pton.obj: inet_net_pton.c setup.h setup_once.h nameser.h \
|
|
||||||
ares_ipv6.h inet_net_pton.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\bitncmp.obj: bitncmp.c bitncmp.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\inet_ntop.obj: inet_ntop.c setup.h setup_once.h nameser.h \
|
|
||||||
ares_ipv6.h inet_ntop.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_getopt.obj: ares_getopt.c ares_getopt.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_llist.obj: ares_llist.c setup.h setup_once.h ares.h \
|
|
||||||
ares_private.h ares_llist.h
|
|
||||||
|
|
||||||
$(OBJ_DIR)\ares_writev.obj: ares_writev.c setup.h setup_once.h ares.h \
|
|
||||||
ares_writev.h
|
|
||||||
21
ares/NEWS
21
ares/NEWS
@@ -1,21 +0,0 @@
|
|||||||
Major changes since:
|
|
||||||
* see the CHANGES file
|
|
||||||
|
|
||||||
Major changes in release 1.1.1:
|
|
||||||
* ares should now compile as C++ code (no longer uses reserved word
|
|
||||||
"class").
|
|
||||||
* Added SRV support to adig test program.
|
|
||||||
* Fixed a few error handling bugs in query processing.
|
|
||||||
|
|
||||||
Major changes in release 1.1.0:
|
|
||||||
* Added ares_free_string() function so that memory can be freed in the
|
|
||||||
same layer as it is allocated, a desirable feature in some
|
|
||||||
environments.
|
|
||||||
* A few of the ares_dns.h macros are fixed to use the proper bitwise
|
|
||||||
operator.
|
|
||||||
* Fixed a couple of fenceposts fixed in ares_expand_name()'s
|
|
||||||
bounds-checking.
|
|
||||||
* In process_timeouts(), extract query->next before calling
|
|
||||||
next_server() and possibly freeing the query structure.
|
|
||||||
* Casted arguments to ctype macros casted to unsigned char, since not
|
|
||||||
all char values are valid inputs to those macros according to ANSI.
|
|
||||||
46
ares/README
46
ares/README
@@ -1,46 +0,0 @@
|
|||||||
This is c-ares, a forked version of the original ares. The original ares
|
|
||||||
README follows below, the c-ares specific details are in README.cares
|
|
||||||
|
|
||||||
====================================================================
|
|
||||||
|
|
||||||
This is ares, an asynchronous resolver library. It is intended for
|
|
||||||
applications which need to perform DNS queries without blocking, or
|
|
||||||
need to perform multiple DNS queries in parallel. The primary
|
|
||||||
examples of such applications are servers which communicate with
|
|
||||||
multiple clients and programs with graphical user interfaces.
|
|
||||||
|
|
||||||
This library implementation is not especially portable to crufty old
|
|
||||||
systems like SunOS 4. It assumes a compiler which can handle ANSI C
|
|
||||||
syntax, a system malloc which properly handles realloc(NULL, foo) and
|
|
||||||
free(NULL), and a reasonably up-to-date <arpa/nameser.h>.
|
|
||||||
|
|
||||||
I have attempted to preserve the externally visible behavior of the
|
|
||||||
BIND resolver in nearly all respects. The API of the library is, of
|
|
||||||
course, very different from the synchronous BIND API; instead of
|
|
||||||
invoking a function like res_send() and getting a return value back
|
|
||||||
indicating the number of bytes in the response, you invoke a function
|
|
||||||
like ares_send() and give it a callback function to invoke when the
|
|
||||||
response arrives. You then have to select() on the file descriptors
|
|
||||||
indicated by ares_fds(), with a timeout given by ares_timeout(). You
|
|
||||||
call ares_process() when select() returns.
|
|
||||||
|
|
||||||
Some features are missing from the current version of ares, relative
|
|
||||||
to the BIND resolver:
|
|
||||||
|
|
||||||
* There is no IPV6 support. [not true for c-ares]
|
|
||||||
* There is no hostname verification.
|
|
||||||
* There is no logging of unexpected events.
|
|
||||||
* There is no debugging-oriented logging.
|
|
||||||
* There is no YP support.
|
|
||||||
|
|
||||||
libares requires an ANSI compiler to compile and use. To build the
|
|
||||||
library, just run "./configure" and "make". To install it, run "make
|
|
||||||
install". Run "./configure --help" to see a list of options you can
|
|
||||||
provide to configure to change how the library builds. libares has no
|
|
||||||
data files, so you can move the include file and library around freely
|
|
||||||
without leaving behind any dependencies on old paths. Building the
|
|
||||||
library will also build the "adig" program, a little toy for trying
|
|
||||||
out the library. It doesn't get installed.
|
|
||||||
|
|
||||||
libares is distributed at athena-dist.mit.edu:pub/ATHENA/ares. Please
|
|
||||||
send bug reports and comments to ghudson@mit.edu.
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
c-ares
|
|
||||||
======
|
|
||||||
|
|
||||||
This package is based on ares 1.1.1 (written by Greg Hudson). I decided to
|
|
||||||
fork and release a separate project since the ares author didn't want the
|
|
||||||
improvements that were vital for our use of it.
|
|
||||||
|
|
||||||
This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use
|
|
||||||
within the curl project (hence the letter C) and it makes a nice pun. Also,
|
|
||||||
c-ares is not API compatible with ares: a new name makes that more obvious to
|
|
||||||
the public.
|
|
||||||
|
|
||||||
The full source code is available in the 'c-ares' release archives, and in the
|
|
||||||
'ares' subdir of the curl CVS source repository.
|
|
||||||
|
|
||||||
If you find bugs, correct flaws, have questions or have comments in general in
|
|
||||||
regard to c-ares (or by all means the original ares too), get in touch with us
|
|
||||||
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
|
|
||||||
|
|
||||||
c-ares is of course distributed under the same MIT-style license as the
|
|
||||||
original ares.
|
|
||||||
|
|
||||||
You'll find all c-ares details and news here:
|
|
||||||
|
|
||||||
http://c-ares.haxx.se/
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
This is what's new and changed in the c-ares 1.6.1 release:
|
|
||||||
|
|
||||||
Changed:
|
|
||||||
|
|
||||||
o in6_addr is not used in ares.h anymore, but a private ares_in6_addr is
|
|
||||||
instead declared and used
|
|
||||||
p ares_gethostbyname() now supports 'AF_UNSPEC' as a family for resolving
|
|
||||||
either AF_INET6 or AF_INET
|
|
||||||
|
|
||||||
Fixed:
|
|
||||||
|
|
||||||
o ares_parse_*_reply() functions now return ARES_EBADRESP instead of
|
|
||||||
ARES_EBADNAME if the name in the response failed to decode
|
|
||||||
|
|
||||||
Thanks go to these friendly people for their efforts and contributions:
|
|
||||||
|
|
||||||
Phil Blundell
|
|
||||||
|
|
||||||
Have fun!
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
TODO
|
|
||||||
====
|
|
||||||
|
|
||||||
ares_gethostbyname
|
|
||||||
|
|
||||||
- When built to support IPv6, it needs to also support PF_UNSPEC or similar,
|
|
||||||
so that an application can ask for any protocol and then c-ares would return
|
|
||||||
all known resolves and not just explicitly IPv4 _or_ IPv6 resolves.
|
|
||||||
1732
ares/acinclude.m4
1732
ares/acinclude.m4
File diff suppressed because it is too large
Load Diff
614
ares/acountry.c
614
ares/acountry.c
@@ -1,614 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* IP-address/hostname to country converter.
|
|
||||||
*
|
|
||||||
* Problem; you want to know where IP a.b.c.d is located.
|
|
||||||
*
|
|
||||||
* Use ares_gethostbyname ("d.c.b.a.zz.countries.nerd.dk")
|
|
||||||
* and get the CNAME (host->h_name). Result will be:
|
|
||||||
* CNAME = zz<CC>.countries.nerd.dk with address 127.0.x.y (ver 1) or
|
|
||||||
* CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.x.y (ver 2)
|
|
||||||
*
|
|
||||||
* The 2 letter country code in <CC> and the ISO-3166 country
|
|
||||||
* number in x.y (number = x*256 + y). Version 2 of the protocol is missing
|
|
||||||
* the <CC> number.
|
|
||||||
*
|
|
||||||
* Ref: http://countries.nerd.dk/more.html
|
|
||||||
*
|
|
||||||
* Written by G. Vanem <gvanem@broadpark.no> 2006, 2007
|
|
||||||
*
|
|
||||||
* NB! This program may not be big-endian aware.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(WATT32)
|
|
||||||
#include <winsock.h>
|
|
||||||
#else
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_getopt.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "inet_ntop.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
|
||||||
# include "ares_strdup.h"
|
|
||||||
# define strdup(ptr) ares_strdup(ptr)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRNCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
|
||||||
#define INADDR_NONE 0xffffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
|
|
||||||
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
|
|
||||||
static const char *nerd_ver1 = nerd_fmt + 14;
|
|
||||||
static const char *nerd_ver2 = nerd_fmt + 11;
|
|
||||||
static int verbose = 0;
|
|
||||||
|
|
||||||
#define TRACE(fmt) do { \
|
|
||||||
if (verbose > 0) \
|
|
||||||
printf fmt ; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static void wait_ares(ares_channel channel);
|
|
||||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
|
||||||
static void callback2(void *arg, int status, int timeouts, struct hostent *host);
|
|
||||||
static void find_country_from_cname(const char *cname, struct in_addr addr);
|
|
||||||
|
|
||||||
static void Abort(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
vfprintf(stderr, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
ares_channel channel;
|
|
||||||
int ch, status;
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(WATT32)
|
|
||||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
|
||||||
WSADATA wsaData;
|
|
||||||
WSAStartup(wVersionRequested, &wsaData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while ((ch = ares_getopt(argc, argv, "dvh?")) != -1)
|
|
||||||
switch (ch)
|
|
||||||
{
|
|
||||||
case 'd':
|
|
||||||
#ifdef WATT32
|
|
||||||
dbug_init();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
verbose++;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
case '?':
|
|
||||||
default:
|
|
||||||
Abort(usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc < 1)
|
|
||||||
Abort(usage);
|
|
||||||
|
|
||||||
status = ares_init(&channel);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initiate the queries, one per command-line argument. */
|
|
||||||
for ( ; *argv; argv++)
|
|
||||||
{
|
|
||||||
struct in_addr addr;
|
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
/* If this fails, assume '*argv' is a host-name that
|
|
||||||
* must be resolved first
|
|
||||||
*/
|
|
||||||
if (ares_inet_pton(AF_INET, *argv, &addr) != 1)
|
|
||||||
{
|
|
||||||
ares_gethostbyname(channel, *argv, AF_INET, callback2, &addr);
|
|
||||||
wait_ares(channel);
|
|
||||||
if (addr.s_addr == INADDR_NONE)
|
|
||||||
{
|
|
||||||
printf("Failed to lookup %s\n", *argv);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(buf, nerd_fmt,
|
|
||||||
(unsigned int)(addr.s_addr >> 24),
|
|
||||||
(unsigned int)((addr.s_addr >> 16) & 255),
|
|
||||||
(unsigned int)((addr.s_addr >> 8) & 255),
|
|
||||||
(unsigned int)(addr.s_addr & 255));
|
|
||||||
TRACE(("Looking up %s...", buf));
|
|
||||||
fflush(stdout);
|
|
||||||
ares_gethostbyname(channel, buf, AF_INET, callback, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_ares(channel);
|
|
||||||
ares_destroy(channel);
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(WATT32)
|
|
||||||
WSACleanup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wait for the queries to complete.
|
|
||||||
*/
|
|
||||||
static void wait_ares(ares_channel channel)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
struct timeval *tvp, tv;
|
|
||||||
fd_set read_fds, write_fds;
|
|
||||||
int nfds;
|
|
||||||
|
|
||||||
FD_ZERO(&read_fds);
|
|
||||||
FD_ZERO(&write_fds);
|
|
||||||
nfds = ares_fds(channel, &read_fds, &write_fds);
|
|
||||||
if (nfds == 0)
|
|
||||||
break;
|
|
||||||
tvp = ares_timeout(channel, NULL, &tv);
|
|
||||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
|
||||||
ares_process(channel, &read_fds, &write_fds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the callback used when we have the IP-address of interest.
|
|
||||||
* Extract the CNAME and figure out the country-code from it.
|
|
||||||
*/
|
|
||||||
static void callback(void *arg, int status, int timeouts, struct hostent *host)
|
|
||||||
{
|
|
||||||
const char *name = (const char*)arg;
|
|
||||||
const char *cname;
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
(void)timeouts;
|
|
||||||
|
|
||||||
if (!host || status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
printf("Failed to lookup %s: %s\n", name, ares_strerror(status));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE(("\nFound address %s, name %s\n",
|
|
||||||
ares_inet_ntop(AF_INET,(const char*)host->h_addr,buf,sizeof(buf)),
|
|
||||||
host->h_name));
|
|
||||||
|
|
||||||
cname = host->h_name; /* CNAME gets put here */
|
|
||||||
if (!cname)
|
|
||||||
printf("Failed to get CNAME for %s\n", name);
|
|
||||||
else
|
|
||||||
find_country_from_cname(cname, *(struct in_addr*)host->h_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the callback used to obtain the IP-address of the host of interest.
|
|
||||||
*/
|
|
||||||
static void callback2(void *arg, int status, int timeouts, struct hostent *host)
|
|
||||||
{
|
|
||||||
struct in_addr *addr = (struct in_addr*) arg;
|
|
||||||
|
|
||||||
(void)timeouts;
|
|
||||||
if (!host || status != ARES_SUCCESS)
|
|
||||||
memset(addr, INADDR_NONE, sizeof(*addr));
|
|
||||||
else
|
|
||||||
memcpy(addr, host->h_addr, sizeof(*addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct search_list {
|
|
||||||
int country_number; /* ISO-3166 country number */
|
|
||||||
char short_name[3]; /* A2 short country code */
|
|
||||||
const char *long_name; /* normal country name */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct search_list *list_lookup(int number, const struct search_list *list, int num)
|
|
||||||
{
|
|
||||||
while (num > 0 && list->long_name)
|
|
||||||
{
|
|
||||||
if (list->country_number == number)
|
|
||||||
return (list);
|
|
||||||
num--;
|
|
||||||
list++;
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ref: ftp://ftp.ripe.net/iso3166-countrycodes.txt
|
|
||||||
*/
|
|
||||||
static const struct search_list country_list[] = {
|
|
||||||
{ 4, "af", "Afghanistan" },
|
|
||||||
{ 248, "ax", "<EFBFBD>land Island" },
|
|
||||||
{ 8, "al", "Albania" },
|
|
||||||
{ 12, "dz", "Algeria" },
|
|
||||||
{ 16, "as", "American Samoa" },
|
|
||||||
{ 20, "ad", "Andorra" },
|
|
||||||
{ 24, "ao", "Angola" },
|
|
||||||
{ 660, "ai", "Anguilla" },
|
|
||||||
{ 10, "aq", "Antarctica" },
|
|
||||||
{ 28, "ag", "Antigua & Barbuda" },
|
|
||||||
{ 32, "ar", "Argentina" },
|
|
||||||
{ 51, "am", "Armenia" },
|
|
||||||
{ 533, "aw", "Aruba" },
|
|
||||||
{ 36, "au", "Australia" },
|
|
||||||
{ 40, "at", "Austria" },
|
|
||||||
{ 31, "az", "Azerbaijan" },
|
|
||||||
{ 44, "bs", "Bahamas" },
|
|
||||||
{ 48, "bh", "Bahrain" },
|
|
||||||
{ 50, "bd", "Bangladesh" },
|
|
||||||
{ 52, "bb", "Barbados" },
|
|
||||||
{ 112, "by", "Belarus" },
|
|
||||||
{ 56, "be", "Belgium" },
|
|
||||||
{ 84, "bz", "Belize" },
|
|
||||||
{ 204, "bj", "Benin" },
|
|
||||||
{ 60, "bm", "Bermuda" },
|
|
||||||
{ 64, "bt", "Bhutan" },
|
|
||||||
{ 68, "bo", "Bolivia" },
|
|
||||||
{ 70, "ba", "Bosnia & Herzegowina" },
|
|
||||||
{ 72, "bw", "Botswana" },
|
|
||||||
{ 74, "bv", "Bouvet Island" },
|
|
||||||
{ 76, "br", "Brazil" },
|
|
||||||
{ 86, "io", "British Indian Ocean Territory" },
|
|
||||||
{ 96, "bn", "Brunei Darussalam" },
|
|
||||||
{ 100, "bg", "Bulgaria" },
|
|
||||||
{ 854, "bf", "Burkina Faso" },
|
|
||||||
{ 108, "bi", "Burundi" },
|
|
||||||
{ 116, "kh", "Cambodia" },
|
|
||||||
{ 120, "cm", "Cameroon" },
|
|
||||||
{ 124, "ca", "Canada" },
|
|
||||||
{ 132, "cv", "Cape Verde" },
|
|
||||||
{ 136, "ky", "Cayman Islands" },
|
|
||||||
{ 140, "cf", "Central African Republic" },
|
|
||||||
{ 148, "td", "Chad" },
|
|
||||||
{ 152, "cl", "Chile" },
|
|
||||||
{ 156, "cn", "China" },
|
|
||||||
{ 162, "cx", "Christmas Island" },
|
|
||||||
{ 166, "cc", "Cocos Islands" },
|
|
||||||
{ 170, "co", "Colombia" },
|
|
||||||
{ 174, "km", "Comoros" },
|
|
||||||
{ 178, "cg", "Congo" },
|
|
||||||
{ 180, "cd", "Congo" },
|
|
||||||
{ 184, "ck", "Cook Islands" },
|
|
||||||
{ 188, "cr", "Costa Rica" },
|
|
||||||
{ 384, "ci", "Cote d'Ivoire" },
|
|
||||||
{ 191, "hr", "Croatia" },
|
|
||||||
{ 192, "cu", "Cuba" },
|
|
||||||
{ 196, "cy", "Cyprus" },
|
|
||||||
{ 203, "cz", "Czech Republic" },
|
|
||||||
{ 208, "dk", "Denmark" },
|
|
||||||
{ 262, "dj", "Djibouti" },
|
|
||||||
{ 212, "dm", "Dominica" },
|
|
||||||
{ 214, "do", "Dominican Republic" },
|
|
||||||
{ 218, "ec", "Ecuador" },
|
|
||||||
{ 818, "eg", "Egypt" },
|
|
||||||
{ 222, "sv", "El Salvador" },
|
|
||||||
{ 226, "gq", "Equatorial Guinea" },
|
|
||||||
{ 232, "er", "Eritrea" },
|
|
||||||
{ 233, "ee", "Estonia" },
|
|
||||||
{ 231, "et", "Ethiopia" },
|
|
||||||
{ 238, "fk", "Falkland Islands" },
|
|
||||||
{ 234, "fo", "Faroe Islands" },
|
|
||||||
{ 242, "fj", "Fiji" },
|
|
||||||
{ 246, "fi", "Finland" },
|
|
||||||
{ 250, "fr", "France" },
|
|
||||||
{ 249, "fx", "France, Metropolitan" },
|
|
||||||
{ 254, "gf", "French Guiana" },
|
|
||||||
{ 258, "pf", "French Polynesia" },
|
|
||||||
{ 260, "tf", "French Southern Territories" },
|
|
||||||
{ 266, "ga", "Gabon" },
|
|
||||||
{ 270, "gm", "Gambia" },
|
|
||||||
{ 268, "ge", "Georgia" },
|
|
||||||
{ 276, "de", "Germany" },
|
|
||||||
{ 288, "gh", "Ghana" },
|
|
||||||
{ 292, "gi", "Gibraltar" },
|
|
||||||
{ 300, "gr", "Greece" },
|
|
||||||
{ 304, "gl", "Greenland" },
|
|
||||||
{ 308, "gd", "Grenada" },
|
|
||||||
{ 312, "gp", "Guadeloupe" },
|
|
||||||
{ 316, "gu", "Guam" },
|
|
||||||
{ 320, "gt", "Guatemala" },
|
|
||||||
{ 324, "gn", "Guinea" },
|
|
||||||
{ 624, "gw", "Guinea-Bissau" },
|
|
||||||
{ 328, "gy", "Guyana" },
|
|
||||||
{ 332, "ht", "Haiti" },
|
|
||||||
{ 334, "hm", "Heard & Mc Donald Islands" },
|
|
||||||
{ 336, "va", "Vatican City" },
|
|
||||||
{ 340, "hn", "Honduras" },
|
|
||||||
{ 344, "hk", "Hong kong" },
|
|
||||||
{ 348, "hu", "Hungary" },
|
|
||||||
{ 352, "is", "Iceland" },
|
|
||||||
{ 356, "in", "India" },
|
|
||||||
{ 360, "id", "Indonesia" },
|
|
||||||
{ 364, "ir", "Iran" },
|
|
||||||
{ 368, "iq", "Iraq" },
|
|
||||||
{ 372, "ie", "Ireland" },
|
|
||||||
{ 376, "il", "Israel" },
|
|
||||||
{ 380, "it", "Italy" },
|
|
||||||
{ 388, "jm", "Jamaica" },
|
|
||||||
{ 392, "jp", "Japan" },
|
|
||||||
{ 400, "jo", "Jordan" },
|
|
||||||
{ 398, "kz", "Kazakhstan" },
|
|
||||||
{ 404, "ke", "Kenya" },
|
|
||||||
{ 296, "ki", "Kiribati" },
|
|
||||||
{ 408, "kp", "Korea (north)" },
|
|
||||||
{ 410, "kr", "Korea (south)" },
|
|
||||||
{ 414, "kw", "Kuwait" },
|
|
||||||
{ 417, "kg", "Kyrgyzstan" },
|
|
||||||
{ 418, "la", "Laos" },
|
|
||||||
{ 428, "lv", "Latvia" },
|
|
||||||
{ 422, "lb", "Lebanon" },
|
|
||||||
{ 426, "ls", "Lesotho" },
|
|
||||||
{ 430, "lr", "Liberia" },
|
|
||||||
{ 434, "ly", "Libya" },
|
|
||||||
{ 438, "li", "Liechtenstein" },
|
|
||||||
{ 440, "lt", "Lithuania" },
|
|
||||||
{ 442, "lu", "Luxembourg" },
|
|
||||||
{ 446, "mo", "Macao" },
|
|
||||||
{ 807, "mk", "Macedonia" },
|
|
||||||
{ 450, "mg", "Madagascar" },
|
|
||||||
{ 454, "mw", "Malawi" },
|
|
||||||
{ 458, "my", "Malaysia" },
|
|
||||||
{ 462, "mv", "Maldives" },
|
|
||||||
{ 466, "ml", "Mali" },
|
|
||||||
{ 470, "mt", "Malta" },
|
|
||||||
{ 584, "mh", "Marshall Islands" },
|
|
||||||
{ 474, "mq", "Martinique" },
|
|
||||||
{ 478, "mr", "Mauritania" },
|
|
||||||
{ 480, "mu", "Mauritius" },
|
|
||||||
{ 175, "yt", "Mayotte" },
|
|
||||||
{ 484, "mx", "Mexico" },
|
|
||||||
{ 583, "fm", "Micronesia" },
|
|
||||||
{ 498, "md", "Moldova" },
|
|
||||||
{ 492, "mc", "Monaco" },
|
|
||||||
{ 496, "mn", "Mongolia" },
|
|
||||||
{ 500, "ms", "Montserrat" },
|
|
||||||
{ 504, "ma", "Morocco" },
|
|
||||||
{ 508, "mz", "Mozambique" },
|
|
||||||
{ 104, "mm", "Myanmar" },
|
|
||||||
{ 516, "na", "Namibia" },
|
|
||||||
{ 520, "nr", "Nauru" },
|
|
||||||
{ 524, "np", "Nepal" },
|
|
||||||
{ 528, "nl", "Netherlands" },
|
|
||||||
{ 530, "an", "Netherlands Antilles" },
|
|
||||||
{ 540, "nc", "New Caledonia" },
|
|
||||||
{ 554, "nz", "New Zealand" },
|
|
||||||
{ 558, "ni", "Nicaragua" },
|
|
||||||
{ 562, "ne", "Niger" },
|
|
||||||
{ 566, "ng", "Nigeria" },
|
|
||||||
{ 570, "nu", "Niue" },
|
|
||||||
{ 574, "nf", "Norfolk Island" },
|
|
||||||
{ 580, "mp", "Northern Mariana Islands" },
|
|
||||||
{ 578, "no", "Norway" },
|
|
||||||
{ 512, "om", "Oman" },
|
|
||||||
{ 586, "pk", "Pakistan" },
|
|
||||||
{ 585, "pw", "Palau" },
|
|
||||||
{ 275, "ps", "Palestinian Territory" },
|
|
||||||
{ 591, "pa", "Panama" },
|
|
||||||
{ 598, "pg", "Papua New Guinea" },
|
|
||||||
{ 600, "py", "Paraguay" },
|
|
||||||
{ 604, "pe", "Peru" },
|
|
||||||
{ 608, "ph", "Philippines" },
|
|
||||||
{ 612, "pn", "Pitcairn" },
|
|
||||||
{ 616, "pl", "Poland" },
|
|
||||||
{ 620, "pt", "Portugal" },
|
|
||||||
{ 630, "pr", "Puerto Rico" },
|
|
||||||
{ 634, "qa", "Qatar" },
|
|
||||||
{ 638, "re", "Reunion" },
|
|
||||||
{ 642, "ro", "Romania" },
|
|
||||||
{ 643, "ru", "Russia" },
|
|
||||||
{ 646, "rw", "Rwanda" },
|
|
||||||
{ 659, "kn", "Saint Kitts & Nevis" },
|
|
||||||
{ 662, "lc", "Saint Lucia" },
|
|
||||||
{ 670, "vc", "Saint Vincent" },
|
|
||||||
{ 882, "ws", "Samoa" },
|
|
||||||
{ 674, "sm", "San Marino" },
|
|
||||||
{ 678, "st", "Sao Tome & Principe" },
|
|
||||||
{ 682, "sa", "Saudi Arabia" },
|
|
||||||
{ 686, "sn", "Senegal" },
|
|
||||||
{ 891, "cs", "Serbia and Montenegro" },
|
|
||||||
{ 690, "sc", "Seychelles" },
|
|
||||||
{ 694, "sl", "Sierra Leone" },
|
|
||||||
{ 702, "sg", "Singapore" },
|
|
||||||
{ 703, "sk", "Slovakia" },
|
|
||||||
{ 705, "si", "Slovenia" },
|
|
||||||
{ 90, "sb", "Solomon Islands" },
|
|
||||||
{ 706, "so", "Somalia" },
|
|
||||||
{ 710, "za", "South Africa" },
|
|
||||||
{ 239, "gs", "South Georgia" },
|
|
||||||
{ 724, "es", "Spain" },
|
|
||||||
{ 144, "lk", "Sri Lanka" },
|
|
||||||
{ 654, "sh", "St. Helena" },
|
|
||||||
{ 666, "pm", "St. Pierre & Miquelon" },
|
|
||||||
{ 736, "sd", "Sudan" },
|
|
||||||
{ 740, "sr", "Suriname" },
|
|
||||||
{ 744, "sj", "Svalbard & Jan Mayen Islands" },
|
|
||||||
{ 748, "sz", "Swaziland" },
|
|
||||||
{ 752, "se", "Sweden" },
|
|
||||||
{ 756, "ch", "Switzerland" },
|
|
||||||
{ 760, "sy", "Syrian Arab Republic" },
|
|
||||||
{ 626, "tl", "Timor-Leste" },
|
|
||||||
{ 158, "tw", "Taiwan" },
|
|
||||||
{ 762, "tj", "Tajikistan" },
|
|
||||||
{ 834, "tz", "Tanzania" },
|
|
||||||
{ 764, "th", "Thailand" },
|
|
||||||
{ 768, "tg", "Togo" },
|
|
||||||
{ 772, "tk", "Tokelau" },
|
|
||||||
{ 776, "to", "Tonga" },
|
|
||||||
{ 780, "tt", "Trinidad & Tobago" },
|
|
||||||
{ 788, "tn", "Tunisia" },
|
|
||||||
{ 792, "tr", "Turkey" },
|
|
||||||
{ 795, "tm", "Turkmenistan" },
|
|
||||||
{ 796, "tc", "Turks & Caicos Islands" },
|
|
||||||
{ 798, "tv", "Tuvalu" },
|
|
||||||
{ 800, "ug", "Uganda" },
|
|
||||||
{ 804, "ua", "Ukraine" },
|
|
||||||
{ 784, "ae", "United Arab Emirates" },
|
|
||||||
{ 826, "gb", "United Kingdom" },
|
|
||||||
{ 840, "us", "United States" },
|
|
||||||
{ 581, "um", "United States Minor Outlying Islands" },
|
|
||||||
{ 858, "uy", "Uruguay" },
|
|
||||||
{ 860, "uz", "Uzbekistan" },
|
|
||||||
{ 548, "vu", "Vanuatu" },
|
|
||||||
{ 862, "ve", "Venezuela" },
|
|
||||||
{ 704, "vn", "Vietnam" },
|
|
||||||
{ 92, "vg", "Virgin Islands (British)" },
|
|
||||||
{ 850, "vi", "Virgin Islands (US)" },
|
|
||||||
{ 876, "wf", "Wallis & Futuna Islands" },
|
|
||||||
{ 732, "eh", "Western Sahara" },
|
|
||||||
{ 887, "ye", "Yemen" },
|
|
||||||
{ 894, "zm", "Zambia" },
|
|
||||||
{ 716, "zw", "Zimbabwe" }
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if start of 'str' is simply an IPv4 address.
|
|
||||||
*/
|
|
||||||
#define BYTE_OK(x) ((x) >= 0 && (x) <= 255)
|
|
||||||
|
|
||||||
static int is_addr(char *str, char **end)
|
|
||||||
{
|
|
||||||
int a0, a1, a2, a3, num, rc = 0, length = 0;
|
|
||||||
|
|
||||||
num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
|
|
||||||
if( (num == 4) &&
|
|
||||||
BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
|
|
||||||
length >= (3+4))
|
|
||||||
{
|
|
||||||
rc = 1;
|
|
||||||
*end = str + length;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find the country-code and name from the CNAME. E.g.:
|
|
||||||
* version 1: CNAME = zzno.countries.nerd.dk with address 127.0.2.66
|
|
||||||
* yields ccode_A" = "no" and cnumber 578 (2.66).
|
|
||||||
* version 2: CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.2.66
|
|
||||||
* yields cnumber 578 (2.66). ccode_A is "";
|
|
||||||
*/
|
|
||||||
static void find_country_from_cname(const char *cname, struct in_addr addr)
|
|
||||||
{
|
|
||||||
const struct search_list *country;
|
|
||||||
char ccode_A2[3], *ccopy, *dot_4;
|
|
||||||
int cnumber, z0, z1, ver_1, ver_2;
|
|
||||||
u_long ip;
|
|
||||||
|
|
||||||
ip = ntohl(addr.s_addr);
|
|
||||||
z0 = tolower(cname[0]);
|
|
||||||
z1 = tolower(cname[1]);
|
|
||||||
ccopy = strdup(cname);
|
|
||||||
dot_4 = NULL;
|
|
||||||
|
|
||||||
ver_1 = (z0 == 'z' && z1 == 'z' && !strcasecmp(cname+4,nerd_ver1));
|
|
||||||
ver_2 = (is_addr(ccopy,&dot_4) && !strcasecmp(dot_4,nerd_ver2));
|
|
||||||
|
|
||||||
if (ver_1)
|
|
||||||
{
|
|
||||||
const char *dot = strchr(cname, '.');
|
|
||||||
if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
|
|
||||||
{
|
|
||||||
printf("Unexpected CNAME %s (ver_1)\n", cname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ver_2)
|
|
||||||
{
|
|
||||||
z0 = tolower(dot_4[1]);
|
|
||||||
z1 = tolower(dot_4[2]);
|
|
||||||
if (z0 != 'z' && z1 != 'z')
|
|
||||||
{
|
|
||||||
printf("Unexpected CNAME %s (ver_2)\n", cname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Unexpected CNAME %s (ver?)\n", cname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ver_1)
|
|
||||||
{
|
|
||||||
ccode_A2[0] = (char)tolower(cname[2]);
|
|
||||||
ccode_A2[1] = (char)tolower(cname[3]);
|
|
||||||
ccode_A2[2] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ccode_A2[0] = '\0';
|
|
||||||
|
|
||||||
cnumber = ip & 0xFFFF;
|
|
||||||
|
|
||||||
TRACE(("Found country-code `%s', number %d\n",
|
|
||||||
ver_1 ? ccode_A2 : "<n/a>", cnumber));
|
|
||||||
|
|
||||||
country = list_lookup(cnumber, country_list,
|
|
||||||
sizeof(country_list) / sizeof(country_list[0]));
|
|
||||||
if (!country)
|
|
||||||
printf("Name for country-number %d not found.\n", cnumber);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ver_1 && *(unsigned short*)&country->short_name != *(unsigned*)&ccode_A2)
|
|
||||||
printf("short-name mismatch; %s vs %s\n", country->short_name, ccode_A2);
|
|
||||||
|
|
||||||
printf("%s (%s), number %d.\n",
|
|
||||||
country->long_name, country->short_name, cnumber);
|
|
||||||
}
|
|
||||||
free(ccopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
721
ares/adig.c
721
ares/adig.c
@@ -1,721 +0,0 @@
|
|||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
# include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "inet_ntop.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "ares_getopt.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
|
||||||
# include "ares_strdup.h"
|
|
||||||
# define strdup(ptr) ares_strdup(ptr)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRNCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WATT32
|
|
||||||
#undef WIN32 /* Redefined in MingW headers */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Mac OS X portability check */
|
|
||||||
#ifndef T_SRV
|
|
||||||
#define T_SRV 33 /* server selection */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct nv {
|
|
||||||
const char *name;
|
|
||||||
int value;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct nv flags[] = {
|
|
||||||
{ "usevc", ARES_FLAG_USEVC },
|
|
||||||
{ "primary", ARES_FLAG_PRIMARY },
|
|
||||||
{ "igntc", ARES_FLAG_IGNTC },
|
|
||||||
{ "norecurse", ARES_FLAG_NORECURSE },
|
|
||||||
{ "stayopen", ARES_FLAG_STAYOPEN },
|
|
||||||
{ "noaliases", ARES_FLAG_NOALIASES }
|
|
||||||
};
|
|
||||||
static const int nflags = sizeof(flags) / sizeof(flags[0]);
|
|
||||||
|
|
||||||
static const struct nv classes[] = {
|
|
||||||
{ "IN", C_IN },
|
|
||||||
{ "CHAOS", C_CHAOS },
|
|
||||||
{ "HS", C_HS },
|
|
||||||
{ "ANY", C_ANY }
|
|
||||||
};
|
|
||||||
static const int nclasses = sizeof(classes) / sizeof(classes[0]);
|
|
||||||
|
|
||||||
static const struct nv types[] = {
|
|
||||||
{ "A", T_A },
|
|
||||||
{ "NS", T_NS },
|
|
||||||
{ "MD", T_MD },
|
|
||||||
{ "MF", T_MF },
|
|
||||||
{ "CNAME", T_CNAME },
|
|
||||||
{ "SOA", T_SOA },
|
|
||||||
{ "MB", T_MB },
|
|
||||||
{ "MG", T_MG },
|
|
||||||
{ "MR", T_MR },
|
|
||||||
{ "NULL", T_NULL },
|
|
||||||
{ "WKS", T_WKS },
|
|
||||||
{ "PTR", T_PTR },
|
|
||||||
{ "HINFO", T_HINFO },
|
|
||||||
{ "MINFO", T_MINFO },
|
|
||||||
{ "MX", T_MX },
|
|
||||||
{ "TXT", T_TXT },
|
|
||||||
{ "RP", T_RP },
|
|
||||||
{ "AFSDB", T_AFSDB },
|
|
||||||
{ "X25", T_X25 },
|
|
||||||
{ "ISDN", T_ISDN },
|
|
||||||
{ "RT", T_RT },
|
|
||||||
{ "NSAP", T_NSAP },
|
|
||||||
{ "NSAP_PTR", T_NSAP_PTR },
|
|
||||||
{ "SIG", T_SIG },
|
|
||||||
{ "KEY", T_KEY },
|
|
||||||
{ "PX", T_PX },
|
|
||||||
{ "GPOS", T_GPOS },
|
|
||||||
{ "AAAA", T_AAAA },
|
|
||||||
{ "LOC", T_LOC },
|
|
||||||
{ "SRV", T_SRV },
|
|
||||||
{ "AXFR", T_AXFR },
|
|
||||||
{ "MAILB", T_MAILB },
|
|
||||||
{ "MAILA", T_MAILA },
|
|
||||||
{ "NAPTR", T_NAPTR },
|
|
||||||
{ "ANY", T_ANY }
|
|
||||||
};
|
|
||||||
static const int ntypes = sizeof(types) / sizeof(types[0]);
|
|
||||||
|
|
||||||
static const char *opcodes[] = {
|
|
||||||
"QUERY", "IQUERY", "STATUS", "(reserved)", "NOTIFY",
|
|
||||||
"(unknown)", "(unknown)", "(unknown)", "(unknown)",
|
|
||||||
"UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA",
|
|
||||||
"ZONEINIT", "ZONEREF"
|
|
||||||
};
|
|
||||||
struct in_addr inaddr;
|
|
||||||
|
|
||||||
static const char *rcodes[] = {
|
|
||||||
"NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED",
|
|
||||||
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)",
|
|
||||||
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "NOCHANGE"
|
|
||||||
};
|
|
||||||
|
|
||||||
static void callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen);
|
|
||||||
static const unsigned char *display_question(const unsigned char *aptr,
|
|
||||||
const unsigned char *abuf,
|
|
||||||
int alen);
|
|
||||||
static const unsigned char *display_rr(const unsigned char *aptr,
|
|
||||||
const unsigned char *abuf, int alen);
|
|
||||||
static const char *type_name(int type);
|
|
||||||
static const char *class_name(int dnsclass);
|
|
||||||
static void usage(void);
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
ares_channel channel;
|
|
||||||
int c, i, optmask = ARES_OPT_FLAGS, dnsclass = C_IN, type = T_A;
|
|
||||||
int status, nfds, count;
|
|
||||||
struct ares_options options;
|
|
||||||
struct hostent *hostent;
|
|
||||||
fd_set read_fds, write_fds;
|
|
||||||
struct timeval *tvp, tv;
|
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
|
||||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
|
||||||
WSADATA wsaData;
|
|
||||||
WSAStartup(wVersionRequested, &wsaData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
options.flags = ARES_FLAG_NOCHECKRESP;
|
|
||||||
options.servers = NULL;
|
|
||||||
options.nservers = 0;
|
|
||||||
while ((c = ares_getopt(argc, argv, "df:s:c:t:T:U:")) != -1)
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'd':
|
|
||||||
#ifdef WATT32
|
|
||||||
dbug_init();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
/* Add a flag. */
|
|
||||||
for (i = 0; i < nflags; i++)
|
|
||||||
{
|
|
||||||
if (strcmp(flags[i].name, optarg) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == nflags)
|
|
||||||
usage();
|
|
||||||
options.flags |= flags[i].value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
/* Add a server, and specify servers in the option mask. */
|
|
||||||
if (ares_inet_pton(AF_INET, optarg, &inaddr) <= 0)
|
|
||||||
{
|
|
||||||
hostent = gethostbyname(optarg);
|
|
||||||
if (!hostent || hostent->h_addrtype != AF_INET)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "adig: server %s not found.\n", optarg);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
memcpy(&inaddr, hostent->h_addr, sizeof(struct in_addr));
|
|
||||||
}
|
|
||||||
options.servers = realloc(options.servers, (options.nservers + 1)
|
|
||||||
* sizeof(struct in_addr));
|
|
||||||
if (!options.servers)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Out of memory!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
memcpy(&options.servers[options.nservers], &inaddr,
|
|
||||||
sizeof(struct in_addr));
|
|
||||||
options.nservers++;
|
|
||||||
optmask |= ARES_OPT_SERVERS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c':
|
|
||||||
/* Set the query class. */
|
|
||||||
for (i = 0; i < nclasses; i++)
|
|
||||||
{
|
|
||||||
if (strcasecmp(classes[i].name, optarg) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == nclasses)
|
|
||||||
usage();
|
|
||||||
dnsclass = classes[i].value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't':
|
|
||||||
/* Set the query type. */
|
|
||||||
for (i = 0; i < ntypes; i++)
|
|
||||||
{
|
|
||||||
if (strcasecmp(types[i].name, optarg) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == ntypes)
|
|
||||||
usage();
|
|
||||||
type = types[i].value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'T':
|
|
||||||
/* Set the TCP port number. */
|
|
||||||
if (!ISDIGIT(*optarg))
|
|
||||||
usage();
|
|
||||||
options.tcp_port = (unsigned short)strtol(optarg, NULL, 0);
|
|
||||||
optmask |= ARES_OPT_TCP_PORT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'U':
|
|
||||||
/* Set the UDP port number. */
|
|
||||||
if (!ISDIGIT(*optarg))
|
|
||||||
usage();
|
|
||||||
options.udp_port = (unsigned short)strtol(optarg, NULL, 0);
|
|
||||||
optmask |= ARES_OPT_UDP_PORT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc == 0)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
status = ares_init_options(&channel, &options, optmask);
|
|
||||||
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ares_init_options: %s\n",
|
|
||||||
ares_strerror(status));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initiate the queries, one per command-line argument. If there is
|
|
||||||
* only one query to do, supply NULL as the callback argument;
|
|
||||||
* otherwise, supply the query name as an argument so we can
|
|
||||||
* distinguish responses for the user when printing them out.
|
|
||||||
*/
|
|
||||||
if (argc == 1)
|
|
||||||
ares_query(channel, *argv, dnsclass, type, callback, (char *) NULL);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (; *argv; argv++)
|
|
||||||
ares_query(channel, *argv, dnsclass, type, callback, *argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for all queries to complete. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FD_ZERO(&read_fds);
|
|
||||||
FD_ZERO(&write_fds);
|
|
||||||
nfds = ares_fds(channel, &read_fds, &write_fds);
|
|
||||||
if (nfds == 0)
|
|
||||||
break;
|
|
||||||
tvp = ares_timeout(channel, NULL, &tv);
|
|
||||||
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
|
||||||
if (count < 0 && SOCKERRNO != EINVAL)
|
|
||||||
{
|
|
||||||
perror("select");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ares_process(channel, &read_fds, &write_fds);
|
|
||||||
}
|
|
||||||
|
|
||||||
ares_destroy(channel);
|
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
|
||||||
WSACleanup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen)
|
|
||||||
{
|
|
||||||
char *name = (char *) arg;
|
|
||||||
int id, qr, opcode, aa, tc, rd, ra, rcode;
|
|
||||||
unsigned int qdcount, ancount, nscount, arcount, i;
|
|
||||||
const unsigned char *aptr;
|
|
||||||
|
|
||||||
(void) timeouts;
|
|
||||||
|
|
||||||
/* Display the query name if given. */
|
|
||||||
if (name)
|
|
||||||
printf("Answer for query %s:\n", name);
|
|
||||||
|
|
||||||
/* Display an error message if there was an error, but only stop if
|
|
||||||
* we actually didn't get an answer buffer.
|
|
||||||
*/
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
printf("%s\n", ares_strerror(status));
|
|
||||||
if (!abuf)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Won't happen, but check anyway, for safety. */
|
|
||||||
if (alen < HFIXEDSZ)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Parse the answer header. */
|
|
||||||
id = DNS_HEADER_QID(abuf);
|
|
||||||
qr = DNS_HEADER_QR(abuf);
|
|
||||||
opcode = DNS_HEADER_OPCODE(abuf);
|
|
||||||
aa = DNS_HEADER_AA(abuf);
|
|
||||||
tc = DNS_HEADER_TC(abuf);
|
|
||||||
rd = DNS_HEADER_RD(abuf);
|
|
||||||
ra = DNS_HEADER_RA(abuf);
|
|
||||||
rcode = DNS_HEADER_RCODE(abuf);
|
|
||||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
|
||||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
|
||||||
nscount = DNS_HEADER_NSCOUNT(abuf);
|
|
||||||
arcount = DNS_HEADER_ARCOUNT(abuf);
|
|
||||||
|
|
||||||
/* Display the answer header. */
|
|
||||||
printf("id: %d\n", id);
|
|
||||||
printf("flags: %s%s%s%s%s\n",
|
|
||||||
qr ? "qr " : "",
|
|
||||||
aa ? "aa " : "",
|
|
||||||
tc ? "tc " : "",
|
|
||||||
rd ? "rd " : "",
|
|
||||||
ra ? "ra " : "");
|
|
||||||
printf("opcode: %s\n", opcodes[opcode]);
|
|
||||||
printf("rcode: %s\n", rcodes[rcode]);
|
|
||||||
|
|
||||||
/* Display the questions. */
|
|
||||||
printf("Questions:\n");
|
|
||||||
aptr = abuf + HFIXEDSZ;
|
|
||||||
for (i = 0; i < qdcount; i++)
|
|
||||||
{
|
|
||||||
aptr = display_question(aptr, abuf, alen);
|
|
||||||
if (aptr == NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Display the answers. */
|
|
||||||
printf("Answers:\n");
|
|
||||||
for (i = 0; i < ancount; i++)
|
|
||||||
{
|
|
||||||
aptr = display_rr(aptr, abuf, alen);
|
|
||||||
if (aptr == NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Display the NS records. */
|
|
||||||
printf("NS records:\n");
|
|
||||||
for (i = 0; i < nscount; i++)
|
|
||||||
{
|
|
||||||
aptr = display_rr(aptr, abuf, alen);
|
|
||||||
if (aptr == NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Display the additional records. */
|
|
||||||
printf("Additional records:\n");
|
|
||||||
for (i = 0; i < arcount; i++)
|
|
||||||
{
|
|
||||||
aptr = display_rr(aptr, abuf, alen);
|
|
||||||
if (aptr == NULL)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const unsigned char *display_question(const unsigned char *aptr,
|
|
||||||
const unsigned char *abuf,
|
|
||||||
int alen)
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
int type, dnsclass, status;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
/* Parse the question name. */
|
|
||||||
status = ares_expand_name(aptr, abuf, alen, &name, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
aptr += len;
|
|
||||||
|
|
||||||
/* Make sure there's enough data after the name for the fixed part
|
|
||||||
* of the question.
|
|
||||||
*/
|
|
||||||
if (aptr + QFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
ares_free_string(name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the question type and class. */
|
|
||||||
type = DNS_QUESTION_TYPE(aptr);
|
|
||||||
dnsclass = DNS_QUESTION_CLASS(aptr);
|
|
||||||
aptr += QFIXEDSZ;
|
|
||||||
|
|
||||||
/* Display the question, in a format sort of similar to how we will
|
|
||||||
* display RRs.
|
|
||||||
*/
|
|
||||||
printf("\t%-15s.\t", name);
|
|
||||||
if (dnsclass != C_IN)
|
|
||||||
printf("\t%s", class_name(dnsclass));
|
|
||||||
printf("\t%s\n", type_name(type));
|
|
||||||
ares_free_string(name);
|
|
||||||
return aptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const unsigned char *display_rr(const unsigned char *aptr,
|
|
||||||
const unsigned char *abuf, int alen)
|
|
||||||
{
|
|
||||||
const unsigned char *p;
|
|
||||||
int type, dnsclass, ttl, dlen, status;
|
|
||||||
long len;
|
|
||||||
char addr[46];
|
|
||||||
union {
|
|
||||||
unsigned char * as_uchar;
|
|
||||||
char * as_char;
|
|
||||||
} name;
|
|
||||||
|
|
||||||
/* Parse the RR name. */
|
|
||||||
status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
aptr += len;
|
|
||||||
|
|
||||||
/* Make sure there is enough data after the RR name for the fixed
|
|
||||||
* part of the RR.
|
|
||||||
*/
|
|
||||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the fixed part of the RR, and advance to the RR data
|
|
||||||
* field. */
|
|
||||||
type = DNS_RR_TYPE(aptr);
|
|
||||||
dnsclass = DNS_RR_CLASS(aptr);
|
|
||||||
ttl = DNS_RR_TTL(aptr);
|
|
||||||
dlen = DNS_RR_LEN(aptr);
|
|
||||||
aptr += RRFIXEDSZ;
|
|
||||||
if (aptr + dlen > abuf + alen)
|
|
||||||
{
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Display the RR name, class, and type. */
|
|
||||||
printf("\t%-15s.\t%d", name.as_char, ttl);
|
|
||||||
if (dnsclass != C_IN)
|
|
||||||
printf("\t%s", class_name(dnsclass));
|
|
||||||
printf("\t%s", type_name(type));
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
|
|
||||||
/* Display the RR data. Don't touch aptr. */
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case T_CNAME:
|
|
||||||
case T_MB:
|
|
||||||
case T_MD:
|
|
||||||
case T_MF:
|
|
||||||
case T_MG:
|
|
||||||
case T_MR:
|
|
||||||
case T_NS:
|
|
||||||
case T_PTR:
|
|
||||||
/* For these types, the RR data is just a domain name. */
|
|
||||||
status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_HINFO:
|
|
||||||
/* The RR data is two length-counted character strings. */
|
|
||||||
p = aptr;
|
|
||||||
len = *p;
|
|
||||||
if (p + len + 1 > aptr + dlen)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%.*s", (int)len, p + 1);
|
|
||||||
p += len + 1;
|
|
||||||
len = *p;
|
|
||||||
if (p + len + 1 > aptr + dlen)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%.*s", (int)len, p + 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_MINFO:
|
|
||||||
/* The RR data is two domain names. */
|
|
||||||
p = aptr;
|
|
||||||
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_MX:
|
|
||||||
/* The RR data is two bytes giving a preference ordering, and
|
|
||||||
* then a domain name.
|
|
||||||
*/
|
|
||||||
if (dlen < 2)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%d", DNS__16BIT(aptr));
|
|
||||||
status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_SOA:
|
|
||||||
/* The RR data is two domain names and then five four-byte
|
|
||||||
* numbers giving the serial number and some timeouts.
|
|
||||||
*/
|
|
||||||
p = aptr;
|
|
||||||
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.\n", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t%s.\n", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
if (p + 20 > aptr + dlen)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t( %lu %lu %lu %lu %lu )",
|
|
||||||
(unsigned long)DNS__32BIT(p), (unsigned long)DNS__32BIT(p+4),
|
|
||||||
(unsigned long)DNS__32BIT(p+8), (unsigned long)DNS__32BIT(p+12),
|
|
||||||
(unsigned long)DNS__32BIT(p+16));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_TXT:
|
|
||||||
/* The RR data is one or more length-counted character
|
|
||||||
* strings. */
|
|
||||||
p = aptr;
|
|
||||||
while (p < aptr + dlen)
|
|
||||||
{
|
|
||||||
len = *p;
|
|
||||||
if (p + len + 1 > aptr + dlen)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%.*s", (int)len, p + 1);
|
|
||||||
p += len + 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_A:
|
|
||||||
/* The RR data is a four-byte Internet address. */
|
|
||||||
if (dlen != 4)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s", ares_inet_ntop(AF_INET,aptr,addr,sizeof(addr)));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_AAAA:
|
|
||||||
/* The RR data is a 16-byte IPv6 address. */
|
|
||||||
if (dlen != 16)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s", ares_inet_ntop(AF_INET6,aptr,addr,sizeof(addr)));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_WKS:
|
|
||||||
/* Not implemented yet */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_SRV:
|
|
||||||
/* The RR data is three two-byte numbers representing the
|
|
||||||
* priority, weight, and port, followed by a domain name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
printf("\t%d", DNS__16BIT(aptr));
|
|
||||||
printf(" %d", DNS__16BIT(aptr + 2));
|
|
||||||
printf(" %d", DNS__16BIT(aptr + 4));
|
|
||||||
|
|
||||||
status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t%s.", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_NAPTR:
|
|
||||||
|
|
||||||
printf("\t%d", DNS__16BIT(aptr)); /* order */
|
|
||||||
printf(" %d\n", DNS__16BIT(aptr + 2)); /* preference */
|
|
||||||
|
|
||||||
p = aptr + 4;
|
|
||||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t%s\n", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
|
|
||||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t%s\n", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
|
|
||||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t%s\n", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
p += len;
|
|
||||||
|
|
||||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return NULL;
|
|
||||||
printf("\t\t\t\t\t\t%s", name.as_char);
|
|
||||||
ares_free_string(name.as_char);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf("\t[Unknown RR; cannot parse]");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
return aptr + dlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *type_name(int type)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ntypes; i++)
|
|
||||||
{
|
|
||||||
if (types[i].value == type)
|
|
||||||
return types[i].name;
|
|
||||||
}
|
|
||||||
return "(unknown)";
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *class_name(int dnsclass)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nclasses; i++)
|
|
||||||
{
|
|
||||||
if (classes[i].value == dnsclass)
|
|
||||||
return classes[i].name;
|
|
||||||
}
|
|
||||||
return "(unknown)";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: adig [-f flag] [-s server] [-c class] "
|
|
||||||
"[-t type] [-p port] name ...\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
192
ares/ahost.c
192
ares/ahost.c
@@ -1,192 +0,0 @@
|
|||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#if !defined(WIN32) || defined(WATT32)
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "inet_ntop.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "ares_getopt.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
|
||||||
# include "ares_strdup.h"
|
|
||||||
# define strdup(ptr) ares_strdup(ptr)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRNCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
|
||||||
static void usage(void);
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
ares_channel channel;
|
|
||||||
int status, nfds, c, addr_family = AF_INET;
|
|
||||||
fd_set read_fds, write_fds;
|
|
||||||
struct timeval *tvp, tv;
|
|
||||||
struct in_addr addr4;
|
|
||||||
struct in6_addr addr6;
|
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
|
||||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
|
||||||
WSADATA wsaData;
|
|
||||||
WSAStartup(wVersionRequested, &wsaData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'd':
|
|
||||||
#ifdef WATT32
|
|
||||||
dbug_init();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if (!strcasecmp(optarg,"a"))
|
|
||||||
addr_family = AF_INET;
|
|
||||||
else if (!strcasecmp(optarg,"aaaa"))
|
|
||||||
addr_family = AF_INET6;
|
|
||||||
else
|
|
||||||
usage();
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
if (argc < 1)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
status = ares_init(&channel);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initiate the queries, one per command-line argument. */
|
|
||||||
for ( ; *argv; argv++)
|
|
||||||
{
|
|
||||||
if (ares_inet_pton(AF_INET, *argv, &addr4) == 1)
|
|
||||||
{
|
|
||||||
ares_gethostbyaddr(channel, &addr4, sizeof(addr4), AF_INET, callback,
|
|
||||||
*argv);
|
|
||||||
}
|
|
||||||
else if (ares_inet_pton(AF_INET6, *argv, &addr6) == 1)
|
|
||||||
{
|
|
||||||
ares_gethostbyaddr(channel, &addr6, sizeof(addr6), AF_INET6, callback,
|
|
||||||
*argv);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ares_gethostbyname(channel, *argv, addr_family, callback, *argv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for all queries to complete. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FD_ZERO(&read_fds);
|
|
||||||
FD_ZERO(&write_fds);
|
|
||||||
nfds = ares_fds(channel, &read_fds, &write_fds);
|
|
||||||
if (nfds == 0)
|
|
||||||
break;
|
|
||||||
tvp = ares_timeout(channel, NULL, &tv);
|
|
||||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
|
||||||
ares_process(channel, &read_fds, &write_fds);
|
|
||||||
}
|
|
||||||
|
|
||||||
ares_destroy(channel);
|
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
|
||||||
WSACleanup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void callback(void *arg, int status, int timeouts, struct hostent *host)
|
|
||||||
{
|
|
||||||
char **p;
|
|
||||||
|
|
||||||
(void)timeouts;
|
|
||||||
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: %s\n", (char *) arg, ares_strerror(status));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (p = host->h_addr_list; *p; p++)
|
|
||||||
{
|
|
||||||
char addr_buf[46] = "??";
|
|
||||||
|
|
||||||
ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));
|
|
||||||
printf("%-32s\t%s", host->h_name, addr_buf);
|
|
||||||
#if 0
|
|
||||||
if (host->h_aliases[0])
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
printf (", Aliases: ");
|
|
||||||
for (i = 0; host->h_aliases[i]; i++)
|
|
||||||
printf("%s ", host->h_aliases[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
puts("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
329
ares/ares.h
329
ares/ares.h
@@ -1,329 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
* Copyright (C) 2007-2009 by Daniel Stenberg
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARES__H
|
|
||||||
#define ARES__H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define WIN32 when build target is Win32 API
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
|
||||||
#define WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
|
|
||||||
libc5-based Linux systems. Only include it on system that are known to
|
|
||||||
require it! */
|
|
||||||
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
|
|
||||||
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
|
||||||
#include <sys/bsdskt.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WATT32)
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <tcp.h>
|
|
||||||
#elif defined(WIN32)
|
|
||||||
# ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# endif
|
|
||||||
# include <windows.h>
|
|
||||||
# include <winsock2.h>
|
|
||||||
# include <ws2tcpip.h>
|
|
||||||
#else
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARES_SUCCESS 0
|
|
||||||
|
|
||||||
/* Server error codes (ARES_ENODATA indicates no relevant answer) */
|
|
||||||
#define ARES_ENODATA 1
|
|
||||||
#define ARES_EFORMERR 2
|
|
||||||
#define ARES_ESERVFAIL 3
|
|
||||||
#define ARES_ENOTFOUND 4
|
|
||||||
#define ARES_ENOTIMP 5
|
|
||||||
#define ARES_EREFUSED 6
|
|
||||||
|
|
||||||
/* Locally generated error codes */
|
|
||||||
#define ARES_EBADQUERY 7
|
|
||||||
#define ARES_EBADNAME 8
|
|
||||||
#define ARES_EBADFAMILY 9
|
|
||||||
#define ARES_EBADRESP 10
|
|
||||||
#define ARES_ECONNREFUSED 11
|
|
||||||
#define ARES_ETIMEOUT 12
|
|
||||||
#define ARES_EOF 13
|
|
||||||
#define ARES_EFILE 14
|
|
||||||
#define ARES_ENOMEM 15
|
|
||||||
#define ARES_EDESTRUCTION 16
|
|
||||||
#define ARES_EBADSTR 17
|
|
||||||
|
|
||||||
/* ares_getnameinfo error codes */
|
|
||||||
#define ARES_EBADFLAGS 18
|
|
||||||
|
|
||||||
/* ares_getaddrinfo error codes */
|
|
||||||
#define ARES_ENONAME 19
|
|
||||||
#define ARES_EBADHINTS 20
|
|
||||||
|
|
||||||
/* Flag values */
|
|
||||||
#define ARES_FLAG_USEVC (1 << 0)
|
|
||||||
#define ARES_FLAG_PRIMARY (1 << 1)
|
|
||||||
#define ARES_FLAG_IGNTC (1 << 2)
|
|
||||||
#define ARES_FLAG_NORECURSE (1 << 3)
|
|
||||||
#define ARES_FLAG_STAYOPEN (1 << 4)
|
|
||||||
#define ARES_FLAG_NOSEARCH (1 << 5)
|
|
||||||
#define ARES_FLAG_NOALIASES (1 << 6)
|
|
||||||
#define ARES_FLAG_NOCHECKRESP (1 << 7)
|
|
||||||
|
|
||||||
/* Option mask values */
|
|
||||||
#define ARES_OPT_FLAGS (1 << 0)
|
|
||||||
#define ARES_OPT_TIMEOUT (1 << 1)
|
|
||||||
#define ARES_OPT_TRIES (1 << 2)
|
|
||||||
#define ARES_OPT_NDOTS (1 << 3)
|
|
||||||
#define ARES_OPT_UDP_PORT (1 << 4)
|
|
||||||
#define ARES_OPT_TCP_PORT (1 << 5)
|
|
||||||
#define ARES_OPT_SERVERS (1 << 6)
|
|
||||||
#define ARES_OPT_DOMAINS (1 << 7)
|
|
||||||
#define ARES_OPT_LOOKUPS (1 << 8)
|
|
||||||
#define ARES_OPT_SOCK_STATE_CB (1 << 9)
|
|
||||||
#define ARES_OPT_SORTLIST (1 << 10)
|
|
||||||
#define ARES_OPT_SOCK_SNDBUF (1 << 11)
|
|
||||||
#define ARES_OPT_SOCK_RCVBUF (1 << 12)
|
|
||||||
#define ARES_OPT_TIMEOUTMS (1 << 13)
|
|
||||||
#define ARES_OPT_ROTATE (1 << 14)
|
|
||||||
|
|
||||||
/* Nameinfo flag values */
|
|
||||||
#define ARES_NI_NOFQDN (1 << 0)
|
|
||||||
#define ARES_NI_NUMERICHOST (1 << 1)
|
|
||||||
#define ARES_NI_NAMEREQD (1 << 2)
|
|
||||||
#define ARES_NI_NUMERICSERV (1 << 3)
|
|
||||||
#define ARES_NI_DGRAM (1 << 4)
|
|
||||||
#define ARES_NI_TCP 0
|
|
||||||
#define ARES_NI_UDP ARES_NI_DGRAM
|
|
||||||
#define ARES_NI_SCTP (1 << 5)
|
|
||||||
#define ARES_NI_DCCP (1 << 6)
|
|
||||||
#define ARES_NI_NUMERICSCOPE (1 << 7)
|
|
||||||
#define ARES_NI_LOOKUPHOST (1 << 8)
|
|
||||||
#define ARES_NI_LOOKUPSERVICE (1 << 9)
|
|
||||||
/* Reserved for future use */
|
|
||||||
#define ARES_NI_IDN (1 << 10)
|
|
||||||
#define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
|
||||||
#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
|
||||||
|
|
||||||
/* Addrinfo flag values */
|
|
||||||
#define ARES_AI_CANONNAME (1 << 0)
|
|
||||||
#define ARES_AI_NUMERICHOST (1 << 1)
|
|
||||||
#define ARES_AI_PASSIVE (1 << 2)
|
|
||||||
#define ARES_AI_NUMERICSERV (1 << 3)
|
|
||||||
#define ARES_AI_V4MAPPED (1 << 4)
|
|
||||||
#define ARES_AI_ALL (1 << 5)
|
|
||||||
#define ARES_AI_ADDRCONFIG (1 << 6)
|
|
||||||
/* Reserved for future use */
|
|
||||||
#define ARES_AI_IDN (1 << 10)
|
|
||||||
#define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
|
||||||
#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
|
||||||
#define ARES_AI_CANONIDN (1 << 13)
|
|
||||||
|
|
||||||
#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
|
|
||||||
ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
|
|
||||||
ARES_AI_ADDRCONFIG)
|
|
||||||
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
|
|
||||||
many sockets */
|
|
||||||
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
|
|
||||||
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
|
|
||||||
ARES_GETSOCK_MAXNUM)))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Typedef our socket type
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ares_socket_typedef
|
|
||||||
#ifdef WIN32
|
|
||||||
typedef SOCKET ares_socket_t;
|
|
||||||
#define ARES_SOCKET_BAD INVALID_SOCKET
|
|
||||||
#else
|
|
||||||
typedef int ares_socket_t;
|
|
||||||
#define ARES_SOCKET_BAD -1
|
|
||||||
#endif
|
|
||||||
#define ares_socket_typedef
|
|
||||||
#endif /* ares_socket_typedef */
|
|
||||||
|
|
||||||
typedef void (*ares_sock_state_cb)(void *data,
|
|
||||||
ares_socket_t socket_fd,
|
|
||||||
int readable,
|
|
||||||
int writable);
|
|
||||||
|
|
||||||
struct apattern;
|
|
||||||
|
|
||||||
/* NOTE about the ares_options struct to users and developers.
|
|
||||||
|
|
||||||
This struct will remain looking like this. It will not be extended nor
|
|
||||||
shrunk in future releases, but all new options will be set by ares_set_*()
|
|
||||||
options instead of with the ares_init_options() function.
|
|
||||||
|
|
||||||
Eventually (in a galaxy far far away), all options will be settable by
|
|
||||||
ares_set_*() options and the ares_init_options() function will become
|
|
||||||
deprecated.
|
|
||||||
|
|
||||||
When new options are added to c-ares, they are not added to this
|
|
||||||
struct. And they are not "saved" with the ares_save_options() function but
|
|
||||||
instead we encourage the use of the ares_dup() function. Needless to say,
|
|
||||||
if you add config options to c-ares you need to make sure ares_dup()
|
|
||||||
duplicates this new option.
|
|
||||||
|
|
||||||
*/
|
|
||||||
struct ares_options {
|
|
||||||
int flags;
|
|
||||||
int timeout; /* in seconds or milliseconds, depending on options */
|
|
||||||
int tries;
|
|
||||||
int ndots;
|
|
||||||
unsigned short udp_port;
|
|
||||||
unsigned short tcp_port;
|
|
||||||
int socket_send_buffer_size;
|
|
||||||
int socket_receive_buffer_size;
|
|
||||||
struct in_addr *servers;
|
|
||||||
int nservers;
|
|
||||||
char **domains;
|
|
||||||
int ndomains;
|
|
||||||
char *lookups;
|
|
||||||
ares_sock_state_cb sock_state_cb;
|
|
||||||
void *sock_state_cb_data;
|
|
||||||
struct apattern *sortlist;
|
|
||||||
int nsort;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hostent;
|
|
||||||
struct timeval;
|
|
||||||
struct sockaddr;
|
|
||||||
struct ares_channeldata;
|
|
||||||
typedef struct ares_channeldata *ares_channel;
|
|
||||||
typedef void (*ares_callback)(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen);
|
|
||||||
typedef void (*ares_host_callback)(void *arg, int status, int timeouts,
|
|
||||||
struct hostent *hostent);
|
|
||||||
typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts,
|
|
||||||
char *node, char *service);
|
|
||||||
typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
|
|
||||||
int type, void *data);
|
|
||||||
|
|
||||||
int ares_init(ares_channel *channelptr);
|
|
||||||
int ares_init_options(ares_channel *channelptr, struct ares_options *options,
|
|
||||||
int optmask);
|
|
||||||
int ares_save_options(ares_channel channel, struct ares_options *options,
|
|
||||||
int *optmask);
|
|
||||||
void ares_destroy_options(struct ares_options *options);
|
|
||||||
int ares_dup(ares_channel *dest, ares_channel src);
|
|
||||||
void ares_destroy(ares_channel channel);
|
|
||||||
void ares_cancel(ares_channel channel);
|
|
||||||
void ares_set_socket_callback(ares_channel channel,
|
|
||||||
ares_sock_create_callback callback,
|
|
||||||
void *user_data);
|
|
||||||
void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
|
|
||||||
ares_callback callback, void *arg);
|
|
||||||
void ares_query(ares_channel channel, const char *name, int dnsclass,
|
|
||||||
int type, ares_callback callback, void *arg);
|
|
||||||
void ares_search(ares_channel channel, const char *name, int dnsclass,
|
|
||||||
int type, ares_callback callback, void *arg);
|
|
||||||
void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
|
||||||
ares_host_callback callback, void *arg);
|
|
||||||
int ares_gethostbyname_file(ares_channel channel, const char *name,
|
|
||||||
int family, struct hostent **host);
|
|
||||||
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
|
||||||
int family, ares_host_callback callback, void *arg);
|
|
||||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
|
||||||
socklen_t salen, int flags,
|
|
||||||
ares_nameinfo_callback callback,
|
|
||||||
void *arg);
|
|
||||||
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
|
|
||||||
int ares_getsock(ares_channel channel, int *socks, int numsocks);
|
|
||||||
struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
|
|
||||||
struct timeval *tv);
|
|
||||||
void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
|
|
||||||
void ares_process_fd(ares_channel channel, ares_socket_t read_fd,
|
|
||||||
ares_socket_t write_fd);
|
|
||||||
|
|
||||||
int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
|
|
||||||
int rd, unsigned char **buf, int *buflen);
|
|
||||||
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
|
||||||
int alen, char **s, long *enclen);
|
|
||||||
int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
|
|
||||||
int alen, unsigned char **s, long *enclen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: before c-ares 1.6.1 we would most often use the system in6_addr
|
|
||||||
* struct below when ares itself was built, but many apps would use this
|
|
||||||
* private version since the header checked a HAVE_* define for it. Starting
|
|
||||||
* with 1.6.1 we always declare and use our own to stop relying on the
|
|
||||||
* system's one.
|
|
||||||
*/
|
|
||||||
struct ares_in6_addr {
|
|
||||||
union {
|
|
||||||
unsigned char _S6_u8[16];
|
|
||||||
} _S6_un;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: the structs 'addrttl' and 'addr6ttl' really should get their names
|
|
||||||
* prefixed with ares_ to keep them in our own "name space".
|
|
||||||
*/
|
|
||||||
struct addrttl {
|
|
||||||
struct in_addr ipaddr;
|
|
||||||
int ttl;
|
|
||||||
};
|
|
||||||
struct addr6ttl {
|
|
||||||
struct ares_in6_addr ip6addr;
|
|
||||||
int ttl;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Parse the buffer, starting at *abuf and of length alen bytes, previously
|
|
||||||
** obtained from an ares_search call. Put the results in *host, if nonnull.
|
|
||||||
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
|
|
||||||
** their TTLs in that array, and set *naddrttls to the number of addresses
|
|
||||||
** so written.
|
|
||||||
*/
|
|
||||||
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|
||||||
struct hostent **host,
|
|
||||||
struct addrttl *addrttls, int *naddrttls);
|
|
||||||
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|
||||||
struct hostent **host,
|
|
||||||
struct addr6ttl *addrttls, int *naddrttls);
|
|
||||||
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|
||||||
int addrlen, int family, struct hostent **host);
|
|
||||||
int ares_parse_ns_reply(const unsigned char *abuf, int alen,
|
|
||||||
struct hostent **host);
|
|
||||||
void ares_free_string(void *str);
|
|
||||||
void ares_free_hostent(struct hostent *host);
|
|
||||||
const char *ares_strerror(int code);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ARES__H */
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
void ares__close_sockets(ares_channel channel, struct server_state *server)
|
|
||||||
{
|
|
||||||
struct send_request *sendreq;
|
|
||||||
|
|
||||||
/* Free all pending output buffers. */
|
|
||||||
while (server->qhead)
|
|
||||||
{
|
|
||||||
/* Advance server->qhead; pull out query as we go. */
|
|
||||||
sendreq = server->qhead;
|
|
||||||
server->qhead = sendreq->next;
|
|
||||||
if (sendreq->data_storage != NULL)
|
|
||||||
free(sendreq->data_storage);
|
|
||||||
free(sendreq);
|
|
||||||
}
|
|
||||||
server->qtail = NULL;
|
|
||||||
|
|
||||||
/* Reset any existing input buffer. */
|
|
||||||
if (server->tcp_buffer)
|
|
||||||
free(server->tcp_buffer);
|
|
||||||
server->tcp_buffer = NULL;
|
|
||||||
server->tcp_lenbuf_pos = 0;
|
|
||||||
|
|
||||||
/* Reset brokenness */
|
|
||||||
server->is_broken = 0;
|
|
||||||
|
|
||||||
/* Close the TCP and UDP sockets. */
|
|
||||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 0, 0);
|
|
||||||
closesocket(server->tcp_socket);
|
|
||||||
server->tcp_socket = ARES_SOCKET_BAD;
|
|
||||||
server->tcp_connection_generation = ++channel->tcp_connection_generation;
|
|
||||||
}
|
|
||||||
if (server->udp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
SOCK_STATE_CALLBACK(channel, server->udp_socket, 0, 0);
|
|
||||||
closesocket(server->udp_socket);
|
|
||||||
server->udp_socket = ARES_SOCKET_BAD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#if !defined(WIN32) || defined(WATT32)
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
|
||||||
{
|
|
||||||
char *line = NULL, *p, *q, *canonical, **alias;
|
|
||||||
int status, linesize, end_at_hostname, naliases;
|
|
||||||
struct in_addr addr;
|
|
||||||
struct in6_addr addr6;
|
|
||||||
int addrlen = sizeof(struct in_addr);
|
|
||||||
struct hostent *hostent = NULL;
|
|
||||||
|
|
||||||
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Skip comment lines; terminate line at comment character. */
|
|
||||||
if (*line == '#' || !*line)
|
|
||||||
continue;
|
|
||||||
p = strchr(line, '#');
|
|
||||||
if (p)
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
/* Get the address part. */
|
|
||||||
p = line;
|
|
||||||
while (*p && !ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
if (!*p)
|
|
||||||
continue;
|
|
||||||
*p = 0;
|
|
||||||
addr.s_addr = inet_addr(line);
|
|
||||||
if (addr.s_addr == INADDR_NONE)
|
|
||||||
{
|
|
||||||
/* It wasn't an AF_INET dotted address, then AF_UNSPEC and AF_INET6
|
|
||||||
families are subject for this further check */
|
|
||||||
if ((family != AF_INET) &&
|
|
||||||
(ares_inet_pton(AF_INET6, line, &addr6) > 0)) {
|
|
||||||
addrlen = sizeof(struct in6_addr);
|
|
||||||
family = AF_INET6;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (family == AF_UNSPEC)
|
|
||||||
family = AF_INET; /* now confirmed! */
|
|
||||||
else if (family != AF_INET)
|
|
||||||
/* unknown, keep moving */
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Get the canonical hostname. */
|
|
||||||
p++;
|
|
||||||
while (ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
if (!*p)
|
|
||||||
continue;
|
|
||||||
q = p;
|
|
||||||
while (*q && !ISSPACE(*q))
|
|
||||||
q++;
|
|
||||||
end_at_hostname = (*q == 0);
|
|
||||||
*q = 0;
|
|
||||||
canonical = p;
|
|
||||||
|
|
||||||
naliases = 0;
|
|
||||||
if (!end_at_hostname)
|
|
||||||
{
|
|
||||||
/* Count the aliases. */
|
|
||||||
p = q + 1;
|
|
||||||
while (ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
while (*p)
|
|
||||||
{
|
|
||||||
while (*p && !ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
while (ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
naliases++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory for the host structure. */
|
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (!hostent)
|
|
||||||
break;
|
|
||||||
hostent->h_aliases = NULL;
|
|
||||||
hostent->h_addr_list = NULL;
|
|
||||||
hostent->h_name = strdup(canonical);
|
|
||||||
if (!hostent->h_name)
|
|
||||||
break;
|
|
||||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
|
||||||
if (!hostent->h_addr_list)
|
|
||||||
break;
|
|
||||||
hostent->h_addr_list[0] = malloc(addrlen);
|
|
||||||
if (!hostent->h_addr_list[0])
|
|
||||||
break;
|
|
||||||
hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
|
|
||||||
if (!hostent->h_aliases)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Copy in aliases. */
|
|
||||||
naliases = 0;
|
|
||||||
if (!end_at_hostname)
|
|
||||||
{
|
|
||||||
p = canonical + strlen(canonical) + 1;
|
|
||||||
while (ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
while (*p)
|
|
||||||
{
|
|
||||||
q = p;
|
|
||||||
while (*q && !ISSPACE(*q))
|
|
||||||
q++;
|
|
||||||
hostent->h_aliases[naliases] = malloc(q - p + 1);
|
|
||||||
if (hostent->h_aliases[naliases] == NULL)
|
|
||||||
break;
|
|
||||||
memcpy(hostent->h_aliases[naliases], p, q - p);
|
|
||||||
hostent->h_aliases[naliases][q - p] = 0;
|
|
||||||
p = q;
|
|
||||||
while (ISSPACE(*p))
|
|
||||||
p++;
|
|
||||||
naliases++;
|
|
||||||
}
|
|
||||||
if (*p)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hostent->h_aliases[naliases] = NULL;
|
|
||||||
|
|
||||||
hostent->h_addrtype = family;
|
|
||||||
hostent->h_length = addrlen;
|
|
||||||
if (family == AF_INET)
|
|
||||||
memcpy(hostent->h_addr_list[0], &addr, addrlen);
|
|
||||||
else if (family == AF_INET6)
|
|
||||||
memcpy(hostent->h_addr_list[0], &addr6, addrlen);
|
|
||||||
hostent->h_addr_list[1] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
free(line);
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
if(line)
|
|
||||||
free(line);
|
|
||||||
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Memory allocation failure; clean up. */
|
|
||||||
if (hostent)
|
|
||||||
{
|
|
||||||
if(hostent->h_name)
|
|
||||||
free((char *) hostent->h_name);
|
|
||||||
if (hostent->h_aliases)
|
|
||||||
{
|
|
||||||
for (alias = hostent->h_aliases; *alias; alias++)
|
|
||||||
free(*alias);
|
|
||||||
}
|
|
||||||
if(hostent->h_aliases)
|
|
||||||
free(hostent->h_aliases);
|
|
||||||
if (hostent->h_addr_list && hostent->h_addr_list[0])
|
|
||||||
free(hostent->h_addr_list[0]);
|
|
||||||
if(hostent->h_addr_list)
|
|
||||||
free(hostent->h_addr_list);
|
|
||||||
free(hostent);
|
|
||||||
}
|
|
||||||
*host = NULL;
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
/* This is an internal function. Its contract is to read a line from
|
|
||||||
* a file into a dynamically allocated buffer, zeroing the trailing
|
|
||||||
* newline if there is one. The calling routine may call
|
|
||||||
* ares__read_line multiple times with the same buf and bufsize
|
|
||||||
* pointers; *buf will be reallocated and *bufsize adjusted as
|
|
||||||
* appropriate. The initial value of *buf should be NULL. After the
|
|
||||||
* calling routine is done reading lines, it should free *buf.
|
|
||||||
*/
|
|
||||||
int ares__read_line(FILE *fp, char **buf, int *bufsize)
|
|
||||||
{
|
|
||||||
char *newbuf;
|
|
||||||
size_t offset = 0;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (*buf == NULL)
|
|
||||||
{
|
|
||||||
*buf = malloc(128);
|
|
||||||
if (!*buf)
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
*bufsize = 128;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (!fgets(*buf + offset, *bufsize - (int)offset, fp))
|
|
||||||
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
|
|
||||||
len = offset + strlen(*buf + offset);
|
|
||||||
if ((*buf)[len - 1] == '\n')
|
|
||||||
{
|
|
||||||
(*buf)[len - 1] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
offset = len;
|
|
||||||
|
|
||||||
/* Allocate more space. */
|
|
||||||
newbuf = realloc(*buf, *bufsize * 2);
|
|
||||||
if (!newbuf)
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
*buf = newbuf;
|
|
||||||
*bufsize *= 2;
|
|
||||||
}
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright (C) 2008 by Daniel Stenberg et al
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software and its
|
|
||||||
* documentation for any purpose and without fee is hereby granted, provided
|
|
||||||
* that the above copyright notice appear in all copies and that both that
|
|
||||||
* copyright notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the software without specific,
|
|
||||||
* written prior permission. M.I.T. makes no representations about the
|
|
||||||
* suitability of this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(MSDOS)
|
|
||||||
|
|
||||||
struct timeval ares__tvnow(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** GetTickCount() is available on _all_ Windows versions from W95 up
|
|
||||||
** to nowadays. Returns milliseconds elapsed since last system boot,
|
|
||||||
** increases monotonically and wraps once 49.7 days have elapsed.
|
|
||||||
*/
|
|
||||||
struct timeval now;
|
|
||||||
DWORD milliseconds = GetTickCount();
|
|
||||||
now.tv_sec = milliseconds / 1000;
|
|
||||||
now.tv_usec = (milliseconds % 1000) * 1000;
|
|
||||||
return now;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
|
|
||||||
|
|
||||||
struct timeval ares__tvnow(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** clock_gettime() is granted to be increased monotonically when the
|
|
||||||
** monotonic clock is queried. Time starting point is unspecified, it
|
|
||||||
** could be the system start-up time, the Epoch, or something else,
|
|
||||||
** in any case the time starting point does not change once that the
|
|
||||||
** system has started up.
|
|
||||||
*/
|
|
||||||
struct timeval now;
|
|
||||||
struct timespec tsnow;
|
|
||||||
if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
|
|
||||||
now.tv_sec = tsnow.tv_sec;
|
|
||||||
now.tv_usec = tsnow.tv_nsec / 1000;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
** Even when the configure process has truly detected monotonic clock
|
|
||||||
** availability, it might happen that it is not actually available at
|
|
||||||
** run-time. When this occurs simply fallback to other time source.
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
|
||||||
else
|
|
||||||
(void)gettimeofday(&now, NULL);
|
|
||||||
#else
|
|
||||||
else {
|
|
||||||
now.tv_sec = (long)time(NULL);
|
|
||||||
now.tv_usec = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return now;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_GETTIMEOFDAY)
|
|
||||||
|
|
||||||
struct timeval ares__tvnow(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** gettimeofday() is not granted to be increased monotonically, due to
|
|
||||||
** clock drifting and external source time synchronization it can jump
|
|
||||||
** forward or backward in time.
|
|
||||||
*/
|
|
||||||
struct timeval now;
|
|
||||||
(void)gettimeofday(&now, NULL);
|
|
||||||
return now;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
struct timeval ares__tvnow(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** time() returns the value of time in seconds since the Epoch.
|
|
||||||
*/
|
|
||||||
struct timeval now;
|
|
||||||
now.tv_sec = (long)time(NULL);
|
|
||||||
now.tv_usec = 0;
|
|
||||||
return now;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0 /* Not used */
|
|
||||||
/*
|
|
||||||
* Make sure that the first argument is the more recent time, as otherwise
|
|
||||||
* we'll get a weird negative time-diff back...
|
|
||||||
*
|
|
||||||
* Returns: the time difference in number of milliseconds.
|
|
||||||
*/
|
|
||||||
long ares__tvdiff(struct timeval newer, struct timeval older)
|
|
||||||
{
|
|
||||||
return (newer.tv_sec-older.tv_sec)*1000+
|
|
||||||
(newer.tv_usec-older.tv_usec)/1000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_CANCEL 3 "31 March 2004"
|
|
||||||
.SH NAME
|
|
||||||
ares_cancel \- Cancel a resolve
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_cancel(ares_channel \fIchannel\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The \fBares_cancel\fP function cancels all lookups/requests made on the the
|
|
||||||
name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
|
|
||||||
the callbacks for each pending query on the channel, passing a status of
|
|
||||||
.BR ARES_ETIMEOUT .
|
|
||||||
These calls give the callbacks a chance to clean up any state which
|
|
||||||
might have been stored in their arguments.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_init (3)
|
|
||||||
.BR ares_destroy (3)
|
|
||||||
.SH NOTES
|
|
||||||
This function was added in c-ares 1.2.0
|
|
||||||
.SH AUTHOR
|
|
||||||
Dirk Manske
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright (C) 2004 by Daniel Stenberg et al
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software and its
|
|
||||||
* documentation for any purpose and without fee is hereby granted, provided
|
|
||||||
* that the above copyright notice appear in all copies and that both that
|
|
||||||
* copyright notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the software without specific,
|
|
||||||
* written prior permission. M.I.T. makes no representations about the
|
|
||||||
* suitability of this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ares_cancel() cancels all ongoing requests/resolves that might be going on
|
|
||||||
* on the given channel. It does NOT kill the channel, use ares_destroy() for
|
|
||||||
* that.
|
|
||||||
*/
|
|
||||||
void ares_cancel(ares_channel channel)
|
|
||||||
{
|
|
||||||
struct query *query;
|
|
||||||
struct list_node* list_head;
|
|
||||||
struct list_node* list_node;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
list_head = &(channel->all_queries);
|
|
||||||
for (list_node = list_head->next; list_node != list_head; )
|
|
||||||
{
|
|
||||||
query = list_node->data;
|
|
||||||
list_node = list_node->next; /* since we're deleting the query */
|
|
||||||
query->callback(query->arg, ARES_ETIMEOUT, 0, NULL, 0);
|
|
||||||
ares__free_query(query);
|
|
||||||
}
|
|
||||||
#ifndef NDEBUG
|
|
||||||
/* Freeing the query should remove it from all the lists in which it sits,
|
|
||||||
* so all query lists should be empty now.
|
|
||||||
*/
|
|
||||||
assert(ares__is_list_empty(&(channel->all_queries)));
|
|
||||||
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
|
||||||
{
|
|
||||||
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
|
||||||
}
|
|
||||||
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
|
||||||
{
|
|
||||||
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!(channel->flags & ARES_FLAG_STAYOPEN))
|
|
||||||
{
|
|
||||||
if (channel->servers)
|
|
||||||
{
|
|
||||||
for (i = 0; i < channel->nservers; i++)
|
|
||||||
ares__close_sockets(channel, &channel->servers[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_DESTROY 3 "7 December 2004"
|
|
||||||
.SH NAME
|
|
||||||
ares_destroy \- Destroy a resolver channel
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_destroy(ares_channel \fIchannel\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_destroy
|
|
||||||
function destroys the name service channel identified by
|
|
||||||
.IR channel ,
|
|
||||||
freeing all memory and closing all sockets used by the channel.
|
|
||||||
.B ares_destroy
|
|
||||||
invokes the callbacks for each pending query on the channel, passing a
|
|
||||||
status of
|
|
||||||
.BR ARES_EDESTRUCTION .
|
|
||||||
These calls give the callbacks a chance to clean up any state which
|
|
||||||
might have been stored in their arguments.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_init (3),
|
|
||||||
.BR ares_cancel (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
void ares_destroy_options(struct ares_options *options)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
free(options->servers);
|
|
||||||
for (i = 0; i < options->ndomains; i++)
|
|
||||||
free(options->domains[i]);
|
|
||||||
free(options->domains);
|
|
||||||
if(options->sortlist)
|
|
||||||
free(options->sortlist);
|
|
||||||
free(options->lookups);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ares_destroy(ares_channel channel)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct query *query;
|
|
||||||
struct list_node* list_head;
|
|
||||||
struct list_node* list_node;
|
|
||||||
|
|
||||||
if (!channel)
|
|
||||||
return;
|
|
||||||
|
|
||||||
list_head = &(channel->all_queries);
|
|
||||||
for (list_node = list_head->next; list_node != list_head; )
|
|
||||||
{
|
|
||||||
query = list_node->data;
|
|
||||||
list_node = list_node->next; /* since we're deleting the query */
|
|
||||||
query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL, 0);
|
|
||||||
ares__free_query(query);
|
|
||||||
}
|
|
||||||
#ifndef NDEBUG
|
|
||||||
/* Freeing the query should remove it from all the lists in which it sits,
|
|
||||||
* so all query lists should be empty now.
|
|
||||||
*/
|
|
||||||
assert(ares__is_list_empty(&(channel->all_queries)));
|
|
||||||
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
|
||||||
{
|
|
||||||
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
|
||||||
}
|
|
||||||
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
|
||||||
{
|
|
||||||
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (channel->servers) {
|
|
||||||
for (i = 0; i < channel->nservers; i++)
|
|
||||||
{
|
|
||||||
struct server_state *server = &channel->servers[i];
|
|
||||||
ares__close_sockets(channel, server);
|
|
||||||
assert(ares__is_list_empty(&(server->queries_to_server)));
|
|
||||||
}
|
|
||||||
free(channel->servers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel->domains) {
|
|
||||||
for (i = 0; i < channel->ndomains; i++)
|
|
||||||
free(channel->domains[i]);
|
|
||||||
free(channel->domains);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(channel->sortlist)
|
|
||||||
free(channel->sortlist);
|
|
||||||
|
|
||||||
if (channel->lookups)
|
|
||||||
free(channel->lookups);
|
|
||||||
|
|
||||||
free(channel);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_DESTROY_OPTIONS 3 "1 June 2007"
|
|
||||||
.SH NAME
|
|
||||||
ares_destroy_options \- Destroy options initialized with ares_save_options
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_destroy_options(struct ares_options *\fIoptions\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_destroy_options
|
|
||||||
function destroys the options struct identified by
|
|
||||||
.IR options ,
|
|
||||||
freeing all memory allocated by ares_save_options.
|
|
||||||
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_save_options (3),
|
|
||||||
.BR ares_init_options (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Brad House
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARES__DNS_H
|
|
||||||
#define ARES__DNS_H
|
|
||||||
|
|
||||||
#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
|
|
||||||
#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \
|
|
||||||
((p)[2] << 8) | (p)[3])
|
|
||||||
|
|
||||||
#define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \
|
|
||||||
((p)[1] = (unsigned char)((v) & 0xff)))
|
|
||||||
#define DNS__SET32BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 24) & 0xff)), \
|
|
||||||
((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \
|
|
||||||
((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \
|
|
||||||
((p)[3] = (unsigned char)((v) & 0xff)))
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* we cannot use this approach on systems where we can't access 16/32 bit
|
|
||||||
data on un-aligned addresses */
|
|
||||||
#define DNS__16BIT(p) ntohs(*(unsigned short*)(p))
|
|
||||||
#define DNS__32BIT(p) ntohl(*(unsigned long*)(p))
|
|
||||||
#define DNS__SET16BIT(p, v) *(unsigned short*)(p) = htons(v)
|
|
||||||
#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Macros for parsing a DNS header */
|
|
||||||
#define DNS_HEADER_QID(h) DNS__16BIT(h)
|
|
||||||
#define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1)
|
|
||||||
#define DNS_HEADER_OPCODE(h) (((h)[2] >> 3) & 0xf)
|
|
||||||
#define DNS_HEADER_AA(h) (((h)[2] >> 2) & 0x1)
|
|
||||||
#define DNS_HEADER_TC(h) (((h)[2] >> 1) & 0x1)
|
|
||||||
#define DNS_HEADER_RD(h) ((h)[2] & 0x1)
|
|
||||||
#define DNS_HEADER_RA(h) (((h)[3] >> 7) & 0x1)
|
|
||||||
#define DNS_HEADER_Z(h) (((h)[3] >> 4) & 0x7)
|
|
||||||
#define DNS_HEADER_RCODE(h) ((h)[3] & 0xf)
|
|
||||||
#define DNS_HEADER_QDCOUNT(h) DNS__16BIT((h) + 4)
|
|
||||||
#define DNS_HEADER_ANCOUNT(h) DNS__16BIT((h) + 6)
|
|
||||||
#define DNS_HEADER_NSCOUNT(h) DNS__16BIT((h) + 8)
|
|
||||||
#define DNS_HEADER_ARCOUNT(h) DNS__16BIT((h) + 10)
|
|
||||||
|
|
||||||
/* Macros for constructing a DNS header */
|
|
||||||
#define DNS_HEADER_SET_QID(h, v) DNS__SET16BIT(h, v)
|
|
||||||
#define DNS_HEADER_SET_QR(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 7))
|
|
||||||
#define DNS_HEADER_SET_OPCODE(h, v) ((h)[2] |= (unsigned char)(((v) & 0xf) << 3))
|
|
||||||
#define DNS_HEADER_SET_AA(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 2))
|
|
||||||
#define DNS_HEADER_SET_TC(h, v) ((h)[2] |= (unsigned char)(((v) & 0x1) << 1))
|
|
||||||
#define DNS_HEADER_SET_RD(h, v) ((h)[2] |= (unsigned char)((v) & 0x1))
|
|
||||||
#define DNS_HEADER_SET_RA(h, v) ((h)[3] |= (unsigned char)(((v) & 0x1) << 7))
|
|
||||||
#define DNS_HEADER_SET_Z(h, v) ((h)[3] |= (unsigned char)(((v) & 0x7) << 4))
|
|
||||||
#define DNS_HEADER_SET_RCODE(h, v) ((h)[3] |= (unsigned char)((v) & 0xf))
|
|
||||||
#define DNS_HEADER_SET_QDCOUNT(h, v) DNS__SET16BIT((h) + 4, v)
|
|
||||||
#define DNS_HEADER_SET_ANCOUNT(h, v) DNS__SET16BIT((h) + 6, v)
|
|
||||||
#define DNS_HEADER_SET_NSCOUNT(h, v) DNS__SET16BIT((h) + 8, v)
|
|
||||||
#define DNS_HEADER_SET_ARCOUNT(h, v) DNS__SET16BIT((h) + 10, v)
|
|
||||||
|
|
||||||
/* Macros for parsing the fixed part of a DNS question */
|
|
||||||
#define DNS_QUESTION_TYPE(q) DNS__16BIT(q)
|
|
||||||
#define DNS_QUESTION_CLASS(q) DNS__16BIT((q) + 2)
|
|
||||||
|
|
||||||
/* Macros for constructing the fixed part of a DNS question */
|
|
||||||
#define DNS_QUESTION_SET_TYPE(q, v) DNS__SET16BIT(q, v)
|
|
||||||
#define DNS_QUESTION_SET_CLASS(q, v) DNS__SET16BIT((q) + 2, v)
|
|
||||||
|
|
||||||
/* Macros for parsing the fixed part of a DNS resource record */
|
|
||||||
#define DNS_RR_TYPE(r) DNS__16BIT(r)
|
|
||||||
#define DNS_RR_CLASS(r) DNS__16BIT((r) + 2)
|
|
||||||
#define DNS_RR_TTL(r) DNS__32BIT((r) + 4)
|
|
||||||
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
|
|
||||||
|
|
||||||
/* Macros for constructing the fixed part of a DNS resource record */
|
|
||||||
#define DNS_RR_SET_TYPE(r) DNS__SET16BIT(r, v)
|
|
||||||
#define DNS_RR_SET_CLASS(r) DNS__SET16BIT((r) + 2, v)
|
|
||||||
#define DNS_RR_SET_TTL(r) DNS__SET32BIT((r) + 4, v)
|
|
||||||
#define DNS_RR_SET_LEN(r) DNS__SET16BIT((r) + 8, v)
|
|
||||||
|
|
||||||
#endif /* ARES__DNS_H */
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright (C) 2007-2008 by Daniel Stenberg
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_DUP 3 "2 Dec 2008"
|
|
||||||
.SH NAME
|
|
||||||
ares_dup \- Duplicate a resolver channel
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_dup(ares_channel *\fIchannel\fP, ares_channel \fIsource\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The \fBares_dup(3)\fP function duplicates an existing communications channel
|
|
||||||
for name service lookups. If it returns successfully, \fBares_dup(3)\fP will
|
|
||||||
set the variable pointed to by \fIchannel\fP to a handle used to identify the
|
|
||||||
name service channel. The caller should invoke \fIares_destroy(3)\fP on the
|
|
||||||
handle when the channel is no longer needed.
|
|
||||||
|
|
||||||
The \fBares_dup_options\fP function also initializes a name service channel,
|
|
||||||
with additional options set exactly as the \fIsource\fP channel has them
|
|
||||||
configured.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_destroy(3),
|
|
||||||
.BR ares_init(3)
|
|
||||||
.SH AVAILABILITY
|
|
||||||
ares_dup(3) was added in c-ares 1.6.0
|
|
||||||
.SH AUTHOR
|
|
||||||
Daniel Stenberg
|
|
||||||
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_EXPAND_NAME 3 "23 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_expand_name \- Expand a DNS-encoded domain name
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_expand_name(const unsigned char *\fIencoded\fP,
|
|
||||||
.B const unsigned char *\fIabuf\fP, int \fIalen\fP, char **\fIs\fP,
|
|
||||||
.B int *\fIenclen\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_expand_name
|
|
||||||
function converts a DNS-encoded domain name to a dot-separated C
|
|
||||||
string. The argument
|
|
||||||
.I encoded
|
|
||||||
gives the beginning of the encoded domain name, and the arguments
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the containing message buffer (necessary for the processing of
|
|
||||||
indirection pointers within the encoded domain name). The result is
|
|
||||||
placed in a NUL-terminated allocated buffer, a pointer to which is
|
|
||||||
stored in the variable pointed to by
|
|
||||||
.IR s .
|
|
||||||
The length of the encoded name is stored in the variable pointed to by
|
|
||||||
.I enclen
|
|
||||||
so that the caller can advance past the encoded domain name to read
|
|
||||||
further data in the message.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_expand_name
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
Expansion of the encoded name succeeded.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADNAME
|
|
||||||
The encoded domain name was malformed and could not be expanded.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_mkquery (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h" /* for the memdebug */
|
|
||||||
|
|
||||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
|
||||||
int alen);
|
|
||||||
|
|
||||||
/* Expand an RFC1035-encoded domain name given by encoded. The
|
|
||||||
* containing message is given by abuf and alen. The result given by
|
|
||||||
* *s, which is set to a NUL-terminated allocated buffer. *enclen is
|
|
||||||
* set to the length of the encoded name (not the length of the
|
|
||||||
* expanded name; the goal is to tell the caller how many bytes to
|
|
||||||
* move forward to get past the encoded name).
|
|
||||||
*
|
|
||||||
* In the simple case, an encoded name is a series of labels, each
|
|
||||||
* composed of a one-byte length (limited to values between 0 and 63
|
|
||||||
* inclusive) followed by the label contents. The name is terminated
|
|
||||||
* by a zero-length label.
|
|
||||||
*
|
|
||||||
* In the more complicated case, a label may be terminated by an
|
|
||||||
* indirection pointer, specified by two bytes with the high bits of
|
|
||||||
* the first byte (corresponding to INDIR_MASK) set to 11. With the
|
|
||||||
* two high bits of the first byte stripped off, the indirection
|
|
||||||
* pointer gives an offset from the beginning of the containing
|
|
||||||
* message with more labels to decode. Indirection can happen an
|
|
||||||
* arbitrary number of times, so we have to detect loops.
|
|
||||||
*
|
|
||||||
* Since the expanded name uses '.' as a label separator, we use
|
|
||||||
* backslashes to escape periods or backslashes in the expanded name.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
|
||||||
int alen, char **s, long *enclen)
|
|
||||||
{
|
|
||||||
int len, indir = 0;
|
|
||||||
char *q;
|
|
||||||
const unsigned char *p;
|
|
||||||
|
|
||||||
len = name_length(encoded, abuf, alen);
|
|
||||||
if (len == -1)
|
|
||||||
return ARES_EBADNAME;
|
|
||||||
|
|
||||||
*s = malloc(len + 1);
|
|
||||||
if (!*s)
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
q = *s;
|
|
||||||
|
|
||||||
if (len == 0) {
|
|
||||||
/* RFC2181 says this should be ".": the root of the DNS tree.
|
|
||||||
* Since this function strips trailing dots though, it becomes ""
|
|
||||||
*/
|
|
||||||
q[0] = '\0';
|
|
||||||
*enclen = 1; /* the caller should move one byte to get past this */
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No error-checking necessary; it was all done by name_length(). */
|
|
||||||
p = encoded;
|
|
||||||
while (*p)
|
|
||||||
{
|
|
||||||
if ((*p & INDIR_MASK) == INDIR_MASK)
|
|
||||||
{
|
|
||||||
if (!indir)
|
|
||||||
{
|
|
||||||
*enclen = p + 2 - encoded;
|
|
||||||
indir = 1;
|
|
||||||
}
|
|
||||||
p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = *p;
|
|
||||||
p++;
|
|
||||||
while (len--)
|
|
||||||
{
|
|
||||||
if (*p == '.' || *p == '\\')
|
|
||||||
*q++ = '\\';
|
|
||||||
*q++ = *p;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
*q++ = '.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!indir)
|
|
||||||
*enclen = p + 1 - encoded;
|
|
||||||
|
|
||||||
/* Nuke the trailing period if we wrote one. */
|
|
||||||
if (q > *s)
|
|
||||||
*(q - 1) = 0;
|
|
||||||
else
|
|
||||||
*q = 0; /* zero terminate */
|
|
||||||
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the length of the expansion of an encoded domain name, or
|
|
||||||
* -1 if the encoding is invalid.
|
|
||||||
*/
|
|
||||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
|
||||||
int alen)
|
|
||||||
{
|
|
||||||
int n = 0, offset, indir = 0;
|
|
||||||
|
|
||||||
/* Allow the caller to pass us abuf + alen and have us check for it. */
|
|
||||||
if (encoded == abuf + alen)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
while (*encoded)
|
|
||||||
{
|
|
||||||
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
|
||||||
{
|
|
||||||
/* Check the offset and go there. */
|
|
||||||
if (encoded + 1 >= abuf + alen)
|
|
||||||
return -1;
|
|
||||||
offset = (*encoded & ~INDIR_MASK) << 8 | *(encoded + 1);
|
|
||||||
if (offset >= alen)
|
|
||||||
return -1;
|
|
||||||
encoded = abuf + offset;
|
|
||||||
|
|
||||||
/* If we've seen more indirects than the message length,
|
|
||||||
* then there's a loop.
|
|
||||||
*/
|
|
||||||
if (++indir > alen)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = *encoded;
|
|
||||||
if (encoded + offset + 1 >= abuf + alen)
|
|
||||||
return -1;
|
|
||||||
encoded++;
|
|
||||||
while (offset--)
|
|
||||||
{
|
|
||||||
n += (*encoded == '.' || *encoded == '\\') ? 2 : 1;
|
|
||||||
encoded++;
|
|
||||||
}
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there were any labels at all, then the number of dots is one
|
|
||||||
* less than the number of labels, so subtract one.
|
|
||||||
*/
|
|
||||||
return (n) ? n - 1 : n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Like ares_expand_name but returns EBADRESP in case of invalid input. */
|
|
||||||
int ares__expand_name_for_response(const unsigned char *encoded,
|
|
||||||
const unsigned char *abuf, int alen,
|
|
||||||
char **s, long *enclen)
|
|
||||||
{
|
|
||||||
int status = ares_expand_name(encoded, abuf, alen, s, enclen);
|
|
||||||
if (status == ARES_EBADNAME)
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_EXPAND_NAME 3 "23 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_expand_string \- Expand a length encoded string
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_expand_string(const unsigned char *\fIencoded\fP,
|
|
||||||
.B const unsigned char *\fIabuf\fP, int \fIalen\fP, unsigned char **\fIs\fP,
|
|
||||||
.B int *\fIenclen\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_expand_string
|
|
||||||
function converts a length encoded string to a NUL-terminated C
|
|
||||||
string. The argument
|
|
||||||
.I encoded
|
|
||||||
gives the beginning of the encoded string, and the arguments
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the containing message buffer (necessary for the processing of
|
|
||||||
indirection pointers within the encoded domain name). The result is
|
|
||||||
placed in a NUL-terminated allocated buffer, a pointer to which is
|
|
||||||
stored in the variable pointed to by
|
|
||||||
.IR s .
|
|
||||||
The length of the encoded string is stored in the variable pointed to by
|
|
||||||
.I enclen
|
|
||||||
so that the caller can advance past the encoded string to read
|
|
||||||
further data in the message.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_expand_string
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
Expansion of the encoded string succeeded.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADSTR
|
|
||||||
The encoded string was malformed and could not be expanded.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_free_string (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Dominick Meglio
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h" /* for the memdebug */
|
|
||||||
|
|
||||||
/* Simply decodes a length-encoded character string. The first byte of the
|
|
||||||
* input is the length of the string to be returned and the bytes thereafter
|
|
||||||
* are the characters of the string. The returned result will be NULL
|
|
||||||
* terminated.
|
|
||||||
*/
|
|
||||||
int ares_expand_string(const unsigned char *encoded,
|
|
||||||
const unsigned char *abuf,
|
|
||||||
int alen,
|
|
||||||
unsigned char **s,
|
|
||||||
long *enclen)
|
|
||||||
{
|
|
||||||
unsigned char *q;
|
|
||||||
long len;
|
|
||||||
if (encoded == abuf+alen)
|
|
||||||
return ARES_EBADSTR;
|
|
||||||
|
|
||||||
len = *encoded;
|
|
||||||
if (encoded+len+1 > abuf+alen)
|
|
||||||
return ARES_EBADSTR;
|
|
||||||
|
|
||||||
encoded++;
|
|
||||||
|
|
||||||
*s = malloc(len+1);
|
|
||||||
if (*s == NULL)
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
q = *s;
|
|
||||||
strncpy((char *)q, (char *)encoded, len);
|
|
||||||
q[len] = '\0';
|
|
||||||
|
|
||||||
*s = q;
|
|
||||||
|
|
||||||
*enclen = len+1;
|
|
||||||
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_FDS 3 "23 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_fds \- Get file descriptors to select on for name service
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_fds(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
|
|
||||||
.B fd_set *\fIwrite_fds\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_fds
|
|
||||||
function retrieves the set of file descriptors which the calling
|
|
||||||
application should select on for reading and writing for the
|
|
||||||
processing of name service queries pending on the name service channel
|
|
||||||
identified by
|
|
||||||
.IR channel .
|
|
||||||
File descriptors will be set in the file descriptor sets pointed to by
|
|
||||||
.I read_fds
|
|
||||||
and
|
|
||||||
.I write_fds
|
|
||||||
as appropriate. File descriptors already set in
|
|
||||||
.I read_fds
|
|
||||||
and
|
|
||||||
.I write_fds
|
|
||||||
will remain set; initialization of the file descriptor sets
|
|
||||||
(using
|
|
||||||
.BR FD_ZERO )
|
|
||||||
is the responsibility of the caller.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_fds
|
|
||||||
returns one greater than the number of the highest socket set in either
|
|
||||||
.I read_fds
|
|
||||||
or
|
|
||||||
.IR write_fds .
|
|
||||||
If no queries are active,
|
|
||||||
.B ares_fds
|
|
||||||
will return 0.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_timeout (3),
|
|
||||||
.BR ares_process (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
|
|
||||||
{
|
|
||||||
struct server_state *server;
|
|
||||||
ares_socket_t nfds;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Are there any active queries? */
|
|
||||||
int active_queries = !ares__is_list_empty(&(channel->all_queries));
|
|
||||||
|
|
||||||
nfds = 0;
|
|
||||||
for (i = 0; i < channel->nservers; i++)
|
|
||||||
{
|
|
||||||
server = &channel->servers[i];
|
|
||||||
/* We only need to register interest in UDP sockets if we have
|
|
||||||
* outstanding queries.
|
|
||||||
*/
|
|
||||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
FD_SET(server->udp_socket, read_fds);
|
|
||||||
if (server->udp_socket >= nfds)
|
|
||||||
nfds = server->udp_socket + 1;
|
|
||||||
}
|
|
||||||
/* We always register for TCP events, because we want to know
|
|
||||||
* when the other side closes the connection, so we don't waste
|
|
||||||
* time trying to use a broken connection.
|
|
||||||
*/
|
|
||||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
FD_SET(server->tcp_socket, read_fds);
|
|
||||||
if (server->qhead)
|
|
||||||
FD_SET(server->tcp_socket, write_fds);
|
|
||||||
if (server->tcp_socket >= nfds)
|
|
||||||
nfds = server->tcp_socket + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (int)nfds;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_FREE_HOSTENT 3 "23 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_free_hostent \- Free host structure allocated by ares functions
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_free_hostent(struct hostent *\fIhost\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.I ares_free_hostent
|
|
||||||
function frees a
|
|
||||||
.B struct hostent
|
|
||||||
allocated by one of the functions \fIares_parse_a_reply(3)\fP,
|
|
||||||
\fIares_parse_aaaa_reply(3)\fP, or \fIares_parse_ptr_reply(3)\fP.
|
|
||||||
.SH NOTES
|
|
||||||
It is not necessary (and is not correct) to free the host structure passed to
|
|
||||||
the callback functions for \fIares_gethostbyname(3)\fP or
|
|
||||||
\fIares_gethostbyaddr(3)\fP. c-ares will automatically free such host
|
|
||||||
structures when the callback returns.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_parse_a_reply (3),
|
|
||||||
.BR ares_parse_aaaa_reply (3),
|
|
||||||
.BR ares_parse_ptr_reply (3),
|
|
||||||
.BR ares_parse_ns_reply (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#if !defined(WIN32) || defined(WATT32)
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h" /* for memdebug */
|
|
||||||
|
|
||||||
void ares_free_hostent(struct hostent *host)
|
|
||||||
{
|
|
||||||
char **p;
|
|
||||||
|
|
||||||
free((char *)(host->h_name));
|
|
||||||
for (p = host->h_aliases; *p; p++)
|
|
||||||
free(*p);
|
|
||||||
free(host->h_aliases);
|
|
||||||
free(host->h_addr_list[0]); /* no matter if there is one or many entries,
|
|
||||||
there is only one malloc for all of them */
|
|
||||||
free(host->h_addr_list);
|
|
||||||
free(host);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 2000 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_FREE_STRING 3 "4 February 2004"
|
|
||||||
.SH NAME
|
|
||||||
ares_free_string \- Free strings allocated by ares functions
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_free_string(void *\fIstr\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.I ares_free_string
|
|
||||||
function frees a string allocated by an ares function.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_mkquery (3)
|
|
||||||
.BR ares_expand_string (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 2000 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 2000 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
void ares_free_string(void *str)
|
|
||||||
{
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_GETHOSTBYADDR 3 "24 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_gethostbyaddr \- Initiate a host query by address
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
|
|
||||||
.B int \fItimeouts\fP, struct hostent *\fIhostent\fP)
|
|
||||||
.PP
|
|
||||||
.B void ares_gethostbyaddr(ares_channel \fIchannel\fP, const void *\fIaddr\fP,
|
|
||||||
.B int \fIaddrlen\fP, int \fIfamily\fP, ares_host_callback \fIcallback\fP,
|
|
||||||
.B void *\fIarg\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_gethostbyaddr
|
|
||||||
function initiates a host query by address on the name service channel
|
|
||||||
identified by
|
|
||||||
.IR channel .
|
|
||||||
The parameters
|
|
||||||
.I addr
|
|
||||||
and
|
|
||||||
.I addrlen
|
|
||||||
give the address as a series of bytes, and
|
|
||||||
.I family
|
|
||||||
gives the type of address. When the query is complete or has failed, the ares
|
|
||||||
library will invoke \fIcallback\fP. Completion or failure of the query may
|
|
||||||
happen immediately, or may happen during a later call to
|
|
||||||
\fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I arg
|
|
||||||
is copied from the
|
|
||||||
.B ares_gethostbyaddr
|
|
||||||
argument
|
|
||||||
.IR arg .
|
|
||||||
The callback argument
|
|
||||||
.I status
|
|
||||||
indicates whether the query succeeded and, if not, how it failed. It
|
|
||||||
may have any of the following values:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The host lookup completed successfully.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTIMP
|
|
||||||
The ares library does not know how to look up addresses of type
|
|
||||||
.IR family .
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTFOUND
|
|
||||||
The address
|
|
||||||
.I addr
|
|
||||||
was not found.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EDESTRUCTION
|
|
||||||
The name service channel
|
|
||||||
.I channel
|
|
||||||
is being destroyed; the query will not be completed.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I timeouts
|
|
||||||
reports how many times a query timed out during the execution of the
|
|
||||||
given request.
|
|
||||||
.PP
|
|
||||||
On successful completion of the query, the callback argument
|
|
||||||
.I hostent
|
|
||||||
points to a
|
|
||||||
.B struct hostent
|
|
||||||
containing the name of the host returned by the query. The callback
|
|
||||||
need not and should not attempt to free the memory pointed to by
|
|
||||||
.IR hostent ;
|
|
||||||
the ares library will free it when the callback returns. If the query
|
|
||||||
did not complete successfully,
|
|
||||||
.I hostent
|
|
||||||
will be
|
|
||||||
.BR NULL .
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_process (3),
|
|
||||||
.BR ares_gethostbyname (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
#ifdef WATT32
|
|
||||||
#undef WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct addr_query {
|
|
||||||
/* Arguments passed to ares_gethostbyaddr() */
|
|
||||||
ares_channel channel;
|
|
||||||
struct ares_addr addr;
|
|
||||||
ares_host_callback callback;
|
|
||||||
void *arg;
|
|
||||||
|
|
||||||
const char *remaining_lookups;
|
|
||||||
int timeouts;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void next_lookup(struct addr_query *aquery);
|
|
||||||
static void addr_callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen);
|
|
||||||
static void end_aquery(struct addr_query *aquery, int status,
|
|
||||||
struct hostent *host);
|
|
||||||
static int file_lookup(struct ares_addr *addr, struct hostent **host);
|
|
||||||
static void ptr_rr_name(char *name, const struct ares_addr *addr);
|
|
||||||
|
|
||||||
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
|
||||||
int family, ares_host_callback callback, void *arg)
|
|
||||||
{
|
|
||||||
struct addr_query *aquery;
|
|
||||||
|
|
||||||
if (family != AF_INET && family != AF_INET6)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((family == AF_INET && addrlen != sizeof(struct in_addr)) ||
|
|
||||||
(family == AF_INET6 && addrlen != sizeof(struct in6_addr)))
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aquery = malloc(sizeof(struct addr_query));
|
|
||||||
if (!aquery)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
aquery->channel = channel;
|
|
||||||
if (family == AF_INET)
|
|
||||||
memcpy(&aquery->addr.addrV4, addr, sizeof(struct in_addr));
|
|
||||||
else
|
|
||||||
memcpy(&aquery->addr.addrV6, addr, sizeof(struct in6_addr));
|
|
||||||
aquery->addr.family = family;
|
|
||||||
aquery->callback = callback;
|
|
||||||
aquery->arg = arg;
|
|
||||||
aquery->remaining_lookups = channel->lookups;
|
|
||||||
aquery->timeouts = 0;
|
|
||||||
|
|
||||||
next_lookup(aquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void next_lookup(struct addr_query *aquery)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
char name[128];
|
|
||||||
int status;
|
|
||||||
struct hostent *host;
|
|
||||||
|
|
||||||
for (p = aquery->remaining_lookups; *p; p++)
|
|
||||||
{
|
|
||||||
switch (*p)
|
|
||||||
{
|
|
||||||
case 'b':
|
|
||||||
ptr_rr_name(name, &aquery->addr);
|
|
||||||
aquery->remaining_lookups = p + 1;
|
|
||||||
ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback,
|
|
||||||
aquery);
|
|
||||||
return;
|
|
||||||
case 'f':
|
|
||||||
status = file_lookup(&aquery->addr, &host);
|
|
||||||
|
|
||||||
/* this status check below previously checked for !ARES_ENOTFOUND,
|
|
||||||
but we should not assume that this single error code is the one
|
|
||||||
that can occur, as that is in fact no longer the case */
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
end_aquery(aquery, status, host);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end_aquery(aquery, ARES_ENOTFOUND, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void addr_callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen)
|
|
||||||
{
|
|
||||||
struct addr_query *aquery = (struct addr_query *) arg;
|
|
||||||
struct hostent *host;
|
|
||||||
|
|
||||||
aquery->timeouts += timeouts;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
if (aquery->addr.family == AF_INET)
|
|
||||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4,
|
|
||||||
sizeof(struct in_addr), AF_INET, &host);
|
|
||||||
else
|
|
||||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6,
|
|
||||||
sizeof(struct in6_addr), AF_INET6, &host);
|
|
||||||
end_aquery(aquery, status, host);
|
|
||||||
}
|
|
||||||
else if (status == ARES_EDESTRUCTION)
|
|
||||||
end_aquery(aquery, status, NULL);
|
|
||||||
else
|
|
||||||
next_lookup(aquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void end_aquery(struct addr_query *aquery, int status,
|
|
||||||
struct hostent *host)
|
|
||||||
{
|
|
||||||
aquery->callback(aquery->arg, status, aquery->timeouts, host);
|
|
||||||
if (host)
|
|
||||||
ares_free_hostent(host);
|
|
||||||
free(aquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
int status;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
char PATH_HOSTS[MAX_PATH];
|
|
||||||
if (IS_NT()) {
|
|
||||||
char tmp[MAX_PATH];
|
|
||||||
HKEY hkeyHosts;
|
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
|
||||||
== ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DWORD dwLength = MAX_PATH;
|
|
||||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
|
||||||
&dwLength);
|
|
||||||
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
|
||||||
RegCloseKey(hkeyHosts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
|
||||||
|
|
||||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
|
||||||
|
|
||||||
#elif defined(WATT32)
|
|
||||||
extern const char *_w32_GetHostsFile (void);
|
|
||||||
const char *PATH_HOSTS = _w32_GetHostsFile();
|
|
||||||
|
|
||||||
if (!PATH_HOSTS)
|
|
||||||
return ARES_ENOTFOUND;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fp = fopen(PATH_HOSTS, "r");
|
|
||||||
if (!fp)
|
|
||||||
{
|
|
||||||
error = ERRNO;
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case ENOENT:
|
|
||||||
case ESRCH:
|
|
||||||
return ARES_ENOTFOUND;
|
|
||||||
default:
|
|
||||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
|
||||||
error, strerror(error)));
|
|
||||||
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
|
||||||
PATH_HOSTS));
|
|
||||||
*host = NULL;
|
|
||||||
return ARES_EFILE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((status = ares__get_hostent(fp, addr->family, host)) == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
if (addr->family != (*host)->h_addrtype)
|
|
||||||
{
|
|
||||||
ares_free_hostent(*host);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (addr->family == AF_INET)
|
|
||||||
{
|
|
||||||
if (memcmp((*host)->h_addr, &addr->addrV4, sizeof(struct in_addr)) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (addr->family == AF_INET6)
|
|
||||||
{
|
|
||||||
if (memcmp((*host)->h_addr, &addr->addrV6, sizeof(struct in6_addr)) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ares_free_hostent(*host);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
if (status == ARES_EOF)
|
|
||||||
status = ARES_ENOTFOUND;
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
*host = NULL;
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ptr_rr_name(char *name, const struct ares_addr *addr)
|
|
||||||
{
|
|
||||||
if (addr->family == AF_INET)
|
|
||||||
{
|
|
||||||
unsigned long laddr = ntohl(addr->addrV4.s_addr);
|
|
||||||
int a1 = (int)((laddr >> 24) & 0xff);
|
|
||||||
int a2 = (int)((laddr >> 16) & 0xff);
|
|
||||||
int a3 = (int)((laddr >> 8) & 0xff);
|
|
||||||
int a4 = (int)(laddr & 0xff);
|
|
||||||
sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned char *bytes = (unsigned char *)&addr->addrV6.s6_addr;
|
|
||||||
/* There are too many arguments to do this in one line using
|
|
||||||
* minimally C89-compliant compilers */
|
|
||||||
sprintf(name,
|
|
||||||
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.",
|
|
||||||
bytes[15]&0xf, bytes[15] >> 4, bytes[14]&0xf, bytes[14] >> 4,
|
|
||||||
bytes[13]&0xf, bytes[13] >> 4, bytes[12]&0xf, bytes[12] >> 4,
|
|
||||||
bytes[11]&0xf, bytes[11] >> 4, bytes[10]&0xf, bytes[10] >> 4,
|
|
||||||
bytes[9]&0xf, bytes[9] >> 4, bytes[8]&0xf, bytes[8] >> 4);
|
|
||||||
sprintf(name+strlen(name),
|
|
||||||
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa",
|
|
||||||
bytes[7]&0xf, bytes[7] >> 4, bytes[6]&0xf, bytes[6] >> 4,
|
|
||||||
bytes[5]&0xf, bytes[5] >> 4, bytes[4]&0xf, bytes[4] >> 4,
|
|
||||||
bytes[3]&0xf, bytes[3] >> 4, bytes[2]&0xf, bytes[2] >> 4,
|
|
||||||
bytes[1]&0xf, bytes[1] >> 4, bytes[0]&0xf, bytes[0] >> 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_GETHOSTBYNAME 3 "25 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_gethostbyname \- Initiate a host query by name
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B typedef void (*ares_host_callback)(void *\fIarg\fP, int \fIstatus\fP,
|
|
||||||
.B int \fItimeouts\fP, struct hostent *\fIhostent\fP)
|
|
||||||
.PP
|
|
||||||
.B void ares_gethostbyname(ares_channel \fIchannel\fP, const char *\fIname\fP,
|
|
||||||
.B int \fIfamily\fP, ares_host_callback \fIcallback\fP, void *\fIarg\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_gethostbyname
|
|
||||||
function initiates a host query by name on the name service channel
|
|
||||||
identified by
|
|
||||||
.IR channel .
|
|
||||||
The parameter
|
|
||||||
.I name
|
|
||||||
gives the hostname as a NUL-terminated C string, and
|
|
||||||
.I family
|
|
||||||
gives the desired type of address for the resulting host entry. When the
|
|
||||||
query is complete or has failed, the ares library will invoke \fIcallback\fP.
|
|
||||||
Completion or failure of the query may happen immediately, or may happen
|
|
||||||
during a later call to \fIares_process(3)\fP, \fIares_destroy(3)\fP or
|
|
||||||
\fIares_cancel(3)\fP.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I arg
|
|
||||||
is copied from the
|
|
||||||
.B ares_gethostbyname
|
|
||||||
argument
|
|
||||||
.IR arg .
|
|
||||||
The callback argument
|
|
||||||
.I status
|
|
||||||
indicates whether the query succeeded and, if not, how it failed. It
|
|
||||||
may have any of the following values:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The host lookup completed successfully.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTIMP
|
|
||||||
The ares library does not know how to find addresses of type
|
|
||||||
.IR family .
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EBADNAME
|
|
||||||
The hostname
|
|
||||||
.B name
|
|
||||||
is composed entirely of numbers and periods, but is not a valid
|
|
||||||
representation of an Internet address.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTFOUND
|
|
||||||
The address
|
|
||||||
.I addr
|
|
||||||
was not found.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EDESTRUCTION
|
|
||||||
The name service channel
|
|
||||||
.I channel
|
|
||||||
is being destroyed; the query will not be completed.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I timeouts
|
|
||||||
reports how many times a query timed out during the execution of the
|
|
||||||
given request.
|
|
||||||
.PP
|
|
||||||
On successful completion of the query, the callback argument
|
|
||||||
.I hostent
|
|
||||||
points to a
|
|
||||||
.B struct hostent
|
|
||||||
containing the name of the host returned by the query. The callback
|
|
||||||
need not and should not attempt to free the memory pointed to by
|
|
||||||
.IR hostent ;
|
|
||||||
the ares library will free it when the callback returns. If the query
|
|
||||||
did not complete successfully,
|
|
||||||
.I hostent
|
|
||||||
will be
|
|
||||||
.BR NULL .
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_process (3),
|
|
||||||
.BR ares_gethostbyaddr (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,507 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "bitncmp.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
#ifdef WATT32
|
|
||||||
#undef WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct host_query {
|
|
||||||
/* Arguments passed to ares_gethostbyname() */
|
|
||||||
ares_channel channel;
|
|
||||||
char *name;
|
|
||||||
ares_host_callback callback;
|
|
||||||
void *arg;
|
|
||||||
int sent_family; /* this family is what was is being used */
|
|
||||||
int want_family; /* this family is what is asked for in the API */
|
|
||||||
const char *remaining_lookups;
|
|
||||||
int timeouts;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void next_lookup(struct host_query *hquery, int status_code);
|
|
||||||
static void host_callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen);
|
|
||||||
static void end_hquery(struct host_query *hquery, int status,
|
|
||||||
struct hostent *host);
|
|
||||||
static int fake_hostent(const char *name, int family,
|
|
||||||
ares_host_callback callback, void *arg);
|
|
||||||
static int file_lookup(const char *name, int family, struct hostent **host);
|
|
||||||
static void sort_addresses(struct hostent *host,
|
|
||||||
const struct apattern *sortlist, int nsort);
|
|
||||||
static void sort6_addresses(struct hostent *host,
|
|
||||||
const struct apattern *sortlist, int nsort);
|
|
||||||
static int get_address_index(const struct in_addr *addr,
|
|
||||||
const struct apattern *sortlist, int nsort);
|
|
||||||
static int get6_address_index(const struct in6_addr *addr,
|
|
||||||
const struct apattern *sortlist, int nsort);
|
|
||||||
|
|
||||||
void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
|
||||||
ares_host_callback callback, void *arg)
|
|
||||||
{
|
|
||||||
struct host_query *hquery;
|
|
||||||
|
|
||||||
/* Right now we only know how to look up Internet addresses - and unspec
|
|
||||||
means try both basically. */
|
|
||||||
switch (family) {
|
|
||||||
case AF_INET:
|
|
||||||
case AF_INET6:
|
|
||||||
case AF_UNSPEC:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fake_hostent(name, family, callback, arg))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Allocate and fill in the host query structure. */
|
|
||||||
hquery = malloc(sizeof(struct host_query));
|
|
||||||
if (!hquery)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hquery->channel = channel;
|
|
||||||
hquery->name = strdup(name);
|
|
||||||
hquery->want_family = family;
|
|
||||||
hquery->sent_family = -1; /* nothing is sent yet */
|
|
||||||
if (!hquery->name) {
|
|
||||||
free(hquery);
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hquery->callback = callback;
|
|
||||||
hquery->arg = arg;
|
|
||||||
hquery->remaining_lookups = channel->lookups;
|
|
||||||
hquery->timeouts = 0;
|
|
||||||
|
|
||||||
/* Start performing lookups according to channel->lookups. */
|
|
||||||
next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void next_lookup(struct host_query *hquery, int status_code)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
struct hostent *host;
|
|
||||||
int status = status_code;
|
|
||||||
|
|
||||||
for (p = hquery->remaining_lookups; *p; p++)
|
|
||||||
{
|
|
||||||
switch (*p)
|
|
||||||
{
|
|
||||||
case 'b':
|
|
||||||
/* DNS lookup */
|
|
||||||
hquery->remaining_lookups = p + 1;
|
|
||||||
if ((hquery->want_family == AF_INET6) ||
|
|
||||||
(hquery->want_family == AF_UNSPEC)) {
|
|
||||||
/* if inet6 or unspec, start out with AAAA */
|
|
||||||
hquery->sent_family = AF_INET6;
|
|
||||||
ares_search(hquery->channel, hquery->name, C_IN, T_AAAA,
|
|
||||||
host_callback, hquery);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
hquery->sent_family = AF_INET;
|
|
||||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
|
||||||
hquery);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
/* Host file lookup */
|
|
||||||
status = file_lookup(hquery->name, hquery->want_family, &host);
|
|
||||||
|
|
||||||
/* this status check below previously checked for !ARES_ENOTFOUND,
|
|
||||||
but we should not assume that this single error code is the one
|
|
||||||
that can occur, as that is in fact no longer the case */
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
end_hquery(hquery, status, host);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
status = status_code; /* Use original status code */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end_hquery(hquery, status, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void host_callback(void *arg, int status, int timeouts,
|
|
||||||
unsigned char *abuf, int alen)
|
|
||||||
{
|
|
||||||
struct host_query *hquery = (struct host_query *) arg;
|
|
||||||
ares_channel channel = hquery->channel;
|
|
||||||
struct hostent *host = NULL;
|
|
||||||
|
|
||||||
hquery->timeouts += timeouts;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
if (hquery->sent_family == AF_INET)
|
|
||||||
{
|
|
||||||
status = ares_parse_a_reply(abuf, alen, &host, NULL, NULL);
|
|
||||||
if (host && channel->nsort)
|
|
||||||
sort_addresses(host, channel->sortlist, channel->nsort);
|
|
||||||
}
|
|
||||||
else if (hquery->sent_family == AF_INET6)
|
|
||||||
{
|
|
||||||
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
|
||||||
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
|
|
||||||
/* The query returned something but either there were no AAAA records (e.g. just CNAME)
|
|
||||||
or the response was malformed. Try looking up A instead.
|
|
||||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
|
||||||
hquery->sent_family = AF_INET;
|
|
||||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
|
||||||
host_callback, hquery);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (host && channel->nsort)
|
|
||||||
sort6_addresses(host, channel->sortlist, channel->nsort);
|
|
||||||
}
|
|
||||||
end_hquery(hquery, status, host);
|
|
||||||
}
|
|
||||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
|
|
||||||
{
|
|
||||||
/* The AAAA query yielded no useful result. Now look up an A instead.
|
|
||||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
|
||||||
hquery->sent_family = AF_INET;
|
|
||||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
|
||||||
hquery);
|
|
||||||
}
|
|
||||||
else if (status == ARES_EDESTRUCTION)
|
|
||||||
end_hquery(hquery, status, NULL);
|
|
||||||
else
|
|
||||||
next_lookup(hquery, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void end_hquery(struct host_query *hquery, int status,
|
|
||||||
struct hostent *host)
|
|
||||||
{
|
|
||||||
hquery->callback(hquery->arg, status, hquery->timeouts, host);
|
|
||||||
if (host)
|
|
||||||
ares_free_hostent(host);
|
|
||||||
free(hquery->name);
|
|
||||||
free(hquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the name looks like an IP address, fake up a host entry, end the
|
|
||||||
* query immediately, and return true. Otherwise return false.
|
|
||||||
*/
|
|
||||||
static int fake_hostent(const char *name, int family, ares_host_callback callback,
|
|
||||||
void *arg)
|
|
||||||
{
|
|
||||||
struct hostent hostent;
|
|
||||||
char *aliases[1] = { NULL };
|
|
||||||
char *addrs[2];
|
|
||||||
int result = 0;
|
|
||||||
struct in_addr in;
|
|
||||||
struct in6_addr in6;
|
|
||||||
|
|
||||||
if (family == AF_INET)
|
|
||||||
{
|
|
||||||
/* It only looks like an IP address if it's all numbers and dots. */
|
|
||||||
int numdots = 0;
|
|
||||||
const char *p;
|
|
||||||
for (p = name; *p; p++)
|
|
||||||
{
|
|
||||||
if (!ISDIGIT(*p) && *p != '.') {
|
|
||||||
return 0;
|
|
||||||
} else if (*p == '.') {
|
|
||||||
numdots++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if we don't have 3 dots, it is illegal
|
|
||||||
* (although inet_addr doesn't think so).
|
|
||||||
*/
|
|
||||||
if (numdots != 3)
|
|
||||||
result = 0;
|
|
||||||
else
|
|
||||||
result = ((in.s_addr = inet_addr(name)) == INADDR_NONE ? 0 : 1);
|
|
||||||
}
|
|
||||||
else if (family == AF_INET6)
|
|
||||||
result = (ares_inet_pton(AF_INET6, name, &in6) < 1 ? 0 : 1);
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (family == AF_INET)
|
|
||||||
{
|
|
||||||
hostent.h_length = sizeof(struct in_addr);
|
|
||||||
addrs[0] = (char *)∈
|
|
||||||
}
|
|
||||||
else if (family == AF_INET6)
|
|
||||||
{
|
|
||||||
hostent.h_length = sizeof(struct in6_addr);
|
|
||||||
addrs[0] = (char *)&in6;
|
|
||||||
}
|
|
||||||
/* Duplicate the name, to avoid a constness violation. */
|
|
||||||
hostent.h_name = strdup(name);
|
|
||||||
if (!hostent.h_name)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill in the rest of the host structure and terminate the query. */
|
|
||||||
addrs[1] = NULL;
|
|
||||||
hostent.h_aliases = aliases;
|
|
||||||
hostent.h_addrtype = family;
|
|
||||||
hostent.h_addr_list = addrs;
|
|
||||||
callback(arg, ARES_SUCCESS, 0, &hostent);
|
|
||||||
|
|
||||||
free((char *)(hostent.h_name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is an API method */
|
|
||||||
int ares_gethostbyname_file(ares_channel channel, const char *name,
|
|
||||||
int family, struct hostent **host)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
/* We only take the channel to ensure that ares_init() been called. */
|
|
||||||
if(channel == NULL)
|
|
||||||
{
|
|
||||||
/* Anything will do, really. This seems fine, and is consistent with
|
|
||||||
other error cases. */
|
|
||||||
*host = NULL;
|
|
||||||
return ARES_ENOTFOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just chain to the internal implementation we use here; it's exactly
|
|
||||||
* what we want.
|
|
||||||
*/
|
|
||||||
result = file_lookup(name, family, host);
|
|
||||||
if(result != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* We guarantee a NULL hostent on failure. */
|
|
||||||
*host = NULL;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int file_lookup(const char *name, int family, struct hostent **host)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
char **alias;
|
|
||||||
int status;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
char PATH_HOSTS[MAX_PATH];
|
|
||||||
if (IS_NT()) {
|
|
||||||
char tmp[MAX_PATH];
|
|
||||||
HKEY hkeyHosts;
|
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
|
||||||
== ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DWORD dwLength = MAX_PATH;
|
|
||||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
|
||||||
&dwLength);
|
|
||||||
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
|
||||||
RegCloseKey(hkeyHosts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
|
||||||
|
|
||||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
|
||||||
|
|
||||||
#elif defined(WATT32)
|
|
||||||
extern const char *_w32_GetHostsFile (void);
|
|
||||||
const char *PATH_HOSTS = _w32_GetHostsFile();
|
|
||||||
|
|
||||||
if (!PATH_HOSTS)
|
|
||||||
return ARES_ENOTFOUND;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fp = fopen(PATH_HOSTS, "r");
|
|
||||||
if (!fp)
|
|
||||||
{
|
|
||||||
error = ERRNO;
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case ENOENT:
|
|
||||||
case ESRCH:
|
|
||||||
return ARES_ENOTFOUND;
|
|
||||||
default:
|
|
||||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
|
||||||
error, strerror(error)));
|
|
||||||
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
|
||||||
PATH_HOSTS));
|
|
||||||
*host = NULL;
|
|
||||||
return ARES_EFILE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
if (strcasecmp((*host)->h_name, name) == 0)
|
|
||||||
break;
|
|
||||||
for (alias = (*host)->h_aliases; *alias; alias++)
|
|
||||||
{
|
|
||||||
if (strcasecmp(*alias, name) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*alias)
|
|
||||||
break;
|
|
||||||
ares_free_hostent(*host);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
if (status == ARES_EOF)
|
|
||||||
status = ARES_ENOTFOUND;
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
*host = NULL;
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sort_addresses(struct hostent *host, const struct apattern *sortlist,
|
|
||||||
int nsort)
|
|
||||||
{
|
|
||||||
struct in_addr a1, a2;
|
|
||||||
int i1, i2, ind1, ind2;
|
|
||||||
|
|
||||||
/* This is a simple insertion sort, not optimized at all. i1 walks
|
|
||||||
* through the address list, with the loop invariant that everything
|
|
||||||
* to the left of i1 is sorted. In the loop body, the value at i1 is moved
|
|
||||||
* back through the list (via i2) until it is in sorted order.
|
|
||||||
*/
|
|
||||||
for (i1 = 0; host->h_addr_list[i1]; i1++)
|
|
||||||
{
|
|
||||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct in_addr));
|
|
||||||
ind1 = get_address_index(&a1, sortlist, nsort);
|
|
||||||
for (i2 = i1 - 1; i2 >= 0; i2--)
|
|
||||||
{
|
|
||||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct in_addr));
|
|
||||||
ind2 = get_address_index(&a2, sortlist, nsort);
|
|
||||||
if (ind2 <= ind1)
|
|
||||||
break;
|
|
||||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in_addr));
|
|
||||||
}
|
|
||||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in_addr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the first entry in sortlist which matches addr. Return nsort
|
|
||||||
* if none of them match.
|
|
||||||
*/
|
|
||||||
static int get_address_index(const struct in_addr *addr,
|
|
||||||
const struct apattern *sortlist,
|
|
||||||
int nsort)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nsort; i++)
|
|
||||||
{
|
|
||||||
if (sortlist[i].family != AF_INET)
|
|
||||||
continue;
|
|
||||||
if (sortlist[i].type == PATTERN_MASK)
|
|
||||||
{
|
|
||||||
if ((addr->s_addr & sortlist[i].mask.addr4.s_addr)
|
|
||||||
== sortlist[i].addrV4.s_addr)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
|
|
||||||
sortlist[i].mask.bits))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sort6_addresses(struct hostent *host, const struct apattern *sortlist,
|
|
||||||
int nsort)
|
|
||||||
{
|
|
||||||
struct in6_addr a1, a2;
|
|
||||||
int i1, i2, ind1, ind2;
|
|
||||||
|
|
||||||
/* This is a simple insertion sort, not optimized at all. i1 walks
|
|
||||||
* through the address list, with the loop invariant that everything
|
|
||||||
* to the left of i1 is sorted. In the loop body, the value at i1 is moved
|
|
||||||
* back through the list (via i2) until it is in sorted order.
|
|
||||||
*/
|
|
||||||
for (i1 = 0; host->h_addr_list[i1]; i1++)
|
|
||||||
{
|
|
||||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct in6_addr));
|
|
||||||
ind1 = get6_address_index(&a1, sortlist, nsort);
|
|
||||||
for (i2 = i1 - 1; i2 >= 0; i2--)
|
|
||||||
{
|
|
||||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct in6_addr));
|
|
||||||
ind2 = get6_address_index(&a2, sortlist, nsort);
|
|
||||||
if (ind2 <= ind1)
|
|
||||||
break;
|
|
||||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in6_addr));
|
|
||||||
}
|
|
||||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in6_addr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the first entry in sortlist which matches addr. Return nsort
|
|
||||||
* if none of them match.
|
|
||||||
*/
|
|
||||||
static int get6_address_index(const struct in6_addr *addr,
|
|
||||||
const struct apattern *sortlist,
|
|
||||||
int nsort)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nsort; i++)
|
|
||||||
{
|
|
||||||
if (sortlist[i].family != AF_INET6)
|
|
||||||
continue;
|
|
||||||
if (!ares_bitncmp(&addr->s6_addr, &sortlist[i].addrV6.s6_addr, sortlist[i].mask.bits))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_GETHOSTBYNAME 3 "25 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_gethostbyname_file \- Lookup a name in the system's hosts file
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_gethostbyname_file(ares_channel \fIchannel\fP, const char *\fIname\fP,
|
|
||||||
.B int \fIfamily\fP, struct hostent **host)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_gethostbyname_file
|
|
||||||
function performs a host lookup by name against the system's hosts file (or equivalent local hostname database).
|
|
||||||
The
|
|
||||||
.IR channel
|
|
||||||
parameter is required, but no asynchronous queries are performed. Instead, the
|
|
||||||
lookup is done via the same mechanism used to perform 'f' lookups
|
|
||||||
(see the
|
|
||||||
.I lookups
|
|
||||||
options field in \fIares_init_options(3)\fP).
|
|
||||||
The parameter
|
|
||||||
.I name
|
|
||||||
gives the hostname as a NUL-terminated C string, and
|
|
||||||
.I family
|
|
||||||
gives the desired type of address for the resulting host entry.
|
|
||||||
.PP
|
|
||||||
The return value indicates whether the query succeeded and, if not, how it
|
|
||||||
failed. It may have any of the following values:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The host lookup completed successfully and
|
|
||||||
.I host
|
|
||||||
now points to the result (and must be freed with \fIares_free_hostent(3)\fP).
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTFOUND
|
|
||||||
The hostname
|
|
||||||
.I name
|
|
||||||
was not found.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EFILE
|
|
||||||
There was a file I/O error while performing the lookup.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.PP
|
|
||||||
On successful completion of the query, the pointer pointed to by
|
|
||||||
.I host
|
|
||||||
points to a
|
|
||||||
.B struct hostent
|
|
||||||
containing the address of the host returned by the lookup. The user must
|
|
||||||
free the memory pointed to by
|
|
||||||
.IR host
|
|
||||||
when finished with it by calling \fIares_free_hostent(3)\fP. If the lookup did
|
|
||||||
not complete successfully,
|
|
||||||
.I host
|
|
||||||
will be
|
|
||||||
.BR NULL .
|
|
||||||
.SH AVAILABILITY
|
|
||||||
Added in c-ares 1.5.4
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_gethostbyname (3),
|
|
||||||
.BR ares_free_hostent (3),
|
|
||||||
.BR ares_init_options (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Brad Spencer
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 2005 by Dominick Meglio.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_GETNAMEINFO 3 "16 May 2005"
|
|
||||||
.SH NAME
|
|
||||||
ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP,
|
|
||||||
.B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
|
|
||||||
.PP
|
|
||||||
.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
|
|
||||||
.B socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
|
|
||||||
.B void *\fIarg\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_getnameinfo
|
|
||||||
function is defined for protocol-independent address translation. The function
|
|
||||||
is a combination of \fIares_gethostbyaddr(3)\fP and \fIgetservbyport(3)\fP. The function will
|
|
||||||
translate the address either by executing a host query on the name service channel
|
|
||||||
identified by
|
|
||||||
.IR channel
|
|
||||||
or it will attempt to resolve it locally if possible.
|
|
||||||
The parameters
|
|
||||||
.I sa
|
|
||||||
and
|
|
||||||
.I len
|
|
||||||
give the address as a sockaddr structure, and
|
|
||||||
.I flags
|
|
||||||
gives the options that the function will use. Valid flags are listed below:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_NOFQDN
|
|
||||||
Only the nodename portion of the FQDN is returned for local hosts.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_NUMERICHOST
|
|
||||||
The numeric form of the hostname is returned rather than the name.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_NAMEREQD
|
|
||||||
An error is returned if the hostname cannot be found in the DNS.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_NUMERICSERV
|
|
||||||
The numeric form of the service is returned rather than the name.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_TCP
|
|
||||||
The service name is to be looked up for the TCP protocol.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_UDP
|
|
||||||
The service name is to be looked up for the UDP protocol.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_SCTP
|
|
||||||
The service name is to be looked up for the SCTP protocol.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_DCCP
|
|
||||||
The service name is to be looked up for the DCCP protocol.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_NUMERICSCOPE
|
|
||||||
The numeric form of the scope ID is returned rather than the name.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_LOOKUPHOST
|
|
||||||
A hostname lookup is being requested.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_NI_LOOKUPSERVICE
|
|
||||||
A service name lookup is being requested.
|
|
||||||
.PP
|
|
||||||
When the query
|
|
||||||
is complete or has
|
|
||||||
failed, the ares library will invoke \fIcallback\fP. Completion or failure of
|
|
||||||
the query may happen immediately, or may happen during a later call to
|
|
||||||
\fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I arg
|
|
||||||
is copied from the
|
|
||||||
.B ares_getnameinfo
|
|
||||||
argument
|
|
||||||
.IR arg .
|
|
||||||
The callback argument
|
|
||||||
.I status
|
|
||||||
indicates whether the query succeeded and, if not, how it failed. It
|
|
||||||
may have any of the following values:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The host lookup completed successfully.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTIMP
|
|
||||||
The ares library does not know how to look up addresses of type
|
|
||||||
.IR family .
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTFOUND
|
|
||||||
The address
|
|
||||||
.I addr
|
|
||||||
was not found.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EDESTRUCTION
|
|
||||||
The name service channel
|
|
||||||
.I channel
|
|
||||||
is being destroyed; the query will not be completed.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EBADFLAGS
|
|
||||||
The
|
|
||||||
.I flags
|
|
||||||
parameter contains an illegal value.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I timeouts
|
|
||||||
reports how many times a query timed out during the execution of the
|
|
||||||
given request.
|
|
||||||
.PP
|
|
||||||
On successful completion of the query, the callback argument
|
|
||||||
.I node
|
|
||||||
contains a string representing the hostname (assuming
|
|
||||||
.B ARES_NI_LOOKUPHOST
|
|
||||||
was specified). Additionally,
|
|
||||||
.I service
|
|
||||||
contains a string representing the service name (assuming
|
|
||||||
.B ARES_NI_LOOKUPSERVICE
|
|
||||||
was specified).
|
|
||||||
If the query did not complete successfully, or one of the values
|
|
||||||
was not requested,
|
|
||||||
.I node
|
|
||||||
or
|
|
||||||
.I service
|
|
||||||
will be
|
|
||||||
.BR NULL .
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_process (3),
|
|
||||||
.BR ares_getaddrinfo (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Dominick Meglio
|
|
||||||
.br
|
|
||||||
Copyright 2005 by Dominick Meglio.
|
|
||||||
@@ -1,413 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 2005 by Dominick Meglio
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_GETSERVBYPORT_R
|
|
||||||
# if !defined(GETSERVBYPORT_R_ARGS) || \
|
|
||||||
(GETSERVBYPORT_R_ARGS < 4) || (GETSERVBYPORT_R_ARGS > 6)
|
|
||||||
# error "you MUST specifiy a valid number of arguments for getservbyport_r"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NET_IF_H
|
|
||||||
#include <net/if.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_ipv6.h"
|
|
||||||
#include "inet_ntop.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
#ifdef WATT32
|
|
||||||
#undef WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct nameinfo_query {
|
|
||||||
ares_nameinfo_callback callback;
|
|
||||||
void *arg;
|
|
||||||
union {
|
|
||||||
struct sockaddr_in addr4;
|
|
||||||
struct sockaddr_in6 addr6;
|
|
||||||
} addr;
|
|
||||||
int family;
|
|
||||||
int flags;
|
|
||||||
int timeouts;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
|
||||||
#define IPBUFSIZ 40+IF_NAMESIZE
|
|
||||||
#else
|
|
||||||
#define IPBUFSIZ 40
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host);
|
|
||||||
static char *lookup_service(unsigned short port, int flags,
|
|
||||||
char *buf, size_t buflen);
|
|
||||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
|
||||||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
|
|
||||||
char *buf, size_t buflen);
|
|
||||||
#endif
|
|
||||||
static char *ares_striendstr(const char *s1, const char *s2);
|
|
||||||
|
|
||||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, socklen_t salen,
|
|
||||||
int flags, ares_nameinfo_callback callback, void *arg)
|
|
||||||
{
|
|
||||||
struct sockaddr_in *addr = NULL;
|
|
||||||
struct sockaddr_in6 *addr6 = NULL;
|
|
||||||
struct nameinfo_query *niquery;
|
|
||||||
|
|
||||||
/* Verify the buffer size */
|
|
||||||
if (salen == sizeof(struct sockaddr_in))
|
|
||||||
addr = (struct sockaddr_in *)sa;
|
|
||||||
else if (salen == sizeof(struct sockaddr_in6))
|
|
||||||
addr6 = (struct sockaddr_in6 *)sa;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOTIMP, 0, NULL, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If neither, assume they want a host */
|
|
||||||
if (!(flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST))
|
|
||||||
flags |= ARES_NI_LOOKUPHOST;
|
|
||||||
|
|
||||||
/* All they want is a service, no need for DNS */
|
|
||||||
if ((flags & ARES_NI_LOOKUPSERVICE) && !(flags & ARES_NI_LOOKUPHOST))
|
|
||||||
{
|
|
||||||
char buf[33], *service;
|
|
||||||
unsigned int port = 0;
|
|
||||||
|
|
||||||
if (salen == sizeof(struct sockaddr_in))
|
|
||||||
port = addr->sin_port;
|
|
||||||
else
|
|
||||||
port = addr6->sin6_port;
|
|
||||||
service = lookup_service((unsigned short)(port & 0xffff),
|
|
||||||
flags, buf, sizeof(buf));
|
|
||||||
callback(arg, ARES_SUCCESS, 0, NULL, service);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* They want a host lookup */
|
|
||||||
if ((flags & ARES_NI_LOOKUPHOST))
|
|
||||||
{
|
|
||||||
/* A numeric host can be handled without DNS */
|
|
||||||
if ((flags & ARES_NI_NUMERICHOST))
|
|
||||||
{
|
|
||||||
unsigned int port = 0;
|
|
||||||
char ipbuf[IPBUFSIZ];
|
|
||||||
char srvbuf[33];
|
|
||||||
char *service = NULL;
|
|
||||||
ipbuf[0] = 0;
|
|
||||||
|
|
||||||
/* Specifying not to lookup a host, but then saying a host
|
|
||||||
* is required has to be illegal.
|
|
||||||
*/
|
|
||||||
if (flags & ARES_NI_NAMEREQD)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_EBADFLAGS, 0, NULL, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (salen == sizeof(struct sockaddr_in6))
|
|
||||||
{
|
|
||||||
ares_inet_ntop(AF_INET6, &addr6->sin6_addr, ipbuf, IPBUFSIZ);
|
|
||||||
port = addr6->sin6_port;
|
|
||||||
/* If the system supports scope IDs, use it */
|
|
||||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
|
||||||
append_scopeid(addr6, flags, ipbuf, sizeof(ipbuf));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ares_inet_ntop(AF_INET, &addr->sin_addr, ipbuf, IPBUFSIZ);
|
|
||||||
port = addr->sin_port;
|
|
||||||
}
|
|
||||||
/* They also want a service */
|
|
||||||
if (flags & ARES_NI_LOOKUPSERVICE)
|
|
||||||
service = lookup_service((unsigned short)(port & 0xffff),
|
|
||||||
flags, srvbuf, sizeof(srvbuf));
|
|
||||||
callback(arg, ARES_SUCCESS, 0, ipbuf, service);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* This is where a DNS lookup becomes necessary */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
niquery = malloc(sizeof(struct nameinfo_query));
|
|
||||||
if (!niquery)
|
|
||||||
{
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
niquery->callback = callback;
|
|
||||||
niquery->arg = arg;
|
|
||||||
niquery->flags = flags;
|
|
||||||
niquery->timeouts = 0;
|
|
||||||
if (sa->sa_family == AF_INET)
|
|
||||||
{
|
|
||||||
niquery->family = AF_INET;
|
|
||||||
memcpy(&niquery->addr.addr4, addr, sizeof(addr));
|
|
||||||
ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), AF_INET,
|
|
||||||
nameinfo_callback, niquery);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
niquery->family = AF_INET6;
|
|
||||||
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
|
|
||||||
ares_gethostbyaddr(channel, &addr6->sin6_addr, sizeof(struct in6_addr), AF_INET6,
|
|
||||||
nameinfo_callback, niquery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host)
|
|
||||||
{
|
|
||||||
struct nameinfo_query *niquery = (struct nameinfo_query *) arg;
|
|
||||||
char srvbuf[33];
|
|
||||||
char *service = NULL;
|
|
||||||
|
|
||||||
niquery->timeouts += timeouts;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* They want a service too */
|
|
||||||
if (niquery->flags & ARES_NI_LOOKUPSERVICE)
|
|
||||||
{
|
|
||||||
if (niquery->family == AF_INET)
|
|
||||||
service = lookup_service(niquery->addr.addr4.sin_port,
|
|
||||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
|
||||||
else
|
|
||||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
|
||||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
|
||||||
}
|
|
||||||
/* NOFQDN means we have to strip off the domain name portion.
|
|
||||||
We do this by determining our own domain name, then searching the string
|
|
||||||
for this domain name and removing it.
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_GETHOSTNAME
|
|
||||||
if (niquery->flags & ARES_NI_NOFQDN)
|
|
||||||
{
|
|
||||||
char buf[255];
|
|
||||||
char *domain;
|
|
||||||
gethostname(buf, 255);
|
|
||||||
if ((domain = strchr(buf, '.')))
|
|
||||||
{
|
|
||||||
char *end = ares_striendstr(host->h_name, domain);
|
|
||||||
if (end)
|
|
||||||
*end = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, (char *)(host->h_name),
|
|
||||||
service);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* We couldn't find the host, but it's OK, we can use the IP */
|
|
||||||
else if (status == ARES_ENOTFOUND && !(niquery->flags & ARES_NI_NAMEREQD))
|
|
||||||
{
|
|
||||||
char ipbuf[IPBUFSIZ];
|
|
||||||
if (niquery->family == AF_INET)
|
|
||||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf, IPBUFSIZ);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf, IPBUFSIZ);
|
|
||||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
|
||||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf, sizeof(ipbuf));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* They want a service too */
|
|
||||||
if (niquery->flags & ARES_NI_LOOKUPSERVICE)
|
|
||||||
{
|
|
||||||
if (niquery->family == AF_INET)
|
|
||||||
service = lookup_service(niquery->addr.addr4.sin_port,
|
|
||||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
|
||||||
else
|
|
||||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
|
||||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
|
||||||
}
|
|
||||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf, service);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
|
|
||||||
free(niquery);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *lookup_service(unsigned short port, int flags,
|
|
||||||
char *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
const char *proto;
|
|
||||||
struct servent *sep;
|
|
||||||
#ifdef HAVE_GETSERVBYPORT_R
|
|
||||||
struct servent se;
|
|
||||||
#endif
|
|
||||||
char tmpbuf[4096];
|
|
||||||
|
|
||||||
if (port)
|
|
||||||
{
|
|
||||||
if (flags & ARES_NI_NUMERICSERV)
|
|
||||||
sep = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (flags & ARES_NI_UDP)
|
|
||||||
proto = "udp";
|
|
||||||
else if (flags & ARES_NI_SCTP)
|
|
||||||
proto = "sctp";
|
|
||||||
else if (flags & ARES_NI_DCCP)
|
|
||||||
proto = "dccp";
|
|
||||||
else
|
|
||||||
proto = "tcp";
|
|
||||||
#ifdef HAVE_GETSERVBYPORT_R
|
|
||||||
sep = &se;
|
|
||||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
|
||||||
#if GETSERVBYPORT_R_ARGS == 6
|
|
||||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf), &sep) != 0)
|
|
||||||
sep = NULL;
|
|
||||||
#elif GETSERVBYPORT_R_ARGS == 5
|
|
||||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf));
|
|
||||||
#elif GETSERVBYPORT_R_ARGS == 4
|
|
||||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
|
|
||||||
sep = NULL;
|
|
||||||
#else
|
|
||||||
/* Lets just hope the OS uses TLS! */
|
|
||||||
sep = getservbyport(port, proto);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
/* Lets just hope the OS uses TLS! */
|
|
||||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
|
||||||
sep = getservbyport(port, (char*)proto);
|
|
||||||
#else
|
|
||||||
sep = getservbyport(port, proto);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (sep && sep->s_name)
|
|
||||||
/* get service name */
|
|
||||||
strcpy(tmpbuf, sep->s_name);
|
|
||||||
else
|
|
||||||
/* get port as a string */
|
|
||||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
|
||||||
if (strlen(tmpbuf) < buflen)
|
|
||||||
/* return it if buffer big enough */
|
|
||||||
strcpy(buf, tmpbuf);
|
|
||||||
else
|
|
||||||
/* avoid reusing previous one */
|
|
||||||
buf[0] = '\0';
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
buf[0] = '\0';
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
|
||||||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
|
||||||
char *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_IF_INDEXTONAME
|
|
||||||
int is_ll, is_mcll;
|
|
||||||
#endif
|
|
||||||
char fmt_u[] = "%u";
|
|
||||||
char fmt_lu[] = "%lu";
|
|
||||||
char tmpbuf[IF_NAMESIZE + 2];
|
|
||||||
size_t bufl;
|
|
||||||
char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?fmt_lu:fmt_u;
|
|
||||||
|
|
||||||
tmpbuf[0] = '%';
|
|
||||||
|
|
||||||
#ifdef HAVE_IF_INDEXTONAME
|
|
||||||
is_ll = IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr);
|
|
||||||
is_mcll = IN6_IS_ADDR_MC_LINKLOCAL(&addr6->sin6_addr);
|
|
||||||
if ((flags & ARES_NI_NUMERICSCOPE) ||
|
|
||||||
(!is_ll && !is_mcll))
|
|
||||||
{
|
|
||||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL)
|
|
||||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);
|
|
||||||
(void) flags;
|
|
||||||
#endif
|
|
||||||
tmpbuf[IF_NAMESIZE + 1] = '\0';
|
|
||||||
bufl = strlen(buf);
|
|
||||||
|
|
||||||
if(bufl + strlen(tmpbuf) < buflen)
|
|
||||||
/* only append the scopeid string if it fits in the target buffer */
|
|
||||||
strcpy(&buf[bufl], tmpbuf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Determines if s1 ends with the string in s2 (case-insensitive) */
|
|
||||||
static char *ares_striendstr(const char *s1, const char *s2)
|
|
||||||
{
|
|
||||||
const char *c1, *c2, *c1_begin;
|
|
||||||
int lo1, lo2;
|
|
||||||
size_t s1_len = strlen(s1), s2_len = strlen(s2);
|
|
||||||
|
|
||||||
/* If the substr is longer than the full str, it can't match */
|
|
||||||
if (s2_len > s1_len)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Jump to the end of s1 minus the length of s2 */
|
|
||||||
c1_begin = s1+s1_len-s2_len;
|
|
||||||
c1 = (const char *)c1_begin;
|
|
||||||
c2 = s2;
|
|
||||||
while (c2 < s2+s2_len)
|
|
||||||
{
|
|
||||||
lo1 = tolower(*c1);
|
|
||||||
lo2 = tolower(*c2);
|
|
||||||
if (lo1 != lo2)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c1++;
|
|
||||||
c2++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (c2 == c1 && c2 == NULL)
|
|
||||||
return (char *)c1_begin;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
/*
|
|
||||||
* Original file name getopt.c Initial import into the c-ares source tree
|
|
||||||
* on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with
|
|
||||||
* the modified BSD license, BSD license without the advertising clause.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* getopt.c --
|
|
||||||
*
|
|
||||||
* Standard UNIX getopt function. Code is from BSD.
|
|
||||||
*
|
|
||||||
* Copyright (c) 1987-2001 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* A. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* B. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* C. Neither the names of the copyright holders nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from this
|
|
||||||
* software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
||||||
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* #if !defined(lint)
|
|
||||||
* static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
|
|
||||||
* #endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ares_getopt.h"
|
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
|
||||||
optind = 1, /* index into parent argv vector */
|
|
||||||
optopt, /* character checked for validity */
|
|
||||||
optreset; /* reset getopt */
|
|
||||||
char *optarg; /* argument associated with option */
|
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
|
||||||
#define BADARG (int)':'
|
|
||||||
#define EMSG (char *)""
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ares_getopt --
|
|
||||||
* Parse argc/argv argument vector.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
ares_getopt(int nargc, char * const nargv[], const char *ostr)
|
|
||||||
{
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
|
||||||
char *oli; /* option letter list index */
|
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
|
||||||
optreset = 0;
|
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
|
||||||
place = EMSG;
|
|
||||||
return (EOF);
|
|
||||||
}
|
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
|
||||||
++optind;
|
|
||||||
place = EMSG;
|
|
||||||
return (EOF);
|
|
||||||
}
|
|
||||||
} /* option letter okay? */
|
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
|
||||||
(oli = strchr(ostr, optopt)) == NULL) {
|
|
||||||
/*
|
|
||||||
* if the user didn't specify '-' as an option,
|
|
||||||
* assume it means EOF.
|
|
||||||
*/
|
|
||||||
if (optopt == (int)'-')
|
|
||||||
return (EOF);
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
if (opterr && *ostr != ':')
|
|
||||||
(void)fprintf(stderr,
|
|
||||||
"%s: illegal option -- %c\n", __FILE__, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
if (*++oli != ':') { /* don't need argument */
|
|
||||||
optarg = NULL;
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
else { /* need an argument */
|
|
||||||
if (*place) /* no white space */
|
|
||||||
optarg = place;
|
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
|
||||||
place = EMSG;
|
|
||||||
if (*ostr == ':')
|
|
||||||
return (BADARG);
|
|
||||||
if (opterr)
|
|
||||||
(void)fprintf(stderr,
|
|
||||||
"%s: option requires an argument -- %c\n",
|
|
||||||
__FILE__, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
else /* white space */
|
|
||||||
optarg = nargv[optind];
|
|
||||||
place = EMSG;
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
return (optopt); /* dump back option letter */
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#ifndef ARES_GETOPT_H
|
|
||||||
#define ARES_GETOPT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1987-2001 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* A. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* B. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* C. Neither the names of the copyright holders nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from this
|
|
||||||
* software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
||||||
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
int ares_getopt(int nargc, char * const nargv[], const char *ostr);
|
|
||||||
|
|
||||||
#if defined(WATT32)
|
|
||||||
#undef optarg
|
|
||||||
#undef optind
|
|
||||||
#undef opterr
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern char *optarg;
|
|
||||||
extern int optind;
|
|
||||||
extern int opterr;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* ARES_GETOPT_H */
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by Daniel Stenberg
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_GETSOCK 3 "22 December 2005"
|
|
||||||
.SH NAME
|
|
||||||
ares_getsock \- get file descriptors to wait on
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_getsock(ares_channel \fIchannel\fP, int *\fIsocks\fP,
|
|
||||||
.B int \fInumsocks\fP);
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_getsock
|
|
||||||
function retrieves the set of file descriptors which the calling
|
|
||||||
application should wait on for reading and/or writing for the
|
|
||||||
processing of name service queries pending on the name service channel
|
|
||||||
identified by
|
|
||||||
.IR channel .
|
|
||||||
File descriptors will be set in the integer array pointed to by
|
|
||||||
\fIsocks\fP.
|
|
||||||
\fInumsocks\fP is the size of the given array in number of ints.
|
|
||||||
|
|
||||||
This function can only return information about up to 16 sockets. If more are
|
|
||||||
in use (however unlikely that is), they are simply not reported back.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
\fBares_getsock\fP returns a bitmask for what actions to wait for on the
|
|
||||||
different sockets. The ares.h header file provides these convenience macros to
|
|
||||||
extract the information appropriately:
|
|
||||||
|
|
||||||
.nf
|
|
||||||
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about
|
|
||||||
this many sockets */
|
|
||||||
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
|
|
||||||
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
|
|
||||||
ARES_GETSOCK_MAXNUM)))
|
|
||||||
.fi
|
|
||||||
.SH NOTES
|
|
||||||
This function was added in c-ares 1.3.1
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_timeout (3),
|
|
||||||
.BR ares_fds (3),
|
|
||||||
.BR ares_process (3)
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright (C) 2005 - 2007, Daniel Stenberg
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software and its
|
|
||||||
* documentation for any purpose and without fee is hereby granted, provided
|
|
||||||
* that the above copyright notice appear in all copies and that both that
|
|
||||||
* copyright notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the software without specific,
|
|
||||||
* written prior permission. M.I.T. makes no representations about the
|
|
||||||
* suitability of this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_getsock(ares_channel channel,
|
|
||||||
int *s,
|
|
||||||
int numsocks) /* size of the 'socks' array */
|
|
||||||
{
|
|
||||||
struct server_state *server;
|
|
||||||
int i;
|
|
||||||
int sockindex=0;
|
|
||||||
int bitmap = 0;
|
|
||||||
unsigned int setbits = 0xffffffff;
|
|
||||||
|
|
||||||
ares_socket_t *socks = (ares_socket_t *)s;
|
|
||||||
|
|
||||||
/* Are there any active queries? */
|
|
||||||
int active_queries = !ares__is_list_empty(&(channel->all_queries));
|
|
||||||
|
|
||||||
for (i = 0;
|
|
||||||
(i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM);
|
|
||||||
i++)
|
|
||||||
{
|
|
||||||
server = &channel->servers[i];
|
|
||||||
/* We only need to register interest in UDP sockets if we have
|
|
||||||
* outstanding queries.
|
|
||||||
*/
|
|
||||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
if(sockindex >= numsocks)
|
|
||||||
break;
|
|
||||||
socks[sockindex] = server->udp_socket;
|
|
||||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
|
||||||
sockindex++;
|
|
||||||
}
|
|
||||||
/* We always register for TCP events, because we want to know
|
|
||||||
* when the other side closes the connection, so we don't waste
|
|
||||||
* time trying to use a broken connection.
|
|
||||||
*/
|
|
||||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
|
||||||
{
|
|
||||||
if(sockindex >= numsocks)
|
|
||||||
break;
|
|
||||||
socks[sockindex] = server->tcp_socket;
|
|
||||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
|
||||||
|
|
||||||
if (server->qhead && active_queries)
|
|
||||||
/* then the tcp socket is also writable! */
|
|
||||||
bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex);
|
|
||||||
|
|
||||||
sockindex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
193
ares/ares_init.3
193
ares/ares_init.3
@@ -1,193 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\" Copyright (C) 2007-2008 by Daniel Stenberg
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_INIT 3 "13 May 2008"
|
|
||||||
.SH NAME
|
|
||||||
ares_init, ares_init_options \- Initialize a resolver channel
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_init(ares_channel *\fIchannel\fP)
|
|
||||||
.B int ares_init_options(ares_channel *\fIchannel\fP,
|
|
||||||
.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
|
|
||||||
.PP
|
|
||||||
.B cc file.c -lcares
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The \fBares_init\fP function initializes a communications channel for name
|
|
||||||
service lookups. If it returns successfully, \fBares_init\fP will set the
|
|
||||||
variable pointed to by \fIchannel\fP to a handle used to identify the name
|
|
||||||
service channel. The caller should invoke
|
|
||||||
.BR ares_destroy (3)
|
|
||||||
on the handle when the channel is no longer needed.
|
|
||||||
.PP
|
|
||||||
The \fBares_init_options\fP function also initializes a name service channel,
|
|
||||||
with additional options useful for applications requiring more control over
|
|
||||||
name service configuration. The \fIoptmask\fP parameter specifies which fields
|
|
||||||
in the structure pointed to by \fIoptions\fP are set, as follows:
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_FLAGS
|
|
||||||
.B int \fIflags\fP;
|
|
||||||
.br
|
|
||||||
Flags controlling the behavior of the resolver. See below for a
|
|
||||||
description of possible flag values.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_TIMEOUT
|
|
||||||
.B int \fItimeout\fP;
|
|
||||||
.br
|
|
||||||
The number of seconds each name server is given to respond to a query on the
|
|
||||||
first try. (After the first try, the timeout algorithm becomes more
|
|
||||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
|
||||||
default is five seconds. This option is being deprecated by
|
|
||||||
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_TIMEOUTMS
|
|
||||||
.B int \fItimeout\fP;
|
|
||||||
.br
|
|
||||||
The number of milliseconds each name server is given to respond to a query on
|
|
||||||
the first try. (After the first try, the timeout algorithm becomes more
|
|
||||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
|
||||||
default is five seconds. Note that this option is specified with the same
|
|
||||||
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
|
|
||||||
that tell c-ares how to interpret the number. This option was added in c-ares
|
|
||||||
1.5.2.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_TRIES
|
|
||||||
.B int \fItries\fP;
|
|
||||||
.br
|
|
||||||
The number of tries the resolver will try contacting each name server
|
|
||||||
before giving up. The default is four tries.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_NDOTS
|
|
||||||
.B int \fIndots\fP;
|
|
||||||
.br
|
|
||||||
The number of dots which must be present in a domain name for it to be
|
|
||||||
queried for "as is" prior to querying for it with the default domain
|
|
||||||
extensions appended. The default value is 1 unless set otherwise by
|
|
||||||
resolv.conf or the RES_OPTIONS environment variable.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_PORT
|
|
||||||
.B unsigned short \fIport\fP;
|
|
||||||
.br
|
|
||||||
The port to use for queries (both TCP and UDP), in network byte order.
|
|
||||||
The default value is 53 (in network byte order), the standard name
|
|
||||||
service port.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_SERVERS
|
|
||||||
.B struct in_addr *\fIservers\fP;
|
|
||||||
.br
|
|
||||||
.B int \fInservers\fP;
|
|
||||||
.br
|
|
||||||
The list of servers to contact, instead of the servers specified in
|
|
||||||
resolv.conf or the local named.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_DOMAINS
|
|
||||||
.B char **\fIdomains\fP;
|
|
||||||
.br
|
|
||||||
.B int \fIndomains\fP;
|
|
||||||
.br
|
|
||||||
The domains to search, instead of the domains specified in resolv.conf
|
|
||||||
or the domain derived from the kernel hostname variable.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_LOOKUPS
|
|
||||||
.B char *\fIlookups\fP;
|
|
||||||
.br
|
|
||||||
The lookups to perform for host queries.
|
|
||||||
.I lookups
|
|
||||||
should be set to a string of the characters "b" or "f", where "b"
|
|
||||||
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
|
|
||||||
.TP 18
|
|
||||||
.B ARES_OPT_SOCK_STATE_CB
|
|
||||||
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
|
|
||||||
.br
|
|
||||||
.B void *\fIsock_state_cb_data\fP;
|
|
||||||
.br
|
|
||||||
A callback function to be invoked when a socket changes state.
|
|
||||||
.I s
|
|
||||||
will be passed the socket whose state has changed;
|
|
||||||
.I read
|
|
||||||
will be set to true if the socket should listen for read events, and
|
|
||||||
.I write
|
|
||||||
will be set to true if the socket should listen for write events.
|
|
||||||
The value of
|
|
||||||
.I sock_state_cb_data
|
|
||||||
will be passed as the
|
|
||||||
.I data
|
|
||||||
argument.
|
|
||||||
.PP
|
|
||||||
The
|
|
||||||
.I flags
|
|
||||||
field should be the bitwise or of some subset of the following values:
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_USEVC
|
|
||||||
Always use TCP queries (the "virtual circuit") instead of UDP
|
|
||||||
queries. Normally, TCP is only used if a UDP query yields a truncated
|
|
||||||
result.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_PRIMARY
|
|
||||||
Only query the first server in the list of servers to query.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_IGNTC
|
|
||||||
If a truncated response to a UDP query is received, do not fall back
|
|
||||||
to TCP; simply continue on with the truncated response.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_NORECURSE
|
|
||||||
Do not set the "recursion desired" bit on outgoing queries, so that the name
|
|
||||||
server being contacted will not try to fetch the answer from other servers if
|
|
||||||
it doesn't know the answer locally. Be aware that ares will not do the
|
|
||||||
recursion for you. Recursion must be handled by the application calling ares
|
|
||||||
if \fIARES_FLAG_NORECURSE\fP is set.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_STAYOPEN
|
|
||||||
Do not close communications sockets when the number of active queries
|
|
||||||
drops to zero.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_NOSEARCH
|
|
||||||
Do not use the default search domains; only query hostnames as-is or
|
|
||||||
as aliases.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_NOALIASES
|
|
||||||
Do not honor the HOSTALIASES environment variable, which normally
|
|
||||||
specifies a file of hostname translations.
|
|
||||||
.TP 23
|
|
||||||
.B ARES_FLAG_NOCHECKRESP
|
|
||||||
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
|
|
||||||
response code or responses whose questions don't match the questions
|
|
||||||
in the request. Primarily useful for writing clients which might be
|
|
||||||
used to test or debug name servers.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.I ares_init
|
|
||||||
or
|
|
||||||
.I ares_init_options
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 14
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
Initialization succeeded.
|
|
||||||
.TP 14
|
|
||||||
.B ARES_EFILE
|
|
||||||
A configuration file could not be read.
|
|
||||||
.TP 14
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
The process's available memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_destroy(3),
|
|
||||||
.BR ares_dup(3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
1564
ares/ares_init.c
1564
ares/ares_init.c
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
|||||||
.so man3/ares_init.3
|
|
||||||
.\" $Id$
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright (C) 2005 by Dominick Meglio
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARES_IPV6_H
|
|
||||||
#define ARES_IPV6_H
|
|
||||||
|
|
||||||
#ifndef HAVE_PF_INET6
|
|
||||||
#define PF_INET6 AF_INET6
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(HAVE_STRUCT_IN6_ADDR) && !defined(s6_addr)
|
|
||||||
struct in6_addr {
|
|
||||||
union {
|
|
||||||
unsigned char _S6_u8[16];
|
|
||||||
} _S6_un;
|
|
||||||
};
|
|
||||||
#define s6_addr _S6_un._S6_u8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
|
||||||
struct sockaddr_in6
|
|
||||||
{
|
|
||||||
unsigned short sin6_family;
|
|
||||||
unsigned short sin6_port;
|
|
||||||
unsigned long sin6_flowinfo;
|
|
||||||
struct in6_addr sin6_addr;
|
|
||||||
unsigned int sin6_scope_id;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_ADDRINFO
|
|
||||||
struct addrinfo
|
|
||||||
{
|
|
||||||
int ai_flags;
|
|
||||||
int ai_family;
|
|
||||||
int ai_socktype;
|
|
||||||
int ai_protocol;
|
|
||||||
socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
|
|
||||||
char *ai_canonname;
|
|
||||||
struct sockaddr *ai_addr;
|
|
||||||
struct addrinfo *ai_next;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NS_IN6ADDRSZ
|
|
||||||
#if SIZEOF_STRUCT_IN6_ADDR == 0
|
|
||||||
/* We cannot have it set to zero, so we pick a fixed value here */
|
|
||||||
#define NS_IN6ADDRSZ 16
|
|
||||||
#else
|
|
||||||
#define NS_IN6ADDRSZ SIZEOF_STRUCT_IN6_ADDR
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NS_INADDRSZ
|
|
||||||
#define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NS_INT16SZ
|
|
||||||
#define NS_INT16SZ 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IF_NAMESIZE
|
|
||||||
#ifdef IFNAMSIZ
|
|
||||||
#define IF_NAMESIZE IFNAMSIZ
|
|
||||||
#else
|
|
||||||
#define IF_NAMESIZE 256
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ARES_IPV6_H */
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
/* Routines for managing doubly-linked circular linked lists with a
|
|
||||||
* dummy head.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Initialize a new head node */
|
|
||||||
void ares__init_list_head(struct list_node* head) {
|
|
||||||
head->prev = head;
|
|
||||||
head->next = head;
|
|
||||||
head->data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize a list node */
|
|
||||||
void ares__init_list_node(struct list_node* node, void* d) {
|
|
||||||
node->prev = NULL;
|
|
||||||
node->next = NULL;
|
|
||||||
node->data = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns true iff the given list is empty */
|
|
||||||
int ares__is_list_empty(struct list_node* head) {
|
|
||||||
return ((head->next == head) && (head->prev == head));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inserts new_node before old_node */
|
|
||||||
void ares__insert_in_list(struct list_node* new_node,
|
|
||||||
struct list_node* old_node) {
|
|
||||||
new_node->next = old_node;
|
|
||||||
new_node->prev = old_node->prev;
|
|
||||||
old_node->prev->next = new_node;
|
|
||||||
old_node->prev = new_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Removes the node from the list it's in, if any */
|
|
||||||
void ares__remove_from_list(struct list_node* node) {
|
|
||||||
if (node->next != NULL) {
|
|
||||||
node->prev->next = node->next;
|
|
||||||
node->next->prev = node->prev;
|
|
||||||
node->prev = NULL;
|
|
||||||
node->next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Swap the contents of two lists */
|
|
||||||
void ares__swap_lists(struct list_node* head_a,
|
|
||||||
struct list_node* head_b) {
|
|
||||||
int is_a_empty = ares__is_list_empty(head_a);
|
|
||||||
int is_b_empty = ares__is_list_empty(head_b);
|
|
||||||
struct list_node old_a = *head_a;
|
|
||||||
struct list_node old_b = *head_b;
|
|
||||||
|
|
||||||
if (is_a_empty) {
|
|
||||||
ares__init_list_head(head_b);
|
|
||||||
} else {
|
|
||||||
*head_b = old_a;
|
|
||||||
old_a.next->prev = head_b;
|
|
||||||
old_a.prev->next = head_b;
|
|
||||||
}
|
|
||||||
if (is_b_empty) {
|
|
||||||
ares__init_list_head(head_a);
|
|
||||||
} else {
|
|
||||||
*head_a = old_b;
|
|
||||||
old_b.next->prev = head_a;
|
|
||||||
old_b.prev->next = head_a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#ifndef __ARES_LLIST_H
|
|
||||||
#define __ARES_LLIST_H
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Node definition for circular, doubly-linked list */
|
|
||||||
struct list_node {
|
|
||||||
struct list_node *prev;
|
|
||||||
struct list_node *next;
|
|
||||||
void* data;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ares__init_list_head(struct list_node* head);
|
|
||||||
|
|
||||||
void ares__init_list_node(struct list_node* node, void* d);
|
|
||||||
|
|
||||||
int ares__is_list_empty(struct list_node* head);
|
|
||||||
|
|
||||||
void ares__insert_in_list(struct list_node* new_node,
|
|
||||||
struct list_node* old_node);
|
|
||||||
|
|
||||||
void ares__remove_from_list(struct list_node* node);
|
|
||||||
|
|
||||||
void ares__swap_lists(struct list_node* head_a,
|
|
||||||
struct list_node* head_b);
|
|
||||||
|
|
||||||
#endif /* __ARES_LLIST_H */
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998, 2000 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_MKQUERY 3 "4 January 2000"
|
|
||||||
.SH NAME
|
|
||||||
ares_mkquery \- Compose a single-question DNS query buffer
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_mkquery(const char *\fIname\fP, int \fIdnsclass\fP, int \fItype\fP,
|
|
||||||
.B unsigned short \fIid\fP, int \fIrd\fP, char **\fIbuf\fP,
|
|
||||||
.B int *\fIbuflen\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_mkquery
|
|
||||||
function composes a DNS query with a single question.
|
|
||||||
The parameter
|
|
||||||
.I name
|
|
||||||
gives the query name as a NUL-terminated C string of period-separated
|
|
||||||
labels optionally ending with a period; periods and backslashes within
|
|
||||||
a label must be escaped with a backlash. The parameters
|
|
||||||
.I dnsclass
|
|
||||||
and
|
|
||||||
.I type
|
|
||||||
give the class and type of the query using the values defined in
|
|
||||||
.BR <arpa/nameser.h> .
|
|
||||||
The parameter
|
|
||||||
.I id
|
|
||||||
gives a 16-bit identifier for the query. The parameter
|
|
||||||
.I rd
|
|
||||||
should be nonzero if recursion is desired, zero if not. The query
|
|
||||||
will be placed in an allocated buffer, a pointer to which will be
|
|
||||||
stored in the variable pointed to by
|
|
||||||
.IR buf ,
|
|
||||||
and the length of which will be stored in the variable pointed to by
|
|
||||||
.IR buflen .
|
|
||||||
It is the caller's responsibility to free this buffer using
|
|
||||||
\fIares_free_string(3)\fP when it is no longer needed.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_mkquery
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
Construction of the DNS query succeeded.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADNAME
|
|
||||||
The query name
|
|
||||||
.I name
|
|
||||||
could not be encoded as a domain name, either because it contained a
|
|
||||||
zero-length label or because it contained a label of more than 63
|
|
||||||
characters.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_expand_name (3),
|
|
||||||
.BR ares_free_string (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998, 2000 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
/* Header format, from RFC 1035:
|
|
||||||
* 1 1 1 1 1 1
|
|
||||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | ID |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | QDCOUNT |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | ANCOUNT |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | NSCOUNT |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | ARCOUNT |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
*
|
|
||||||
* AA, TC, RA, and RCODE are only set in responses. Brief description
|
|
||||||
* of the remaining fields:
|
|
||||||
* ID Identifier to match responses with queries
|
|
||||||
* QR Query (0) or response (1)
|
|
||||||
* Opcode For our purposes, always QUERY
|
|
||||||
* RD Recursion desired
|
|
||||||
* Z Reserved (zero)
|
|
||||||
* QDCOUNT Number of queries
|
|
||||||
* ANCOUNT Number of answers
|
|
||||||
* NSCOUNT Number of name server records
|
|
||||||
* ARCOUNT Number of additional records
|
|
||||||
*
|
|
||||||
* Question format, from RFC 1035:
|
|
||||||
* 1 1 1 1 1 1
|
|
||||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | |
|
|
||||||
* / QNAME /
|
|
||||||
* / /
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | QTYPE |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
* | QCLASS |
|
|
||||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
|
||||||
*
|
|
||||||
* The query name is encoded as a series of labels, each represented
|
|
||||||
* as a one-byte length (maximum 63) followed by the text of the
|
|
||||||
* label. The list is terminated by a label of length zero (which can
|
|
||||||
* be thought of as the root domain).
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
|
|
||||||
int rd, unsigned char **buf, int *buflen)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
unsigned char *q;
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
/* Set our results early, in case we bail out early with an error. */
|
|
||||||
*buflen = 0;
|
|
||||||
*buf = NULL;
|
|
||||||
|
|
||||||
/* Compute the length of the encoded name so we can check buflen.
|
|
||||||
* Start counting at 1 for the zero-length label at the end. */
|
|
||||||
len = 1;
|
|
||||||
for (p = name; *p; p++)
|
|
||||||
{
|
|
||||||
if (*p == '\\' && *(p + 1) != 0)
|
|
||||||
p++;
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
/* If there are n periods in the name, there are n + 1 labels, and
|
|
||||||
* thus n + 1 length fields, unless the name is empty or ends with a
|
|
||||||
* period. So add 1 unless name is empty or ends with a period.
|
|
||||||
*/
|
|
||||||
if (*name && *(p - 1) != '.')
|
|
||||||
len++;
|
|
||||||
|
|
||||||
/* Immediately reject names that are longer than the maximum of 255
|
|
||||||
* bytes that's specified in RFC 1035 ("To simplify implementations,
|
|
||||||
* the total length of a domain name (i.e., label octets and label
|
|
||||||
* length octets) is restricted to 255 octets or less."). We aren't
|
|
||||||
* doing this just to be a stickler about RFCs. For names that are
|
|
||||||
* too long, 'dnscache' closes its TCP connection to us immediately
|
|
||||||
* (when using TCP) and ignores the request when using UDP, and
|
|
||||||
* BIND's named returns ServFail (TCP or UDP). Sending a request
|
|
||||||
* that we know will cause 'dnscache' to close the TCP connection is
|
|
||||||
* painful, since that makes any other outstanding requests on that
|
|
||||||
* connection fail. And sending a UDP request that we know
|
|
||||||
* 'dnscache' will ignore is bad because resources will be tied up
|
|
||||||
* until we time-out the request.
|
|
||||||
*/
|
|
||||||
if (len > MAXCDNAME)
|
|
||||||
return ARES_EBADNAME;
|
|
||||||
|
|
||||||
*buflen = len + HFIXEDSZ + QFIXEDSZ;
|
|
||||||
*buf = malloc(*buflen);
|
|
||||||
if (!*buf)
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
|
|
||||||
/* Set up the header. */
|
|
||||||
q = *buf;
|
|
||||||
memset(q, 0, HFIXEDSZ);
|
|
||||||
DNS_HEADER_SET_QID(q, id);
|
|
||||||
DNS_HEADER_SET_OPCODE(q, QUERY);
|
|
||||||
if (rd) {
|
|
||||||
DNS_HEADER_SET_RD(q, 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DNS_HEADER_SET_RD(q, 0);
|
|
||||||
}
|
|
||||||
DNS_HEADER_SET_QDCOUNT(q, 1);
|
|
||||||
|
|
||||||
/* A name of "." is a screw case for the loop below, so adjust it. */
|
|
||||||
if (strcmp(name, ".") == 0)
|
|
||||||
name++;
|
|
||||||
|
|
||||||
/* Start writing out the name after the header. */
|
|
||||||
q += HFIXEDSZ;
|
|
||||||
while (*name)
|
|
||||||
{
|
|
||||||
if (*name == '.')
|
|
||||||
return ARES_EBADNAME;
|
|
||||||
|
|
||||||
/* Count the number of bytes in this label. */
|
|
||||||
len = 0;
|
|
||||||
for (p = name; *p && *p != '.'; p++)
|
|
||||||
{
|
|
||||||
if (*p == '\\' && *(p + 1) != 0)
|
|
||||||
p++;
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
if (len > MAXLABEL)
|
|
||||||
return ARES_EBADNAME;
|
|
||||||
|
|
||||||
/* Encode the length and copy the data. */
|
|
||||||
*q++ = (unsigned char)len;
|
|
||||||
for (p = name; *p && *p != '.'; p++)
|
|
||||||
{
|
|
||||||
if (*p == '\\' && *(p + 1) != 0)
|
|
||||||
p++;
|
|
||||||
*q++ = *p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Go to the next label and repeat, unless we hit the end. */
|
|
||||||
if (!*p)
|
|
||||||
break;
|
|
||||||
name = p + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add the zero-length label at the end. */
|
|
||||||
*q++ = 0;
|
|
||||||
|
|
||||||
/* Finish off the question with the type and class. */
|
|
||||||
DNS_QUESTION_SET_TYPE(q, type);
|
|
||||||
DNS_QUESTION_SET_CLASS(q, dnsclass);
|
|
||||||
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_PARSE_A_REPLY 3 "25 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_parse_a_reply \- Parse a reply to a DNS query of type A into a hostent
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
|
||||||
.B struct hostent **\fIhost\fP,
|
|
||||||
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_parse_a_reply
|
|
||||||
function parses the response to a query of type A into a
|
|
||||||
.BR "struct hostent"
|
|
||||||
and/or an array of
|
|
||||||
.BR "struct addrttls" .
|
|
||||||
The parameters
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the contents of the response. The result is stored in allocated
|
|
||||||
memory and a pointer to it stored into the variable pointed to by
|
|
||||||
.IR host ,
|
|
||||||
if host is nonnull.
|
|
||||||
It is the caller's responsibility to free the resulting host structure
|
|
||||||
using
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
when it is no longer needed.
|
|
||||||
.PP
|
|
||||||
If
|
|
||||||
.IR addrttls
|
|
||||||
and
|
|
||||||
.IR naddrttls
|
|
||||||
are both nonnull,
|
|
||||||
then up to *naddrttls
|
|
||||||
.BR "struct addrttl"
|
|
||||||
records are stored in the array pointed to by addrttls,
|
|
||||||
and then *naddrttls is set to the number of records so stored.
|
|
||||||
Note that the memory for these records is supplied by the caller.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_parse_a_reply
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The response was successfully parsed.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADRESP
|
|
||||||
The response was malformatted.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENODATA
|
|
||||||
The response did not contain an answer to the query.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_gethostbyname (3),
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|
||||||
struct hostent **host,
|
|
||||||
struct addrttl *addrttls, int *naddrttls)
|
|
||||||
{
|
|
||||||
unsigned int qdcount, ancount;
|
|
||||||
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
|
||||||
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
|
||||||
int naliases;
|
|
||||||
long len;
|
|
||||||
const unsigned char *aptr;
|
|
||||||
char *hostname, *rr_name, *rr_data, **aliases;
|
|
||||||
struct in_addr *addrs;
|
|
||||||
struct hostent *hostent;
|
|
||||||
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
|
||||||
if (host)
|
|
||||||
*host = NULL;
|
|
||||||
/* Same with *naddrttls. */
|
|
||||||
if (naddrttls)
|
|
||||||
*naddrttls = 0;
|
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
|
||||||
if (alen < HFIXEDSZ)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Fetch the question and answer count from the header. */
|
|
||||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
|
||||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
|
||||||
if (qdcount != 1)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Expand the name from the question, and skip past the question. */
|
|
||||||
aptr = abuf + HFIXEDSZ;
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return status;
|
|
||||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
}
|
|
||||||
aptr += len + QFIXEDSZ;
|
|
||||||
|
|
||||||
if (host)
|
|
||||||
{
|
|
||||||
/* Allocate addresses and aliases; ancount gives an upper bound for
|
|
||||||
both. */
|
|
||||||
addrs = malloc(ancount * sizeof(struct in_addr));
|
|
||||||
if (!addrs)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
|
||||||
if (!aliases)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
free(addrs);
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addrs = NULL;
|
|
||||||
aliases = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
naddrs = 0;
|
|
||||||
naliases = 0;
|
|
||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
|
||||||
for (i = 0; i < (int)ancount; i++)
|
|
||||||
{
|
|
||||||
/* Decode the RR up to the data field. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
aptr += len;
|
|
||||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rr_type = DNS_RR_TYPE(aptr);
|
|
||||||
rr_class = DNS_RR_CLASS(aptr);
|
|
||||||
rr_len = DNS_RR_LEN(aptr);
|
|
||||||
rr_ttl = DNS_RR_TTL(aptr);
|
|
||||||
aptr += RRFIXEDSZ;
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_A
|
|
||||||
&& rr_len == sizeof(struct in_addr)
|
|
||||||
&& strcasecmp(rr_name, hostname) == 0)
|
|
||||||
{
|
|
||||||
if (addrs)
|
|
||||||
{
|
|
||||||
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
|
|
||||||
}
|
|
||||||
if (naddrs < max_addr_ttls)
|
|
||||||
{
|
|
||||||
struct addrttl * const at = &addrttls[naddrs];
|
|
||||||
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
|
|
||||||
at->ttl = rr_ttl;
|
|
||||||
}
|
|
||||||
naddrs++;
|
|
||||||
status = ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
|
||||||
{
|
|
||||||
/* Record the RR name as an alias. */
|
|
||||||
if (aliases)
|
|
||||||
aliases[naliases] = rr_name;
|
|
||||||
else
|
|
||||||
free(rr_name);
|
|
||||||
naliases++;
|
|
||||||
|
|
||||||
/* Decode the RR data and replace the hostname with it. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
|
||||||
&len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
free(hostname);
|
|
||||||
hostname = rr_data;
|
|
||||||
|
|
||||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
|
||||||
if (cname_ttl > rr_ttl)
|
|
||||||
cname_ttl = rr_ttl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
free(rr_name);
|
|
||||||
|
|
||||||
aptr += rr_len;
|
|
||||||
if (aptr > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == ARES_SUCCESS && naddrs == 0)
|
|
||||||
status = ARES_ENODATA;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* We got our answer. */
|
|
||||||
if (naddrttls)
|
|
||||||
{
|
|
||||||
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
|
||||||
if (addrttls[i].ttl > cname_ttl)
|
|
||||||
addrttls[i].ttl = cname_ttl;
|
|
||||||
}
|
|
||||||
*naddrttls = n;
|
|
||||||
}
|
|
||||||
if (aliases)
|
|
||||||
aliases[naliases] = NULL;
|
|
||||||
if (host)
|
|
||||||
{
|
|
||||||
/* Allocate memory to build the host entry. */
|
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (hostent)
|
|
||||||
{
|
|
||||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
|
||||||
if (hostent->h_addr_list)
|
|
||||||
{
|
|
||||||
/* Fill in the hostent and return successfully. */
|
|
||||||
hostent->h_name = hostname;
|
|
||||||
hostent->h_aliases = aliases;
|
|
||||||
hostent->h_addrtype = AF_INET;
|
|
||||||
hostent->h_length = sizeof(struct in_addr);
|
|
||||||
for (i = 0; i < naddrs; i++)
|
|
||||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
|
||||||
hostent->h_addr_list[naddrs] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
free(hostent);
|
|
||||||
}
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (aliases)
|
|
||||||
{
|
|
||||||
for (i = 0; i < naliases; i++)
|
|
||||||
free(aliases[i]);
|
|
||||||
free(aliases);
|
|
||||||
}
|
|
||||||
free(addrs);
|
|
||||||
free(hostname);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 2005 by Dominick Meglio.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_PARSE_AAAA_REPLY 3 "10 March 2005"
|
|
||||||
.SH NAME
|
|
||||||
ares_parse_aaaa_reply \- Parse a reply to a DNS query of type AAAA into a hostent
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
|
||||||
.B struct hostent **\fIhost\fP,
|
|
||||||
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_parse_aaaa_reply
|
|
||||||
function parses the response to a query of type AAAA into a
|
|
||||||
.BR "struct hostent"
|
|
||||||
and/or an array of
|
|
||||||
.BR "struct addrttls" .
|
|
||||||
The parameters
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the contents of the response. The result is stored in allocated
|
|
||||||
memory and a pointer to it stored into the variable pointed to by
|
|
||||||
.IR host ,
|
|
||||||
if host is nonnull.
|
|
||||||
It is the caller's responsibility to free the resulting host structure
|
|
||||||
using
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
when it is no longer needed.
|
|
||||||
.PP
|
|
||||||
If
|
|
||||||
.IR addrttls
|
|
||||||
and
|
|
||||||
.IR naddrttls
|
|
||||||
are both nonnull,
|
|
||||||
then up to *naddrttls
|
|
||||||
.BR "struct addr6ttl"
|
|
||||||
records are stored in the array pointed to by addrttls,
|
|
||||||
and then *naddrttls is set to the number of records so stored.
|
|
||||||
Note that the memory for these records is supplied by the caller.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_parse_aaaa_reply
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The response was successfully parsed.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADRESP
|
|
||||||
The response was malformatted.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENODATA
|
|
||||||
The response did not contain an answer to the query.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_gethostbyname (3),
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Dominick Meglio
|
|
||||||
.br
|
|
||||||
Copyright 2005 by Dominick Meglio.
|
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 2005 Dominick Meglio
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "inet_net_pton.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|
||||||
struct hostent **host, struct addr6ttl *addrttls,
|
|
||||||
int *naddrttls)
|
|
||||||
{
|
|
||||||
unsigned int qdcount, ancount;
|
|
||||||
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
|
||||||
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
|
||||||
int naliases;
|
|
||||||
long len;
|
|
||||||
const unsigned char *aptr;
|
|
||||||
char *hostname, *rr_name, *rr_data, **aliases;
|
|
||||||
struct in6_addr *addrs;
|
|
||||||
struct hostent *hostent;
|
|
||||||
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
|
||||||
if (host)
|
|
||||||
*host = NULL;
|
|
||||||
/* Same with *naddrttls. */
|
|
||||||
if (naddrttls)
|
|
||||||
*naddrttls = 0;
|
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
|
||||||
if (alen < HFIXEDSZ)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Fetch the question and answer count from the header. */
|
|
||||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
|
||||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
|
||||||
if (qdcount != 1)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Expand the name from the question, and skip past the question. */
|
|
||||||
aptr = abuf + HFIXEDSZ;
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return status;
|
|
||||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
}
|
|
||||||
aptr += len + QFIXEDSZ;
|
|
||||||
|
|
||||||
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
|
||||||
if (host)
|
|
||||||
{
|
|
||||||
addrs = malloc(ancount * sizeof(struct in6_addr));
|
|
||||||
if (!addrs)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
|
||||||
if (!aliases)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
free(addrs);
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addrs = NULL;
|
|
||||||
aliases = NULL;
|
|
||||||
}
|
|
||||||
naddrs = 0;
|
|
||||||
naliases = 0;
|
|
||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
|
||||||
for (i = 0; i < (int)ancount; i++)
|
|
||||||
{
|
|
||||||
/* Decode the RR up to the data field. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
aptr += len;
|
|
||||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rr_type = DNS_RR_TYPE(aptr);
|
|
||||||
rr_class = DNS_RR_CLASS(aptr);
|
|
||||||
rr_len = DNS_RR_LEN(aptr);
|
|
||||||
rr_ttl = DNS_RR_TTL(aptr);
|
|
||||||
aptr += RRFIXEDSZ;
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_AAAA
|
|
||||||
&& rr_len == sizeof(struct in6_addr)
|
|
||||||
&& strcasecmp(rr_name, hostname) == 0)
|
|
||||||
{
|
|
||||||
if (addrs)
|
|
||||||
{
|
|
||||||
if (aptr + sizeof(struct in6_addr) > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy(&addrs[naddrs], aptr, sizeof(struct in6_addr));
|
|
||||||
}
|
|
||||||
if (naddrs < max_addr_ttls)
|
|
||||||
{
|
|
||||||
struct addr6ttl * const at = &addrttls[naddrs];
|
|
||||||
if (aptr + sizeof(struct in6_addr) > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
memcpy(&at->ip6addr, aptr, sizeof(struct in6_addr));
|
|
||||||
at->ttl = rr_ttl;
|
|
||||||
}
|
|
||||||
naddrs++;
|
|
||||||
status = ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
|
||||||
{
|
|
||||||
/* Record the RR name as an alias. */
|
|
||||||
if (aliases)
|
|
||||||
aliases[naliases] = rr_name;
|
|
||||||
else
|
|
||||||
free(rr_name);
|
|
||||||
naliases++;
|
|
||||||
|
|
||||||
/* Decode the RR data and replace the hostname with it. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
|
||||||
&len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
free(hostname);
|
|
||||||
hostname = rr_data;
|
|
||||||
|
|
||||||
/* Take the min of the TTLs we see in the CNAME chain. */
|
|
||||||
if (cname_ttl > rr_ttl)
|
|
||||||
cname_ttl = rr_ttl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
free(rr_name);
|
|
||||||
|
|
||||||
aptr += rr_len;
|
|
||||||
if (aptr > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == ARES_SUCCESS && naddrs == 0)
|
|
||||||
status = ARES_ENODATA;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* We got our answer. */
|
|
||||||
if (naddrttls)
|
|
||||||
{
|
|
||||||
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
|
||||||
if (addrttls[i].ttl > cname_ttl)
|
|
||||||
addrttls[i].ttl = cname_ttl;
|
|
||||||
}
|
|
||||||
*naddrttls = n;
|
|
||||||
}
|
|
||||||
if (aliases)
|
|
||||||
aliases[naliases] = NULL;
|
|
||||||
if (host)
|
|
||||||
{
|
|
||||||
/* Allocate memory to build the host entry. */
|
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (hostent)
|
|
||||||
{
|
|
||||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
|
||||||
if (hostent->h_addr_list)
|
|
||||||
{
|
|
||||||
/* Fill in the hostent and return successfully. */
|
|
||||||
hostent->h_name = hostname;
|
|
||||||
hostent->h_aliases = aliases;
|
|
||||||
hostent->h_addrtype = AF_INET6;
|
|
||||||
hostent->h_length = sizeof(struct in6_addr);
|
|
||||||
for (i = 0; i < naddrs; i++)
|
|
||||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
|
||||||
hostent->h_addr_list[naddrs] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
free(hostent);
|
|
||||||
}
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (aliases)
|
|
||||||
{
|
|
||||||
for (i = 0; i < naliases; i++)
|
|
||||||
free(aliases[i]);
|
|
||||||
free(aliases);
|
|
||||||
}
|
|
||||||
free(addrs);
|
|
||||||
free(hostname);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_PARSE_NS_REPLY 3 "10 February 2007"
|
|
||||||
.SH NAME
|
|
||||||
ares_parse_ns_reply \- Parse a reply to a DNS query of type NS into a hostent
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_parse_ns_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
|
||||||
.B struct hostent **\fIhost\fP);
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_parse_ns_reply
|
|
||||||
function parses the response to a query of type NS into a
|
|
||||||
.BR "struct hostent" .
|
|
||||||
The parameters
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the contents of the response. The result is stored in allocated
|
|
||||||
memory and a pointer to it stored into the variable pointed to by
|
|
||||||
.IR host .
|
|
||||||
The nameservers are stored into the
|
|
||||||
.BR aliases
|
|
||||||
field of the
|
|
||||||
.IR host
|
|
||||||
structure.
|
|
||||||
It is the caller's responsibility to free the resulting host structure
|
|
||||||
using
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
when it is no longer needed.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_parse_ns_reply
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The response was successfully parsed.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADRESP
|
|
||||||
The response was malformatted.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENODATA
|
|
||||||
The response did not contain an answer to the query.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_query (3),
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Written by Vlad Dinulescu <vlad.dinulescu@avira.com>, on behalf of AVIRA Gmbh http://www.avira.com
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ares_parse_ns_reply created by Vlad Dinulescu <vlad.dinulescu@avira.com>
|
|
||||||
* on behalf of AVIRA Gmbh - http://www.avira.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_parse_ns_reply( const unsigned char* abuf, int alen,
|
|
||||||
struct hostent** host )
|
|
||||||
{
|
|
||||||
unsigned int qdcount, ancount;
|
|
||||||
int status, i, rr_type, rr_class, rr_len;
|
|
||||||
int nameservers_num;
|
|
||||||
long len;
|
|
||||||
const unsigned char *aptr;
|
|
||||||
char* hostname, *rr_name, *rr_data, **nameservers;
|
|
||||||
struct hostent *hostent;
|
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
|
||||||
*host = NULL;
|
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
|
||||||
if ( alen < HFIXEDSZ )
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Fetch the question and answer count from the header. */
|
|
||||||
qdcount = DNS_HEADER_QDCOUNT( abuf );
|
|
||||||
ancount = DNS_HEADER_ANCOUNT( abuf );
|
|
||||||
if ( qdcount != 1 )
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Expand the name from the question, and skip past the question. */
|
|
||||||
aptr = abuf + HFIXEDSZ;
|
|
||||||
status = ares__expand_name_for_response( aptr, abuf, alen, &hostname, &len);
|
|
||||||
if ( status != ARES_SUCCESS )
|
|
||||||
return status;
|
|
||||||
if ( aptr + len + QFIXEDSZ > abuf + alen )
|
|
||||||
{
|
|
||||||
free( hostname );
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
}
|
|
||||||
aptr += len + QFIXEDSZ;
|
|
||||||
|
|
||||||
/* Allocate nameservers array; ancount gives an upper bound */
|
|
||||||
nameservers = malloc( ( ancount + 1 ) * sizeof( char * ) );
|
|
||||||
if ( !nameservers )
|
|
||||||
{
|
|
||||||
free( hostname );
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
nameservers_num = 0;
|
|
||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
|
||||||
for ( i = 0; i < ( int ) ancount; i++ )
|
|
||||||
{
|
|
||||||
/* Decode the RR up to the data field. */
|
|
||||||
status = ares__expand_name_for_response( aptr, abuf, alen, &rr_name, &len );
|
|
||||||
if ( status != ARES_SUCCESS )
|
|
||||||
break;
|
|
||||||
aptr += len;
|
|
||||||
if ( aptr + RRFIXEDSZ > abuf + alen )
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rr_type = DNS_RR_TYPE( aptr );
|
|
||||||
rr_class = DNS_RR_CLASS( aptr );
|
|
||||||
rr_len = DNS_RR_LEN( aptr );
|
|
||||||
aptr += RRFIXEDSZ;
|
|
||||||
|
|
||||||
if ( rr_class == C_IN && rr_type == T_NS )
|
|
||||||
{
|
|
||||||
/* Decode the RR data and add it to the nameservers list */
|
|
||||||
status = ares__expand_name_for_response( aptr, abuf, alen, &rr_data,
|
|
||||||
&len);
|
|
||||||
if ( status != ARES_SUCCESS )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nameservers[nameservers_num] = malloc(strlen(rr_data)+1);
|
|
||||||
|
|
||||||
if (nameservers[nameservers_num]==NULL)
|
|
||||||
{
|
|
||||||
free(rr_name);
|
|
||||||
free(rr_data);
|
|
||||||
status=ARES_ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strcpy(nameservers[nameservers_num],rr_data);
|
|
||||||
free(rr_data);
|
|
||||||
|
|
||||||
nameservers_num++;
|
|
||||||
}
|
|
||||||
|
|
||||||
free( rr_name );
|
|
||||||
|
|
||||||
aptr += rr_len;
|
|
||||||
if ( aptr > abuf + alen )
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( status == ARES_SUCCESS && nameservers_num == 0 )
|
|
||||||
{
|
|
||||||
status = ARES_ENODATA;
|
|
||||||
}
|
|
||||||
if ( status == ARES_SUCCESS )
|
|
||||||
{
|
|
||||||
/* We got our answer. Allocate memory to build the host entry. */
|
|
||||||
nameservers[nameservers_num] = NULL;
|
|
||||||
hostent = malloc( sizeof( struct hostent ) );
|
|
||||||
if ( hostent )
|
|
||||||
{
|
|
||||||
hostent->h_addr_list = malloc( 1 * sizeof( char * ) );
|
|
||||||
if ( hostent->h_addr_list )
|
|
||||||
{
|
|
||||||
/* Fill in the hostent and return successfully. */
|
|
||||||
hostent->h_name = hostname;
|
|
||||||
hostent->h_aliases = nameservers;
|
|
||||||
hostent->h_addrtype = AF_INET;
|
|
||||||
hostent->h_length = sizeof( struct in_addr );
|
|
||||||
hostent->h_addr_list[0] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
free( hostent );
|
|
||||||
}
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
for ( i = 0; i < nameservers_num; i++ )
|
|
||||||
free( nameservers[i] );
|
|
||||||
free( nameservers );
|
|
||||||
free( hostname );
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_PARSE_PTR_REPLY 3 "25 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_parse_ptr_reply \- Parse a reply to a DNS query of type PTR into a hostent
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B int ares_parse_ptr_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
|
||||||
.B const void *\fIaddr\fP, int \fIaddrlen\fP, int \fIfamily\fP,
|
|
||||||
.B struct hostent **\fIhost\fP);
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_parse_ptr_reply
|
|
||||||
function parses the response to a query of type PTR into a
|
|
||||||
.BR "struct hostent" .
|
|
||||||
The parameters
|
|
||||||
.I abuf
|
|
||||||
and
|
|
||||||
.I alen
|
|
||||||
give the contents of the response. The parameters
|
|
||||||
.IR addr ,
|
|
||||||
.IR addrlen ,
|
|
||||||
and
|
|
||||||
.I family
|
|
||||||
specify which address was queried for; they are not used to verify the
|
|
||||||
response, merely used to fill in the address of the
|
|
||||||
.BR "struct hostent" .
|
|
||||||
The resulting
|
|
||||||
.B struct hostent
|
|
||||||
is stored in allocated memory and a pointer to it stored into the
|
|
||||||
variable pointed to by
|
|
||||||
.IR host .
|
|
||||||
It is the caller's responsibility to free the resulting host structure
|
|
||||||
using
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
when it is no longer needed.
|
|
||||||
.SH RETURN VALUES
|
|
||||||
.B ares_parse_ptr_reply
|
|
||||||
can return any of the following values:
|
|
||||||
.TP 15
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The response was successfully parsed.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_EBADRESP
|
|
||||||
The response was malformatted.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENODATA
|
|
||||||
The response did not contain an answer to the query.
|
|
||||||
.TP 15
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_gethostbyaddr (3),
|
|
||||||
.BR ares_free_hostent (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|
||||||
int addrlen, int family, struct hostent **host)
|
|
||||||
{
|
|
||||||
unsigned int qdcount, ancount;
|
|
||||||
int status, i, rr_type, rr_class, rr_len;
|
|
||||||
long len;
|
|
||||||
const unsigned char *aptr;
|
|
||||||
char *ptrname, *hostname, *rr_name, *rr_data;
|
|
||||||
struct hostent *hostent;
|
|
||||||
int aliascnt = 0;
|
|
||||||
int alias_alloc = 8;
|
|
||||||
char ** aliases;
|
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
|
||||||
*host = NULL;
|
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
|
||||||
if (alen < HFIXEDSZ)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Fetch the question and answer count from the header. */
|
|
||||||
qdcount = DNS_HEADER_QDCOUNT(abuf);
|
|
||||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
|
||||||
if (qdcount != 1)
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
|
|
||||||
/* Expand the name from the question, and skip past the question. */
|
|
||||||
aptr = abuf + HFIXEDSZ;
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &ptrname, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
return status;
|
|
||||||
if (aptr + len + QFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
free(ptrname);
|
|
||||||
return ARES_EBADRESP;
|
|
||||||
}
|
|
||||||
aptr += len + QFIXEDSZ;
|
|
||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
|
||||||
hostname = NULL;
|
|
||||||
aliases = malloc(alias_alloc * sizeof(char *));
|
|
||||||
if (!aliases)
|
|
||||||
{
|
|
||||||
free(ptrname);
|
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
for (i = 0; i < (int)ancount; i++)
|
|
||||||
{
|
|
||||||
/* Decode the RR up to the data field. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
aptr += len;
|
|
||||||
if (aptr + RRFIXEDSZ > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rr_type = DNS_RR_TYPE(aptr);
|
|
||||||
rr_class = DNS_RR_CLASS(aptr);
|
|
||||||
rr_len = DNS_RR_LEN(aptr);
|
|
||||||
aptr += RRFIXEDSZ;
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_PTR
|
|
||||||
&& strcasecmp(rr_name, ptrname) == 0)
|
|
||||||
{
|
|
||||||
/* Decode the RR data and set hostname to it. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
|
||||||
&len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
if (hostname)
|
|
||||||
free(hostname);
|
|
||||||
hostname = rr_data;
|
|
||||||
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char *));
|
|
||||||
if (!aliases[aliascnt])
|
|
||||||
{
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
|
||||||
aliascnt++;
|
|
||||||
if (aliascnt >= alias_alloc) {
|
|
||||||
char **ptr;
|
|
||||||
alias_alloc *= 2;
|
|
||||||
ptr = realloc(aliases, alias_alloc * sizeof(char *));
|
|
||||||
if(!ptr) {
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aliases = ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
|
||||||
{
|
|
||||||
/* Decode the RR data and replace ptrname with it. */
|
|
||||||
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
|
|
||||||
&len);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
break;
|
|
||||||
free(ptrname);
|
|
||||||
ptrname = rr_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(rr_name);
|
|
||||||
aptr += rr_len;
|
|
||||||
if (aptr > abuf + alen)
|
|
||||||
{
|
|
||||||
status = ARES_EBADRESP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == ARES_SUCCESS && !hostname)
|
|
||||||
status = ARES_ENODATA;
|
|
||||||
if (status == ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
/* We got our answer. Allocate memory to build the host entry. */
|
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (hostent)
|
|
||||||
{
|
|
||||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
|
||||||
if (hostent->h_addr_list)
|
|
||||||
{
|
|
||||||
hostent->h_addr_list[0] = malloc(addrlen);
|
|
||||||
if (hostent->h_addr_list[0])
|
|
||||||
{
|
|
||||||
hostent->h_aliases = malloc((aliascnt+1) * sizeof (char *));
|
|
||||||
if (hostent->h_aliases)
|
|
||||||
{
|
|
||||||
/* Fill in the hostent and return successfully. */
|
|
||||||
hostent->h_name = hostname;
|
|
||||||
for (i=0 ; i<aliascnt ; i++)
|
|
||||||
hostent->h_aliases[i] = aliases[i];
|
|
||||||
hostent->h_aliases[aliascnt] = NULL;
|
|
||||||
hostent->h_addrtype = family;
|
|
||||||
hostent->h_length = addrlen;
|
|
||||||
memcpy(hostent->h_addr_list[0], addr, addrlen);
|
|
||||||
hostent->h_addr_list[1] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
free(aliases);
|
|
||||||
free(ptrname);
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
|
||||||
free(hostent->h_addr_list[0]);
|
|
||||||
}
|
|
||||||
free(hostent->h_addr_list);
|
|
||||||
}
|
|
||||||
free(hostent);
|
|
||||||
}
|
|
||||||
status = ARES_ENOMEM;
|
|
||||||
}
|
|
||||||
for (i=0 ; i<aliascnt ; i++)
|
|
||||||
if (aliases[i])
|
|
||||||
free(aliases[i]);
|
|
||||||
free(aliases);
|
|
||||||
if (hostname)
|
|
||||||
free(hostname);
|
|
||||||
free(ptrname);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
@@ -1,346 +0,0 @@
|
|||||||
#ifndef __ARES_PRIVATE_H
|
|
||||||
#define __ARES_PRIVATE_H
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
* Copyright (C) 2004-2008 by Daniel Stenberg
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define WIN32 when build target is Win32 API
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
|
||||||
#define WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#if !defined(WIN32) || defined(WATT32)
|
|
||||||
#include <netinet/in.h>
|
|
||||||
/* We define closesocket() here so that we can use this function all over
|
|
||||||
the source code for closing sockets. */
|
|
||||||
#define closesocket(x) close(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WATT32
|
|
||||||
#include <tcp.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#undef closesocket
|
|
||||||
#define closesocket(s) close_s(s)
|
|
||||||
#define writev(s,v,c) writev_s(s,v,c)
|
|
||||||
#define HAVE_WRITEV 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NETWARE
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFAULT_TIMEOUT 5000 /* milliseconds */
|
|
||||||
#define DEFAULT_TRIES 4
|
|
||||||
#ifndef INADDR_NONE
|
|
||||||
#define INADDR_NONE 0xffffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(WATT32)
|
|
||||||
|
|
||||||
#define IS_NT() ((int)GetVersion() > 0)
|
|
||||||
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
|
|
||||||
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
|
|
||||||
#define NAMESERVER "NameServer"
|
|
||||||
#define DHCPNAMESERVER "DhcpNameServer"
|
|
||||||
#define DATABASEPATH "DatabasePath"
|
|
||||||
#define WIN_PATH_HOSTS "\\hosts"
|
|
||||||
|
|
||||||
#elif defined(WATT32)
|
|
||||||
|
|
||||||
#define PATH_RESOLV_CONF "/dev/ENV/etc/resolv.conf"
|
|
||||||
|
|
||||||
#elif defined(NETWARE)
|
|
||||||
|
|
||||||
#define PATH_RESOLV_CONF "sys:/etc/resolv.cfg"
|
|
||||||
#define PATH_HOSTS "sys:/etc/hosts"
|
|
||||||
|
|
||||||
#elif defined(__riscos__)
|
|
||||||
|
|
||||||
#define PATH_HOSTS "InetDBase:Hosts"
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define PATH_RESOLV_CONF "/etc/resolv.conf"
|
|
||||||
#ifdef ETC_INET
|
|
||||||
#define PATH_HOSTS "/etc/inet/hosts"
|
|
||||||
#else
|
|
||||||
#define PATH_HOSTS "/etc/hosts"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARES_ID_KEY_LEN 31
|
|
||||||
|
|
||||||
#include "ares_ipv6.h"
|
|
||||||
#include "ares_llist.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
|
||||||
# include "ares_strdup.h"
|
|
||||||
# define strdup(ptr) ares_strdup(ptr)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_STRNCASECMP
|
|
||||||
# include "ares_strcasecmp.h"
|
|
||||||
# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_WRITEV
|
|
||||||
# include "ares_writev.h"
|
|
||||||
# define writev(s,ptr,cnt) ares_writev(s,ptr,cnt)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ares_addr {
|
|
||||||
int family;
|
|
||||||
union {
|
|
||||||
struct in_addr addr4;
|
|
||||||
struct in6_addr addr6;
|
|
||||||
} addr;
|
|
||||||
};
|
|
||||||
#define addrV4 addr.addr4
|
|
||||||
#define addrV6 addr.addr6
|
|
||||||
|
|
||||||
struct query;
|
|
||||||
|
|
||||||
struct send_request {
|
|
||||||
/* Remaining data to send */
|
|
||||||
const unsigned char *data;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* The query for which we're sending this data */
|
|
||||||
struct query* owner_query;
|
|
||||||
/* The buffer we're using, if we have our own copy of the packet */
|
|
||||||
unsigned char *data_storage;
|
|
||||||
|
|
||||||
/* Next request in queue */
|
|
||||||
struct send_request *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct server_state {
|
|
||||||
struct in_addr addr;
|
|
||||||
ares_socket_t udp_socket;
|
|
||||||
ares_socket_t tcp_socket;
|
|
||||||
|
|
||||||
/* Mini-buffer for reading the length word */
|
|
||||||
unsigned char tcp_lenbuf[2];
|
|
||||||
int tcp_lenbuf_pos;
|
|
||||||
int tcp_length;
|
|
||||||
|
|
||||||
/* Buffer for reading actual TCP data */
|
|
||||||
unsigned char *tcp_buffer;
|
|
||||||
int tcp_buffer_pos;
|
|
||||||
|
|
||||||
/* TCP output queue */
|
|
||||||
struct send_request *qhead;
|
|
||||||
struct send_request *qtail;
|
|
||||||
|
|
||||||
/* Which incarnation of this connection is this? We don't want to
|
|
||||||
* retransmit requests into the very same socket, but if the server
|
|
||||||
* closes on us and we re-open the connection, then we do want to
|
|
||||||
* re-send. */
|
|
||||||
int tcp_connection_generation;
|
|
||||||
|
|
||||||
/* Circular, doubly-linked list of outstanding queries to this server */
|
|
||||||
struct list_node queries_to_server;
|
|
||||||
|
|
||||||
/* Link back to owning channel */
|
|
||||||
ares_channel channel;
|
|
||||||
|
|
||||||
/* Is this server broken? We mark connections as broken when a
|
|
||||||
* request that is queued for sending times out.
|
|
||||||
*/
|
|
||||||
int is_broken;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* State to represent a DNS query */
|
|
||||||
struct query {
|
|
||||||
/* Query ID from qbuf, for faster lookup, and current timeout */
|
|
||||||
unsigned short qid;
|
|
||||||
struct timeval timeout;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Links for the doubly-linked lists in which we insert a query.
|
|
||||||
* These circular, doubly-linked lists that are hash-bucketed based
|
|
||||||
* the attributes we care about, help making most important
|
|
||||||
* operations O(1).
|
|
||||||
*/
|
|
||||||
struct list_node queries_by_qid; /* hopefully in same cache line as qid */
|
|
||||||
struct list_node queries_by_timeout;
|
|
||||||
struct list_node queries_to_server;
|
|
||||||
struct list_node all_queries;
|
|
||||||
|
|
||||||
/* Query buf with length at beginning, for TCP transmission */
|
|
||||||
unsigned char *tcpbuf;
|
|
||||||
int tcplen;
|
|
||||||
|
|
||||||
/* Arguments passed to ares_send() (qbuf points into tcpbuf) */
|
|
||||||
const unsigned char *qbuf;
|
|
||||||
int qlen;
|
|
||||||
ares_callback callback;
|
|
||||||
void *arg;
|
|
||||||
|
|
||||||
/* Query status */
|
|
||||||
int try; /* Number of times we tried this query already. */
|
|
||||||
int server; /* Server this query has last been sent to. */
|
|
||||||
struct query_server_info *server_info; /* per-server state */
|
|
||||||
int using_tcp;
|
|
||||||
int error_status;
|
|
||||||
int timeouts; /* number of timeouts we saw for this request */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Per-server state for a query */
|
|
||||||
struct query_server_info {
|
|
||||||
int skip_server; /* should we skip server, due to errors, etc? */
|
|
||||||
int tcp_connection_generation; /* into which TCP connection did we send? */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* An IP address pattern; matches an IP address X if X & mask == addr */
|
|
||||||
#define PATTERN_MASK 0x1
|
|
||||||
#define PATTERN_CIDR 0x2
|
|
||||||
|
|
||||||
struct apattern {
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct in_addr addr4;
|
|
||||||
struct in6_addr addr6;
|
|
||||||
} addr;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct in_addr addr4;
|
|
||||||
struct in6_addr addr6;
|
|
||||||
unsigned short bits;
|
|
||||||
} mask;
|
|
||||||
int family;
|
|
||||||
unsigned short type;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct rc4_key
|
|
||||||
{
|
|
||||||
unsigned char state[256];
|
|
||||||
unsigned char x;
|
|
||||||
unsigned char y;
|
|
||||||
} rc4_key;
|
|
||||||
|
|
||||||
struct ares_channeldata {
|
|
||||||
/* Configuration data */
|
|
||||||
int flags;
|
|
||||||
int timeout; /* in milliseconds */
|
|
||||||
int tries;
|
|
||||||
int ndots;
|
|
||||||
int rotate; /* if true, all servers specified are used */
|
|
||||||
int udp_port;
|
|
||||||
int tcp_port;
|
|
||||||
int socket_send_buffer_size;
|
|
||||||
int socket_receive_buffer_size;
|
|
||||||
char **domains;
|
|
||||||
int ndomains;
|
|
||||||
struct apattern *sortlist;
|
|
||||||
int nsort;
|
|
||||||
char *lookups;
|
|
||||||
|
|
||||||
int optmask; /* the option bitfield passed in at init time */
|
|
||||||
|
|
||||||
/* Server addresses and communications state */
|
|
||||||
struct server_state *servers;
|
|
||||||
int nservers;
|
|
||||||
|
|
||||||
/* ID to use for next query */
|
|
||||||
unsigned short next_id;
|
|
||||||
/* key to use when generating new ids */
|
|
||||||
rc4_key id_key;
|
|
||||||
|
|
||||||
/* Generation number to use for the next TCP socket open/close */
|
|
||||||
int tcp_connection_generation;
|
|
||||||
|
|
||||||
/* The time at which we last called process_timeouts(). Uses integer seconds
|
|
||||||
just to draw the line somewhere. */
|
|
||||||
time_t last_timeout_processed;
|
|
||||||
|
|
||||||
/* Last server we sent a query to. */
|
|
||||||
int last_server;
|
|
||||||
|
|
||||||
/* Circular, doubly-linked list of queries, bucketed various ways.... */
|
|
||||||
/* All active queries in a single list: */
|
|
||||||
struct list_node all_queries;
|
|
||||||
/* Queries bucketed by qid, for quickly dispatching DNS responses: */
|
|
||||||
#define ARES_QID_TABLE_SIZE 2048
|
|
||||||
struct list_node queries_by_qid[ARES_QID_TABLE_SIZE];
|
|
||||||
/* Queries bucketed by timeout, for quickly handling timeouts: */
|
|
||||||
#define ARES_TIMEOUT_TABLE_SIZE 1024
|
|
||||||
struct list_node queries_by_timeout[ARES_TIMEOUT_TABLE_SIZE];
|
|
||||||
|
|
||||||
ares_sock_state_cb sock_state_cb;
|
|
||||||
void *sock_state_cb_data;
|
|
||||||
|
|
||||||
ares_sock_create_callback sock_create_cb;
|
|
||||||
void *sock_create_cb_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* return true if now is exactly check time or later */
|
|
||||||
int ares__timedout(struct timeval *now,
|
|
||||||
struct timeval *check);
|
|
||||||
/* add the specific number of milliseconds to the time in the first argument */
|
|
||||||
int ares__timeadd(struct timeval *now,
|
|
||||||
int millisecs);
|
|
||||||
/* return time offset between now and (future) check, in milliseconds */
|
|
||||||
long ares__timeoffset(struct timeval *now,
|
|
||||||
struct timeval *check);
|
|
||||||
void ares__rc4(rc4_key* key,unsigned char *buffer_ptr, int buffer_len);
|
|
||||||
void ares__send_query(ares_channel channel, struct query *query,
|
|
||||||
struct timeval *now);
|
|
||||||
void ares__close_sockets(ares_channel channel, struct server_state *server);
|
|
||||||
int ares__get_hostent(FILE *fp, int family, struct hostent **host);
|
|
||||||
int ares__read_line(FILE *fp, char **buf, int *bufsize);
|
|
||||||
void ares__free_query(struct query *query);
|
|
||||||
unsigned short ares__generate_new_id(rc4_key* key);
|
|
||||||
struct timeval ares__tvnow(void);
|
|
||||||
int ares__expand_name_for_response(const unsigned char *encoded,
|
|
||||||
const unsigned char *abuf, int alen,
|
|
||||||
char **s, long *enclen);
|
|
||||||
#if 0 /* Not used */
|
|
||||||
long ares__tvdiff(struct timeval t1, struct timeval t2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARES_SWAP_BYTE(a,b) \
|
|
||||||
{ unsigned char swapByte = *(a); *(a) = *(b); *(b) = swapByte; }
|
|
||||||
|
|
||||||
#define SOCK_STATE_CALLBACK(c, s, r, w) \
|
|
||||||
do { \
|
|
||||||
if ((c)->sock_state_cb) \
|
|
||||||
(c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#ifdef CURLDEBUG
|
|
||||||
/* This is low-level hard-hacking memory leak tracking and similar. Using the
|
|
||||||
libcurl lowlevel code from within library is ugly and only works when
|
|
||||||
c-ares is built and linked with a similarly debug-build libcurl, but we do
|
|
||||||
this anyway for convenience. */
|
|
||||||
#include "../lib/memdebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __ARES_PRIVATE_H */
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_PROCESS 3 "25 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_process \- Process events for name resolution
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B void ares_process(ares_channel \fIchannel\fP, fd_set *\fIread_fds\fP,
|
|
||||||
.B fd_set *\fIwrite_fds\fP)
|
|
||||||
.fi
|
|
||||||
.PP
|
|
||||||
.B void ares_process_fd(ares_channel \fIchannel\fP,
|
|
||||||
.B ares_socket_t \fIread_fd\fP,
|
|
||||||
.B ares_socket_t \fIwrite_fd\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The \fBares_process(3)\fP function handles input/output events and timeouts
|
|
||||||
associated with queries pending on the name service channel identified by
|
|
||||||
.IR channel .
|
|
||||||
The file descriptor sets pointed to by \fIread_fds\fP and \fIwrite_fds\fP
|
|
||||||
should have file descriptors set in them according to whether the file
|
|
||||||
descriptors specified by \fIares_fds(3)\fP are ready for reading and writing.
|
|
||||||
(The easiest way to determine this information is to invoke
|
|
||||||
.B select
|
|
||||||
with a timeout no greater than the timeout given by \fIares_timeout(3)\fP ).
|
|
||||||
.PP
|
|
||||||
The
|
|
||||||
.B ares_process
|
|
||||||
function will invoke callbacks for pending queries if they complete
|
|
||||||
successfully or fail.
|
|
||||||
|
|
||||||
\fBares_process_fd(3)\fP works the same way but acts and operates only on the
|
|
||||||
specific file descriptors (sockets) you pass in to the function. Use
|
|
||||||
ARES_SOCKET_BAD for "no action". This function is of course provided to allow
|
|
||||||
users of c-ares to void select() in their applications and within c-ares.
|
|
||||||
.SS EXAMPLE
|
|
||||||
The following code fragment waits for all pending queries on a channel
|
|
||||||
to complete:
|
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
.nf
|
|
||||||
int nfds, count;
|
|
||||||
fd_set readers, writers;
|
|
||||||
struct timeval tv, *tvp;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FD_ZERO(&readers);
|
|
||||||
FD_ZERO(&writers);
|
|
||||||
nfds = ares_fds(channel, &readers, &writers);
|
|
||||||
if (nfds == 0)
|
|
||||||
break;
|
|
||||||
tvp = ares_timeout(channel, NULL, &tv);
|
|
||||||
count = select(nfds, &readers, &writers, NULL, tvp);
|
|
||||||
ares_process(channel, &readers, &writers);
|
|
||||||
}
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_fds (3),
|
|
||||||
.BR ares_timeout (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
1170
ares/ares_process.c
1170
ares/ares_process.c
File diff suppressed because it is too large
Load Diff
@@ -1,147 +0,0 @@
|
|||||||
.\" $Id$
|
|
||||||
.\"
|
|
||||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
.\"
|
|
||||||
.\" Permission to use, copy, modify, and distribute this
|
|
||||||
.\" software and its documentation for any purpose and without
|
|
||||||
.\" fee is hereby granted, provided that the above copyright
|
|
||||||
.\" notice appear in all copies and that both that copyright
|
|
||||||
.\" notice and this permission notice appear in supporting
|
|
||||||
.\" documentation, and that the name of M.I.T. not be used in
|
|
||||||
.\" advertising or publicity pertaining to distribution of the
|
|
||||||
.\" software without specific, written prior permission.
|
|
||||||
.\" M.I.T. makes no representations about the suitability of
|
|
||||||
.\" this software for any purpose. It is provided "as is"
|
|
||||||
.\" without express or implied warranty.
|
|
||||||
.\"
|
|
||||||
.TH ARES_QUERY 3 "24 July 1998"
|
|
||||||
.SH NAME
|
|
||||||
ares_query \- Initiate a single-question DNS query
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <ares.h>
|
|
||||||
.PP
|
|
||||||
.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
|
|
||||||
.B int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
|
|
||||||
.PP
|
|
||||||
.B void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP,
|
|
||||||
.B int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP,
|
|
||||||
.B void *\fIarg\fP)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.B ares_query
|
|
||||||
function initiates a single-question DNS query on the name service
|
|
||||||
channel identified by
|
|
||||||
.IR channel .
|
|
||||||
The parameter
|
|
||||||
.I name
|
|
||||||
gives the query name as a NUL-terminated C string of period-separated
|
|
||||||
labels optionally ending with a period; periods and backslashes within
|
|
||||||
a label must be escaped with a backslash. The parameters
|
|
||||||
.I dnsclass
|
|
||||||
and
|
|
||||||
.I type
|
|
||||||
give the class and type of the query using the values defined in
|
|
||||||
.BR <arpa/nameser.h> .
|
|
||||||
When the query is complete or has failed, the ares library will invoke
|
|
||||||
.IR callback .
|
|
||||||
Completion or failure of the query may happen immediately, or may
|
|
||||||
happen during a later call to
|
|
||||||
.BR ares_process (3)
|
|
||||||
or
|
|
||||||
.BR ares_destroy (3).
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I arg
|
|
||||||
is copied from the
|
|
||||||
.B ares_query
|
|
||||||
argument
|
|
||||||
.IR arg .
|
|
||||||
The callback argument
|
|
||||||
.I status
|
|
||||||
indicates whether the query succeeded and, if not, how it failed. It
|
|
||||||
may have any of the following values:
|
|
||||||
.TP 19
|
|
||||||
.B ARES_SUCCESS
|
|
||||||
The query completed successfully.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENODATA
|
|
||||||
The query completed but contains no answers.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EFORMERR
|
|
||||||
The query completed but the server claims that the query was
|
|
||||||
malformatted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ESERVFAIL
|
|
||||||
The query completed but the server claims to have experienced a
|
|
||||||
failure. (This code can only occur if the
|
|
||||||
.B ARES_FLAG_NOCHECKRESP
|
|
||||||
flag was specified at channel initialization time; otherwise, such
|
|
||||||
responses are ignored at the
|
|
||||||
.BR ares_send (3)
|
|
||||||
level.)
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTFOUND
|
|
||||||
The query completed but the queried-for domain name was not found.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOTIMP
|
|
||||||
The query completed but the server does not implement the operation
|
|
||||||
requested by the query. (This code can only occur if the
|
|
||||||
.B ARES_FLAG_NOCHECKRESP
|
|
||||||
flag was specified at channel initialization time; otherwise, such
|
|
||||||
responses are ignored at the
|
|
||||||
.BR ares_send (3)
|
|
||||||
level.)
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EREFUSED
|
|
||||||
The query completed but the server refused the query. (This code can
|
|
||||||
only occur if the
|
|
||||||
.B ARES_FLAG_NOCHECKRESP
|
|
||||||
flag was specified at channel initialization time; otherwise, such
|
|
||||||
responses are ignored at the
|
|
||||||
.BR ares_send (3)
|
|
||||||
level.)
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EBADNAME
|
|
||||||
The query name
|
|
||||||
.I name
|
|
||||||
could not be encoded as a domain name, either because it contained a
|
|
||||||
zero-length label or because it contained a label of more than 63
|
|
||||||
characters.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ETIMEOUT
|
|
||||||
No name servers responded within the timeout period.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ECONNREFUSED
|
|
||||||
No name servers could be contacted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_ENOMEM
|
|
||||||
Memory was exhausted.
|
|
||||||
.TP 19
|
|
||||||
.B ARES_EDESTRUCTION
|
|
||||||
The name service channel
|
|
||||||
.I channel
|
|
||||||
is being destroyed; the query will not be completed.
|
|
||||||
.PP
|
|
||||||
The callback argument
|
|
||||||
.I timeouts
|
|
||||||
reports how many times a query timed out during the execution of the
|
|
||||||
given request.
|
|
||||||
.PP
|
|
||||||
If the query completed (even if there was something wrong with it, as
|
|
||||||
indicated by some of the above error codes), the callback argument
|
|
||||||
.I abuf
|
|
||||||
points to a result buffer of length
|
|
||||||
.IR alen .
|
|
||||||
If the query did not complete,
|
|
||||||
.I abuf
|
|
||||||
will be NULL and
|
|
||||||
.I alen
|
|
||||||
will be 0.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR ares_process (3)
|
|
||||||
.SH AUTHOR
|
|
||||||
Greg Hudson, MIT Information Systems
|
|
||||||
.br
|
|
||||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this
|
|
||||||
* software and its documentation for any purpose and without
|
|
||||||
* fee is hereby granted, provided that the above copyright
|
|
||||||
* notice appear in all copies and that both that copyright
|
|
||||||
* notice and this permission notice appear in supporting
|
|
||||||
* documentation, and that the name of M.I.T. not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
* M.I.T. makes no representations about the suitability of
|
|
||||||
* this software for any purpose. It is provided "as is"
|
|
||||||
* without express or implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_H
|
|
||||||
# include <arpa/nameser.h>
|
|
||||||
#else
|
|
||||||
# include "nameser.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
|
||||||
# include <arpa/nameser_compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ares.h"
|
|
||||||
#include "ares_dns.h"
|
|
||||||
#include "ares_private.h"
|
|
||||||
|
|
||||||
struct qquery {
|
|
||||||
ares_callback callback;
|
|
||||||
void *arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen);
|
|
||||||
|
|
||||||
void ares__rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len)
|
|
||||||
{
|
|
||||||
unsigned char x;
|
|
||||||
unsigned char y;
|
|
||||||
unsigned char* state;
|
|
||||||
unsigned char xorIndex;
|
|
||||||
short counter;
|
|
||||||
|
|
||||||
x = key->x;
|
|
||||||
y = key->y;
|
|
||||||
|
|
||||||
state = &key->state[0];
|
|
||||||
for(counter = 0; counter < buffer_len; counter ++)
|
|
||||||
{
|
|
||||||
x = (unsigned char)((x + 1) % 256);
|
|
||||||
y = (unsigned char)((state[x] + y) % 256);
|
|
||||||
ARES_SWAP_BYTE(&state[x], &state[y]);
|
|
||||||
|
|
||||||
xorIndex = (unsigned char)((state[x] + state[y]) % 256);
|
|
||||||
|
|
||||||
buffer_ptr[counter] = (unsigned char)(buffer_ptr[counter]^state[xorIndex]);
|
|
||||||
}
|
|
||||||
key->x = x;
|
|
||||||
key->y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct query* find_query_by_id(ares_channel channel, unsigned short id)
|
|
||||||
{
|
|
||||||
unsigned short qid;
|
|
||||||
struct list_node* list_head;
|
|
||||||
struct list_node* list_node;
|
|
||||||
DNS_HEADER_SET_QID(((unsigned char*)&qid), id);
|
|
||||||
|
|
||||||
/* Find the query corresponding to this packet. */
|
|
||||||
list_head = &(channel->queries_by_qid[qid % ARES_QID_TABLE_SIZE]);
|
|
||||||
for (list_node = list_head->next; list_node != list_head;
|
|
||||||
list_node = list_node->next)
|
|
||||||
{
|
|
||||||
struct query *q = list_node->data;
|
|
||||||
if (q->qid == qid)
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* a unique query id is generated using an rc4 key. Since the id may already
|
|
||||||
be used by a running query (as infrequent as it may be), a lookup is
|
|
||||||
performed per id generation. In practice this search should happen only
|
|
||||||
once per newly generated id
|
|
||||||
*/
|
|
||||||
static unsigned short generate_unique_id(ares_channel channel)
|
|
||||||
{
|
|
||||||
unsigned short id;
|
|
||||||
|
|
||||||
do {
|
|
||||||
id = ares__generate_new_id(&channel->id_key);
|
|
||||||
} while (find_query_by_id(channel, id));
|
|
||||||
|
|
||||||
return (unsigned short)id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ares_query(ares_channel channel, const char *name, int dnsclass,
|
|
||||||
int type, ares_callback callback, void *arg)
|
|
||||||
{
|
|
||||||
struct qquery *qquery;
|
|
||||||
unsigned char *qbuf;
|
|
||||||
int qlen, rd, status;
|
|
||||||
|
|
||||||
/* Compose the query. */
|
|
||||||
rd = !(channel->flags & ARES_FLAG_NORECURSE);
|
|
||||||
status = ares_mkquery(name, dnsclass, type, channel->next_id, rd, &qbuf,
|
|
||||||
&qlen);
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
{
|
|
||||||
if (qbuf != NULL) free(qbuf);
|
|
||||||
callback(arg, status, 0, NULL, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
channel->next_id = generate_unique_id(channel);
|
|
||||||
|
|
||||||
/* Allocate and fill in the query structure. */
|
|
||||||
qquery = malloc(sizeof(struct qquery));
|
|
||||||
if (!qquery)
|
|
||||||
{
|
|
||||||
ares_free_string(qbuf);
|
|
||||||
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
qquery->callback = callback;
|
|
||||||
qquery->arg = arg;
|
|
||||||
|
|
||||||
/* Send it off. qcallback will be called when we get an answer. */
|
|
||||||
ares_send(channel, qbuf, qlen, qcallback, qquery);
|
|
||||||
ares_free_string(qbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen)
|
|
||||||
{
|
|
||||||
struct qquery *qquery = (struct qquery *) arg;
|
|
||||||
unsigned int ancount;
|
|
||||||
int rcode;
|
|
||||||
|
|
||||||
if (status != ARES_SUCCESS)
|
|
||||||
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Pull the response code and answer count from the packet. */
|
|
||||||
rcode = DNS_HEADER_RCODE(abuf);
|
|
||||||
ancount = DNS_HEADER_ANCOUNT(abuf);
|
|
||||||
|
|
||||||
/* Convert errors. */
|
|
||||||
switch (rcode)
|
|
||||||
{
|
|
||||||
case NOERROR:
|
|
||||||
status = (ancount > 0) ? ARES_SUCCESS : ARES_ENODATA;
|
|
||||||
break;
|
|
||||||
case FORMERR:
|
|
||||||
status = ARES_EFORMERR;
|
|
||||||
break;
|
|
||||||
case SERVFAIL:
|
|
||||||
status = ARES_ESERVFAIL;
|
|
||||||
break;
|
|
||||||
case NXDOMAIN:
|
|
||||||
status = ARES_ENOTFOUND;
|
|
||||||
break;
|
|
||||||
case NOTIMP:
|
|
||||||
status = ARES_ENOTIMP;
|
|
||||||
break;
|
|
||||||
case REFUSED:
|
|
||||||
status = ARES_EREFUSED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
|
|
||||||
}
|
|
||||||
free(qquery);
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user