Comparar commits
888 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| ed1cc99506 | |||
| f66cb26c58 | |||
| 707412d1b6 | |||
| a7ebdc5453 | |||
| dc35957f63 | |||
| 0711483bb7 | |||
| f4f5ff1887 | |||
| 33a4fa3203 | |||
| 8b22412e55 | |||
| 92d721d9d0 | |||
| 0f06d0b8ce | |||
| e321ec4c6f | |||
| 2f2892ff08 | |||
| 1dd559e80e | |||
| b7fb1b7e5a | |||
| eb60877793 | |||
| 5907ce0a02 | |||
| 5a1d431e51 | |||
| 0552c4a001 | |||
| 96d017869a | |||
| ddc2688af8 | |||
| baa60b6198 | |||
| 8abdddf11a | |||
| 9141018b27 | |||
| 3370fecdf2 | |||
| 5e91f76f0f | |||
| 557b3e1c93 | |||
| 3f65e56ccd | |||
| 5bd2cba2c2 | |||
| 3de7eb58a7 | |||
| 41eb294ce6 | |||
| ba94f2ebe0 | |||
| 7912248950 | |||
| 5d27c255b3 | |||
| 80e86e3b83 | |||
| 3a759f1eea | |||
| a09e503f19 | |||
| da4524b05c | |||
| 1a98283709 | |||
| acca8c5ac9 | |||
| 55eabb84e4 | |||
| 90ba9fce2a | |||
| 76b3982ddd | |||
| c946f80d5b | |||
| 8d350c7d99 | |||
| 7cd7fb8d6c | |||
| b12e563340 | |||
| 9c0aadce1e | |||
| b8d538b1b4 | |||
| 0219cd71b9 | |||
| 899fcbdfcc | |||
| 79fed6e32f | |||
| 55263ca11d | |||
| fe1f4a3bac | |||
| dd4fda55b5 | |||
| 2aae506110 | |||
| aae54a6f41 | |||
| 89da58adec | |||
| 57ef003eb9 | |||
| d378a64096 | |||
| 58ac91bc10 | |||
| 97602c0bf8 | |||
| 8523c487c1 | |||
| 3580b58bf6 | |||
| 9b26a4d5ce | |||
| c43fc68bc8 | |||
| df07539331 | |||
| 563931750b | |||
| 6b090de7b1 | |||
| d8863ef95f | |||
| 36f9595ce7 | |||
| 48565e6305 | |||
| 3727f9583b | |||
| 4a6bbf0b3c | |||
| 7513a7157f | |||
| e7dbdb6ead | |||
| db5f101bfc | |||
| 3c06e8b6fd | |||
| 28f94cbd0b | |||
| 6f37cbd946 | |||
| 396281263b | |||
| a00e8ac201 | |||
| b1772a89c1 | |||
| 58f07ff045 | |||
| 12f99d4fc7 | |||
| 05da0a6877 | |||
| 46ce871f34 | |||
| 4b22c2f044 | |||
| 4014828eff | |||
| bc87a62d59 | |||
| f6862442d3 | |||
| bff7f57eb8 | |||
| e19024ca0d | |||
| 73997e4799 | |||
| ffa97aa438 | |||
| d08244dfd8 | |||
| 2e0d367045 | |||
| 0f1fb2e6a1 | |||
| 672e362ed8 | |||
| bcae16c441 | |||
| 19b8f5cb59 | |||
| 68b37156d8 | |||
| d9237b64c0 | |||
| da037b38e3 | |||
| 62f864f4ab | |||
| bf89f1d37d | |||
| 3dc986e609 | |||
| 2f5e874201 | |||
| 05291932f8 | |||
| 72aa450ecb | |||
| 926ea21fe0 | |||
| 657a077cdb | |||
| 9a90f56845 | |||
| 7d36e0d63b | |||
| 865d5ed7a1 | |||
| 9dd91ee17e | |||
| 425ea821d7 | |||
| bea5049a2f | |||
| eae1e34696 | |||
| e63b6b00bc | |||
| e5b3ed226b | |||
| d5ce354c87 | |||
| e280838989 | |||
| 2309054b1f | |||
| 9dcc44a76b | |||
| 7a417c6d3b | |||
| 425ab15ae1 | |||
| c75ff4f118 | |||
| 75d3dd19ec | |||
| 4cd556555e | |||
| feebe921af | |||
| 92929308bd | |||
| ca4f14b555 | |||
| a7bcfacbd9 | |||
| e097b4820d | |||
| 566ec7974c | |||
| c735d6c420 | |||
| cf54ca9551 | |||
| 9f1da1b562 | |||
| f5a3dbf82b | |||
| 89f83e796a | |||
| 977a9e49c5 | |||
| 7ee0a4b39f | |||
| 4268e3a1d2 | |||
| 860b9a266a | |||
| c39d752ccb | |||
| 15db1cf385 | |||
| 38d684d1e6 | |||
| ccb1bc514b | |||
| 27c46a2c8e | |||
| ff2f1d237a | |||
| 402f4c162c | |||
| 81013a98b4 | |||
| 971dd622c7 | |||
| 0045d31e2d | |||
| caef8f4ebc | |||
| 6116c1ae71 | |||
| 03ecf2b0bb | |||
| d4a5005273 | |||
| 7522f29f0a | |||
| 09f0a2e4a6 | |||
| aa846929f3 | |||
| b378af7cb1 | |||
| 8b549a487f | |||
| 005f659eaa | |||
| a5aad94f24 | |||
| 52a6926da3 | |||
| b3c0f003bb | |||
| 3d2360bc56 | |||
| 1267f51d8c | |||
| e7328001a4 | |||
| fc7b53e809 | |||
| 50637cb3c2 | |||
| 11b4203874 | |||
| 60beb432eb | |||
| 64331c9cf0 | |||
| 00088d4093 | |||
| 472f3660e0 | |||
| 3c13cc8c4d | |||
| 0792ac8eee | |||
| 4952af4ffe | |||
| 3fcca7ef56 | |||
| e93244fef2 | |||
| acf75ce7fe | |||
| 7560b6e53d | |||
| f5346bbec2 | |||
| 41958889fb | |||
| d439a7811d | |||
| 4951c00d23 | |||
| 202cd0d45e | |||
| 1502db6095 | |||
| e8eea9e68e | |||
| 396eb9f283 | |||
| 378f400226 | |||
| 37e02dfbd5 | |||
| dce66ec8ec | |||
| 2fef67a08d | |||
| 50a17583c7 | |||
| bfe2c7df83 | |||
| b3186dde12 | |||
| 628a33eb76 | |||
| 4373e66b1e | |||
| 2e67b0ad9f | |||
| a4cbe0635f | |||
| 8563419280 | |||
| 0974bd4a90 | |||
| e1d47adc99 | |||
| e5e171d913 | |||
| 1e313227b8 | |||
| 8d45a9e0cd | |||
| 95568d76d3 | |||
| d4a3442468 | |||
| e262de22ea | |||
| 49243f1891 | |||
| 1a099ba549 | |||
| 2367133b4f | |||
| c648a1933d | |||
| 598acf08da | |||
| 208a8dee90 | |||
| e9fb299565 | |||
| 17a514ecd0 | |||
| 38ac62cedd | |||
| ce280731af | |||
| 751fb57f71 | |||
| be7d90abbf | |||
| d59585dd4f | |||
| 7a695707a2 | |||
| 4e590c9450 | |||
| b069d1c9e9 | |||
| 9fa1f7b981 | |||
| 4a68e4cd9d | |||
| 8320b6fd7c | |||
| e40cf0a1c4 | |||
| 19106985d7 | |||
| 3d817c54da | |||
| ca31877107 | |||
| f5f9afefb0 | |||
| d42863603e | |||
| 2c19cf3e31 | |||
| e7dc918c6a | |||
| 64c9e8212a | |||
| 499c39f13d | |||
| bccdae735b | |||
| 58120730a5 | |||
| 5b8db8a680 | |||
| 0acfd583c8 | |||
| 402b7ef67e | |||
| 6944871c42 | |||
| b60da35689 | |||
| 5204feddb1 | |||
| 68156df66b | |||
| a9e8b27285 | |||
| b8f470ddbd | |||
| 9d075dd1d1 | |||
| 4b802c6f60 | |||
| 8ce9344dd0 | |||
| cb2b386791 | |||
| 7ee4681c10 | |||
| 82c0ea9df2 | |||
| 9070d80880 | |||
| 45c53caf94 | |||
| c4947618c1 | |||
| 941ed59c37 | |||
| d76bbec1ab | |||
| f5a1d98cf9 | |||
| b0e6d837f0 | |||
| b1cfb1b733 | |||
| 26a1212546 | |||
| 03b05aaae9 | |||
| f41c87d7c9 | |||
| b74deb5e35 | |||
| 240e2db637 | |||
| 441947b6a4 | |||
| 194bdaffcd | |||
| db6e9ff4c6 | |||
| 57261a1164 | |||
| 0b116bb409 | |||
| a5ad2e5de2 | |||
| b6928ff6c0 | |||
| 4b03dd321c | |||
| f7eefbd3d7 | |||
| b23f7f9b27 | |||
| b95bc7e4c4 | |||
| 1593c0c347 | |||
| c154663455 | |||
| 13bc1901dc | |||
| 4f28322ac2 | |||
| 756e2ced8b | |||
| 1dc78b5209 | |||
| 3464093273 | |||
| 4487214494 | |||
| 6d7e222946 | |||
| d12a6a3178 | |||
| ed9d609c35 | |||
| b86f359d93 | |||
| 02080dfcf8 | |||
| 2768d25884 | |||
| 7bdf9896d2 | |||
| 3b4f84ded8 | |||
| 69abc52731 | |||
| 1671b1fb8b | |||
| 8735f4ef5c | |||
| 86967b5786 | |||
| ca8ceeb130 | |||
| 41d6f8eeea | |||
| 27b7805608 | |||
| fef39f7013 | |||
| b414b54c6b | |||
| ccdbb20ad0 | |||
| eb7e47bf29 | |||
| 53988c7184 | |||
| 9092b2bdc5 | |||
| 068353aa5b | |||
| 95a17ddbf0 | |||
| 6c8c455f5b | |||
| 282032e178 | |||
| af63e6a80d | |||
| a46ba0da29 | |||
| f7738bf65b | |||
| bb11d1fe37 | |||
| d02a2deb52 | |||
| 46105d849d | |||
| f16b6c3482 | |||
| a9cb497045 | |||
| d529a34ecb | |||
| 5394029dc5 | |||
| 28247737ca | |||
| 6448c2d8fb | |||
| 4460ccc8ec | |||
| 2b02a3c533 | |||
| 6705513b86 | |||
| 4bd8d12481 | |||
| ccaf3c283b | |||
| ce4276a0cb | |||
| 709e316e56 | |||
| e46635d6ab | |||
| 0af8677ba4 | |||
| 9ab13daf09 | |||
| 17977fbabc | |||
| 83854047b7 | |||
| 28e56fd587 | |||
| 29fc6308b8 | |||
| 14a7df128d | |||
| dd4ef89d0a | |||
| 830ec91cbf | |||
| aee2d55fab | |||
| 89ed7982e7 | |||
| 9f702c89ab | |||
| 2f76efd0f6 | |||
| fae18c72c3 | |||
| 1586f6ee2b | |||
| 4ce6214526 | |||
| e370e4b65e | |||
| 944de2d3f5 | |||
| f32146368d | |||
| 8d45e9b016 | |||
| 70227861ff | |||
| 20e542516b | |||
| 73ad21df73 | |||
| a67fe7e43d | |||
| a15ddd9f88 | |||
| b27f9bf930 | |||
| d5c28f98f1 | |||
| 16b283ed00 | |||
| 97b43889a1 | |||
| 05efa12411 | |||
| 3e60495232 | |||
| 45522b0710 | |||
| d67d25eb7b | |||
| 2538690fb4 | |||
| 4c23b2518e | |||
| 9daade9816 | |||
| 5f925f0070 | |||
| 38b0cd7780 | |||
| e46391042b | |||
| 553a03b05f | |||
| 24c1cc4efe | |||
| f6eabe7b58 | |||
| de2de1fdc7 | |||
| 8184ac8843 | |||
| a57d82d4cd | |||
| a266ef7337 | |||
| b30ca23180 | |||
| db5c8f00fc | |||
| d1bbacb06e | |||
| bff4e3b0fd | |||
| 14248ddbd9 | |||
| 391f39d291 | |||
| b4354efa8b | |||
| 686588a6e5 | |||
| 294267a605 | |||
| 7b53b9108b | |||
| 15be9ab501 | |||
| 7cfcd2daef | |||
| 6070429eec | |||
| b5f41ef6c7 | |||
| 716588a8fb | |||
| 95bc92f005 | |||
| 23425abe9d | |||
| 3bab5e1e78 | |||
| 79ed7e81b1 | |||
| a59e58cc94 | |||
| 72bd12e394 | |||
| 2c667ca016 | |||
| 209c4d724f | |||
| 95cf641f50 | |||
| 85750fd065 | |||
| 402b5c7f81 | |||
| be6f52b796 | |||
| f4e6c6ad94 | |||
| 99fe59cee9 | |||
| 0e80ba8b91 | |||
| 8965efdce1 | |||
| 1393a94804 | |||
| 52e558d877 | |||
| d9948105f1 | |||
| 87c91c1c04 | |||
| f15e471371 | |||
| fc0a83933d | |||
| f1cf2fe218 | |||
| 7a5679cb65 | |||
| 571b4604db | |||
| 29e15a40db | |||
| 6fb2286fa4 | |||
| ab2f78c7b4 | |||
| f9b918a05b | |||
| a46cde174a | |||
| 6eee0f8741 | |||
| 28d31bb9f6 | |||
| 23128be17f | |||
| 130885fda7 | |||
| c4fc42f8f4 | |||
| 21e73c5fb9 | |||
| b635bf5591 | |||
| be594bb1f6 | |||
| 543e3fca98 | |||
| b385d76dc6 | |||
| 2adc88fec3 | |||
| 2a9e2ceb61 | |||
| 47fa804469 | |||
| f70c01eee7 | |||
| eb4ea07a2d | |||
| 55cd72baaa | |||
| 940076d101 | |||
| 93ebb9f7a9 | |||
| 1a17ea52d8 | |||
| 68bc0c0c7c | |||
| 0e7dd6b350 | |||
| b3b0bf3845 | |||
| ddc32f1e43 | |||
| c9de508a2c | |||
| fac68bca4e | |||
| eaf250c3c6 | |||
| 8b99772d29 | |||
| 862a32e97e | |||
| 6cfb84d6ee | |||
| 2fda7ca6f6 | |||
| f2aecb53bc | |||
| 05fdc2f17a | |||
| b9868b993c | |||
| 573d8eefd1 | |||
| 51d64f29e6 | |||
| a39ab60ae5 | |||
| ba9671fae5 | |||
| a9340f354d | |||
| f9d6b069f7 | |||
| c363d5790d | |||
| 15a50d2a26 | |||
| bffc188151 | |||
| e78205430c | |||
| 4ef76d4f85 | |||
| 967da46793 | |||
| 46899503bd | |||
| 2dcf0f774c | |||
| d669db0cab | |||
| f8aabcc50a | |||
| 4bb3ece8dc | |||
| 495a7765d2 | |||
| 225296f253 | |||
| 52e6900e7a | |||
| 557bff1465 | |||
| add32ac107 | |||
| f7699b98fb | |||
| 05a8ec1fec | |||
| 004e63c433 | |||
| 898f41b95a | |||
| 859a6a75aa | |||
| b90dae6448 | |||
| dc1ddf4cff | |||
| 46ef5d86c3 | |||
| ac63a6b125 | |||
| 72778c97df | |||
| b4b86081f9 | |||
| e4a47a4ca5 | |||
| 79c60f6d4e | |||
| 4c4d55e0dc | |||
| 9504416beb | |||
| 99586d9b3f | |||
| 65b19cbbd3 | |||
| 7b64f4443d | |||
| abb2e857be | |||
| df10745963 | |||
| 3d729595d1 | |||
| 96a38d1895 | |||
| b4c1390af8 | |||
| e9604ac212 | |||
| ea3a4b34ea | |||
| 79a0d92161 | |||
| b10c40260c | |||
| 9e056d2097 | |||
| 8a250c5994 | |||
| e311ac3269 | |||
| 28078a2d0c | |||
| 7def8c1bbf | |||
| 24ca11387e | |||
| bccc9583c1 | |||
| 9643747b17 | |||
| c695848092 | |||
| 5011613e4c | |||
| 6cc7f69a59 | |||
| db6678637b | |||
| 93892e12a2 | |||
| c196aab89d | |||
| 54a7718b88 | |||
| cec6e6175a | |||
| bc5036bd34 | |||
| 021826eb1b | |||
| facd071967 | |||
| 486e81ad77 | |||
| 872cd3d7c0 | |||
| ca9851b311 | |||
| 2fa0940d45 | |||
| 3485338386 | |||
| 786a821f3f | |||
| da1c9c5ea5 | |||
| 93d8cce7ac | |||
| 5086ba2a3b | |||
| 4cf8611dcd | |||
| 101e9d705a | |||
| 7d8bfa1b62 | |||
| 5dcf9e2f41 | |||
| cdf18b6c4d | |||
| 609ce3b6e0 | |||
| 3ba8be2e21 | |||
| 6b13a97ce4 | |||
| 130e40957e | |||
| a7b28317d7 | |||
| 29fcd0fdcf | |||
| 9d5f63e543 | |||
| 208c28ead2 | |||
| 447d5ee94b | |||
| bb443add17 | |||
| cb954773ed | |||
| 89749c7eb1 | |||
| 30146f8744 | |||
| a623f374b1 | |||
| b41584feb3 | |||
| 77d5bbb767 | |||
| 171d428d3a | |||
| 61254c6cc4 | |||
| 44b3a8952e | |||
| 0fc8c5e7e9 | |||
| 6d969eb92f | |||
| 26ea0f81ca | |||
| dc45e38f11 | |||
| 9d5db40d3f | |||
| 9e25d52679 | |||
| 1f98d4f6ff | |||
| b73883ce1d | |||
| 7af42da5d2 | |||
| cf75057b67 | |||
| e5b1841030 | |||
| 57325a22a5 | |||
| c640166cf8 | |||
| 4b4c362c03 | |||
| c71bfb1602 | |||
| 022e6349c1 | |||
| 917671ac9a | |||
| a108975d78 | |||
| 62d31c5902 | |||
| 5d28314ee3 | |||
| 1b22109f95 | |||
| e5c05bfd66 | |||
| 62e97858d7 | |||
| b9da9b977e | |||
| f121b6c039 | |||
| c48b13bc0a | |||
| 26abb9beb9 | |||
| 02cc7d53b7 | |||
| 67136b5986 | |||
| 58d5175fde | |||
| c511c4063e | |||
| 6429611b3c | |||
| 3cea53ddca | |||
| d661e58fc3 | |||
| e140b6e4e2 | |||
| e1025d9337 | |||
| f1acc483c3 | |||
| 0e25e979a2 | |||
| 0c129ff02e | |||
| 05234082a9 | |||
| bdc44962a1 | |||
| e96a59965e | |||
| 507f3fc74b | |||
| 22d997fcd9 | |||
| 89a98ca51b | |||
| 9834abe3ab | |||
| 54ffc2c138 | |||
| 4785c4f11e | |||
| 9d5b0deb61 | |||
| 9c0b540ddc | |||
| c124a9f2b8 | |||
| 8b0e08f9df | |||
| 9ee115d1a0 | |||
| a7ebf431a8 | |||
| d85330d54a | |||
| f8f93c7351 | |||
| ee1fd4944f | |||
| 5117fa06b8 | |||
| 2ac1552bf7 | |||
| 94c2647d25 | |||
| 6b2f067435 | |||
| 3e2471d0a0 | |||
| f0b1d33398 | |||
| bae955f7c5 | |||
| b747e71583 | |||
| 48160da4b7 | |||
| d17df6a9db | |||
| df7a9ec977 | |||
| f2157420f2 | |||
| ae9c56416f | |||
| 1dec6a541a | |||
| c75157ffd8 | |||
| fa77d03fea | |||
| 618f4c533c | |||
| 9b77631dd5 | |||
| 7aa22df1e2 | |||
| ee0ff79820 | |||
| ca772e8a9c | |||
| 8af05c14be | |||
| 20f230e910 | |||
| 8af51875b6 | |||
| a4ead757f6 | |||
| 0cc6bc9e2e | |||
| 00a551d2b1 | |||
| b6f1652aab | |||
| b304555389 | |||
| 456af457bb | |||
| e9cb67844d | |||
| ff12099078 | |||
| 4068c6da1a | |||
| 2f839a41c0 | |||
| d9c13aefe3 | |||
| 7bfa1c27bf | |||
| f6986352ee | |||
| 2eb51bbb13 | |||
| 77ef1e75c8 | |||
| ae11a9d77c | |||
| 30648be2ed | |||
| e5958a2a15 | |||
| 8d3b41ea4d | |||
| 2d7f82af75 | |||
| 9c93a94834 | |||
| 13a9861d18 | |||
| f7d1a91aad | |||
| 121b8e0a64 | |||
| 36ebf4a034 | |||
| 0a752616b7 | |||
| edd21a959b | |||
| dfe9779401 | |||
| d64bc68562 | |||
| f29a57ceb2 | |||
| 529c8e36f2 | |||
| 108abcdec4 | |||
| 1ae7d8373f | |||
| 8eb4860ec6 | |||
| 7ae188c42b | |||
| 125a65ee8a | |||
| 98c3353a07 | |||
| 683ba59fae | |||
| 38abd739d3 | |||
| df58c84b5a | |||
| 513bb215db | |||
| 77be329ed0 | |||
| 1f223fbe13 | |||
| c6a21ab661 | |||
| 6d59f0bd3f | |||
| 74972e267a | |||
| 6c2134ba0e | |||
| 7bf53b0588 | |||
| eaff635df5 | |||
| 88ad275b44 | |||
| fe6143ca49 | |||
| 724432aa02 | |||
| 9686a4b1bd | |||
| 7f8fab8ec0 | |||
| 5a985a143b | |||
| f9154f8c2e | |||
| 287879a7f5 | |||
| 3c82302545 | |||
| b331783c01 | |||
| 1882210db4 | |||
| 12bd185a9b | |||
| 3dbaa7984f | |||
| 40f00b1dcb | |||
| 98bb38cb03 | |||
| e1b4c8d616 | |||
| 5d7c015348 | |||
| a90e7c82b3 | |||
| 6c0c9e7d7c | |||
| 461b35f6ef | |||
| 81ca040918 | |||
| 5dc6bfb195 | |||
| b0d3657e56 | |||
| 822913c85f | |||
| ce0ac250e1 | |||
| 22e98986e5 | |||
| 3f7fc39362 | |||
| 024c845d06 | |||
| 4bb1e29cf3 | |||
| fa7bdc4fcd | |||
| ab0708340c | |||
| 34723a2e17 | |||
| d4c4d2bb13 | |||
| 80090df8e4 | |||
| 05dc68db7b | |||
| 1bcde2cbf2 | |||
| 9a5f5851ba | |||
| 8c7152bb9f | |||
| 5580e39447 | |||
| f29d58c0f0 | |||
| d69e62363e | |||
| 0e0af9dcaa | |||
| 85fee142b3 | |||
| a1b5a934f4 | |||
| 996b533634 | |||
| 11fab2e58e | |||
| 437df3b6d4 | |||
| 663c2fdbac | |||
| 4eb0e9f8aa | |||
| 00a17b60f8 | |||
| fb5f00db61 | |||
| 0105055c3e | |||
| efe147b731 | |||
| 9585302dc5 | |||
| 7432c0775b | |||
| 8666ac7b85 | |||
| 827cbfd03c | |||
| 64a5e8f236 | |||
| 6a60315011 | |||
| a234334f69 | |||
| d71acbd909 | |||
| 33e672d135 | |||
| a26a696e34 | |||
| c63827d5a0 | |||
| 998f9f6ad0 | |||
| 0e188d3bff | |||
| 4a0867c5f2 | |||
| 4fb1955303 | |||
| ef202cd8b8 | |||
| 3648b4539b | |||
| b78ac9355a | |||
| f023994074 | |||
| a47e77bdf9 | |||
| 13773c267d | |||
| deccbf6d9a | |||
| ec1f92c16a | |||
| 5436e605b0 | |||
| 949ae6a7aa | |||
| b957c563c6 | |||
| 36c73e1d64 | |||
| d8f0925466 | |||
| 77d1b2f648 | |||
| 7a82dd3baf | |||
| 7c5573199f | |||
| 55146b70bd | |||
| c2a26458e8 | |||
| 6be895f83c | |||
| fcae79eb9a | |||
| 9a342d979f | |||
| a48a7c321d | |||
| fd167bc19f | |||
| 11f794c9df | |||
| 30b353fabe | |||
| 61590a115c | |||
| 982dfbdd61 | |||
| 9a5605f5de | |||
| 5d62055838 | |||
| 3e886a8a5b | |||
| eb1d4736b0 | |||
| affcdf49f9 | |||
| 06a4a3f8af | |||
| eb58d23656 | |||
| ed2ee11af8 | |||
| 6ed833bf28 | |||
| 196e8af786 | |||
| 17aafbc595 | |||
| 1dcf8cf36c | |||
| 3fc6bc7e53 | |||
| fce337b823 | |||
| 6e3c4a856c | |||
| 05f44f3c62 | |||
| d609eed733 | |||
| 65c4e6ad94 | |||
| 6fc11568c0 | |||
| 494aa6e090 | |||
| abab91748c | |||
| f86ef41980 | |||
| a22191c1fb | |||
| db2a6b239e | |||
| 25726a3df9 | |||
| a95c4d673d | |||
| b6b53d7b83 | |||
| 573a5c6a53 | |||
| 7db8868043 | |||
| 7ee89a6e1d | |||
| 5e22b1cd27 | |||
| 2e5eee5092 | |||
| b341608130 | |||
| e6e8ffb1c3 | |||
| 60c851972e | |||
| dcfc552254 | |||
| 8bb92f5c19 | |||
| 0ca338ade0 | |||
| 272424d379 | |||
| 6d72f33da7 | |||
| c0fab06356 | |||
| 1423a7ce91 | |||
| 053a432804 | |||
| f50129baa3 | |||
| 9150e8f188 | |||
| b637ab3ceb | |||
| 32d38dd876 | |||
| a04f4bd4b2 | |||
| ad68219568 | |||
| af117d810d | |||
| 5d764abdc6 | |||
| a9e9c69265 | |||
| 461e86eb82 | |||
| 7e87ffa0fd | |||
| 7bfa698796 | |||
| 285f64ed62 | |||
| b13b1d7b70 | |||
| 212e0cd812 | |||
| 589a8e101d | |||
| b8b4169b1a | |||
| e8aac64083 | |||
| 8e3ae9bb85 | |||
| 14a549928f | |||
| 83e1fb715e | |||
| aeeac8e343 | |||
| 5fc6d50486 | |||
| edc7c111cb | |||
| 05a754bc92 | |||
| dff58c56fb | |||
| 58709a1d32 | |||
| 554567fa82 | |||
| 3ad51db9c2 | |||
| 007d74ee23 | |||
| cd15214d77 | |||
| 32eca24468 | |||
| a96e25ef5d | |||
| 5087fb1904 | |||
| 2c4af20cb0 | |||
| 78cdc63b76 | |||
| 6ef191563a | |||
| daf616be22 | |||
| 278dc84bb9 | |||
| 686a2931e6 | |||
| 5be5a0e417 | |||
| cd2d1dbb76 | |||
| 68a92623d0 | |||
| 81b3255577 | |||
| fc33a22f27 | |||
| 5267c76580 | |||
| 2908b993a3 | |||
| 1c172bf513 | |||
| aa037e4a0c | |||
| 10dd04e03c | |||
| 560f75c755 | |||
| f2ce65fb84 | |||
| eb1d463889 | |||
| 8d021cb29c | |||
| 70faac1b6a | |||
| abaf425a36 | |||
| 95a0333057 | |||
| a49bba636a | |||
| e252ef2cb2 |
@@ -0,0 +1,8 @@
|
||||
build
|
||||
build.eclipse
|
||||
build.number
|
||||
.metadata
|
||||
bin
|
||||
jnalib/contrib/ntservice/dist
|
||||
jnalib/contrib/platform/dist
|
||||
|
||||
Arquivo executável
+479
@@ -0,0 +1,479 @@
|
||||
Release 3.3.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Facilitate `Memory` subclasses (jbellis).
|
||||
* Allow multiple fields of the same type in Unions (Francis Barber).
|
||||
* Add `platform.win32.Advapi32.AdjustTokenPrivileges`, `platform.win32.Advapi32.LookupPrivilegeName`, `platform.win32.Advapi32.LookupPrivilegeValue`, `platform.win32.Advapi32.ImpersonateSelf`.
|
||||
* Add `platform.win32.Advapi32.DuplicateTokenEx`, `platform.win32.Advapi32.CreateProcessAsUser`, `platform.win32.Kernel32.GetExitCodeProcess`, `platform.win32.Kernel32.TerminateProcess`, `platform.win32.Kernel32.ReadFile`, `platform.win32.Kernel32.CreatePipe`, `platform.win32.Kernel32.SetHandleInformation` and related constants / structures in `platform.win32.WinBase` and `platform.win32.WinNT`. Please note that the `SECURITY_ATTRIBUTES` structure has been moved from `platform.win32.WinNT` to `platform.win32.WinBase`.
|
||||
* Add `platform.win32.Kernel32.DeleteFile` and `platform.win32.Kernel32Util.deleteFile`.
|
||||
* Add `platform.win32.Kernel32.GetFileAttributes` and `platform.win32.Kernel32Util.getFileAttributes`.
|
||||
* Add `platform.win32.Kernel32.GetTickCount`.
|
||||
* Add Win32 Service functions to `platform.win32.Advapi32`.
|
||||
* Add `platform.win32.W32ServiceManager` and `W32Service`.
|
||||
* Add Win32 Event Logging functions to `platform.win32.Advapi32` and `platform.win32.Advapi32Util.EventLogIterator`.
|
||||
* `platform.win32.Advapi32Util.registryCreateKey` returns `true` if key was created, `false` if it already exists.
|
||||
* Add `REG_BINARY`, `REG_EXPAND_SZ` and `REG_MULTI_SZ` support to `platform.win32.Advapi32Util` registry functions.
|
||||
* Reduce JNI crossings in a number of native methods, moving object creation out into pure Java code.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Move all native functions into `com.sun.jna.Native`, to ensure that all dependent classes must be disposed before the `Native` class is unloaded. Note that this change is incompatible with all previous JNA native libraries.
|
||||
* Fix `platform.win32.Kernel32.GetNativeSystemInfo` and `GetSystemInfo` AV on Win64.
|
||||
* Fix several potential minor bugs as reported by TvT.
|
||||
* Fix bug in Structure.StructureSet.toString (Blair Zajac), exposed by Tomcat ThreadLocal cleanup.
|
||||
* Fix several bugs when using Structure(Pointer) ctor and array fields (Samuel Audet).
|
||||
|
||||
Release 3.2.7
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add native peer value accessors for Pointer
|
||||
* The `jna.library.path` property is now re-evaluated whenever a native library is loaded. Previously this value was cached when the JNA classes loaded.
|
||||
* `Native.loadLibrary` can now load `.drv` files.
|
||||
* Refactor `com.sun.jna.platform.win32.WINBASE` into `WinDef`, `WinNT` and `BaseTSD`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.GDI32` into `WinGDI`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.User32` into `WinUser`, matching Windows SDK headers.
|
||||
* Refactor `platform.win32.WinNT.LARGE_INTEGER` into a union.
|
||||
* Add `platform.win32.ObjBase`, `com.sun.jna.platform.win32.Ole32.CoInitializeEx`, `CoUninitialize`, and `CoCreateInstance`.
|
||||
* Add `platform.win32.Oleaut32.SysAllocString` and `SysFreeString`.
|
||||
* Add `platform.win32.Secur32.ImpersonateSecurityContext` and `RevertSecurityContext`.
|
||||
* Add `platform.win32.WinNT.WELL_KNOWN_SID_TYPE`, `SECURITY_MAX_SID_SIZE` and other related SID-related constants.
|
||||
* Add `platform.win32.Advapi32.CreateWellKnownSid` and `IsWellKnownSid` and `com.sun.jna.platform.win32.Advapi32Util.isWellKnownSid`.
|
||||
* Add `platform.win32.Kernel32.GetVersion`, `GetVersionEx`, `GetSystemInfo`, `GetNativeSystemInfo`, `GlobalMemoryStatusEx`, `GetLogicalDriveStrings` and `IsWow64Process`.
|
||||
* Add `platform.win32.Kernel32Util.getLogicalDriveStrings`.
|
||||
* Add `platform.win32.User32.GetSystemMetrics`.
|
||||
* Add `platform.win32.BaseTSD.DWORD_PTR`.
|
||||
* Add `platform.win32.WinBase.SYSTEM_INFO` and `MEMORYSTATUSEX`.
|
||||
* Add `platform.win32.WinNT.OSVERSIONINFOEX`, `VER` constants.
|
||||
* Add `platform.win32.WinDef.ULONGLONG` and `DWORDLONG`.
|
||||
* Add `platform.win32.Shell32.SHGetDesktopFolder` (prep work for Com4JNA).
|
||||
* Add `platform.win32.Winspool.GetPrinterInfo`.
|
||||
* Add `platform.win32.WinspoolUtil.getPrinterInfo1`.
|
||||
* Add `platform.win32.GDI32.GetDeviceCaps`.
|
||||
* Add `platform.win32.GDI32.GetDIBits`.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix `ClassCastException` in `Structure.equals` (issue 152).
|
||||
* Fix bug initializing a structure object from existing memory when the structure has initialized fields (issue 133).
|
||||
* Fix NPE reading an array of string from a pointer when an element of the array is `NULL` (issue 151).
|
||||
* Avoid calling `UnregisterNatives` in native code (issue 154).
|
||||
* Compare unpacked library path against canonical (long) filename (issue 156).
|
||||
* Fix `read()` of uninitialized memory in `platform.win32.Advapi32Util.getTokenGroups` and `getTokenAccount`.
|
||||
* Fix `com.sun.jna.platform.win32.Secur32.QuerySecurityContextToken` to take a `CtxtHandle` instead of `PSecHandle`.
|
||||
* Fix definition of BITMAPINFO (platform/win32).
|
||||
|
||||
Release 3.2.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Split code in examples.jar into a contrib platform.jar package and individual packages for demos.
|
||||
* Fix Eclipse build and added Eclipse projects for all contrib samples, import projects from jnalib and contrib.
|
||||
* Ensure Structure fields correctly ordered when inherited.
|
||||
* Use explicit Structure field whenever provided, regardless of whether the VM requires it.
|
||||
* Add Win32 mappings for two dozen functions from Kernel32.dll, Advapi32.dll, Netapi32.dll, Secur32.dll, NtDll.dll, Ole32.dll, Shell32.dll and Crypt32.dll to com.sun.jna.platform.win32.
|
||||
* Port parts of WinError.h, WinNT.h, LMAccess.h, LMCons.h, LMErr.h, LMJoin.h, NTStatus.h, ShlObj.h, WinDef.h, ShellApi.h, Wdm.h, WinReg.h, WinCrypt.h, Sspi.h, Guid.h, NtSecApi.h and DsGetDc.h.
|
||||
* Add Win32 simplified utility interfaces Kernel32Util, Advapi32Util, Netapi32Util, Crypt32Util, NtDllUtil, Shell32Util, Ole32Util and Secur32Util to com.sun.jna.platform.win32.
|
||||
* Support unicode paths in W32FileUtils.
|
||||
* Fix exception during dispose in W32FileMonitor.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Provide String.replace for 1.4 compatibility.
|
||||
* Avoid allocating memory when Structure is provided a pointer in the ctor.
|
||||
* Ensure proper value returned in Pointer.getValue() for non-null, unchanged NIO Buffer values.
|
||||
* Use 1.4-compatible URI generation (issue 149).
|
||||
|
||||
Release 3.2.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Make Pointer ctor public.
|
||||
* Provide access to Function objects for arbitrary Pointer values.
|
||||
* Add linux/ia64 binaries (bpiwowar). See issue 134 patch.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Use a more robust method to decode a file-based URL (issue 135).
|
||||
|
||||
Release 3.2.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Include version information in code in case package information lost.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix WindowUtils exception on mouse over TrayIcon.
|
||||
* Fix bug toggling windows transparent/opaque (win32/OSX).
|
||||
* Avoid overwriting unchanged Pointer values in arrays (function calls with Pointer[] and Structure.read).
|
||||
* Ensure Structure fields marked `final` are never written.
|
||||
* Fix bug preventing proper population Structure.ByReference fields on Structure read.
|
||||
* Ensure double buffering is disabled in components added to a transparent window.
|
||||
* Fix UnsatisfiedLinkError attempting to load system libraries under Web Start.
|
||||
* Fix loading Web Start-provided libraries on OSX (libraries must have a .jnilib suffix under Web Start).
|
||||
* Properly include sources in Maven zip file (Issue 129).
|
||||
|
||||
Release 3.2.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Provide length-specified Pointer.getStringArray()
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix crash with direct mapping if NULL struct* used (Issue 125).
|
||||
* Fix case where null-valued Structure fields would get non-null values on write.
|
||||
* Synch callback Structure/Structure[] arguments on callback return.
|
||||
* Fix NPE when mapping an interface to the current process.
|
||||
* Automatically load proper C library version from current process on Linux (avoids crashing bug on Ubuntu with libc-i686 packages active).
|
||||
* Avoid scanning structure contents in Structure.toString if contents aren't actually used.
|
||||
|
||||
Release 3.2.1
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add HRESULT, LONG mapping to W32API (marc strapetz).
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix definition of HWND_BROADCAST in W32API.
|
||||
* Fix memory alignment checking (Issue 121).
|
||||
* Fix Structure equals/hashCode implementation, based on current Java fields rather than strictly native memory contents. Avoid using equals/hashCode when avoiding recursive reads/writes.
|
||||
|
||||
Release 3.2.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Handle String, Structure, Callback, Buffer, and primitive arrays in direct mappings. Handle NativeMapped and TypeMapper, with optimized paths for IntegerType and PointerType.
|
||||
* Optionally throw errno/GetLastError as an exception. This is preferred to (and more efficient than) calling Native.getLastError().
|
||||
* Unload/delete native library unpacked from jna.jar if Native class is garbage collected. Only install shutdown hook if using the system class loader.
|
||||
* Auto-write contiguous Structure arrays when first element is written.
|
||||
* Support NativeMapped[] as function arguments for interface-mapped libraries (Issue 90).
|
||||
* Enable function lookup within current process on Windows.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Restrict recursive structure reads/writes by thread instead of globally. This avoids potentially missed reads/writes with concurrent access (Issue 120).
|
||||
* Ensure Memory is not GC'd and freed if direct NIO buffers mapped to it are extant.
|
||||
* Allow types derived from java.nio.Buffer as Structure fields.
|
||||
|
||||
Release 3.1.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add raw JNI mapping of static Java methods. Performance is about 10X that of traditional JNA interface mapping, although with less type conversion functionality.
|
||||
* Add library option to allow passing/return of Java Objects.
|
||||
* Allow handling of uncaught callback exceptions (Issue 63).
|
||||
* Object oriented interface to X server (see contrib/x11)
|
||||
* Make Memory class more accessible.
|
||||
* Provide Structure ctor with Pointer argument (issue 102).
|
||||
* Allow implicit library access to current process on linux (issue 98).
|
||||
* Open all shared libraries with RTLD_GLOBAL, if applicable. This was the default behavior on OSX and changes the default behavior on linux.
|
||||
* Allow NIO Buffer as Structure field (with limitations) (Issue 57)
|
||||
* Add `size_t` size.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Run tests with libjsig.so, if available, which fixes some crashes when running tests on 64-bit platforms.
|
||||
* Fix Issue 104.
|
||||
* Fix Issue 94 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 51 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 95.
|
||||
* Fix Issue 101.
|
||||
* Fix Issue 111, memory leak with String-returning Callback.
|
||||
* Fix missing storage of union type information (affects usage of struct/union by value as argument and return type).
|
||||
* Remove non-functional Structure ctors requiring explicit size.
|
||||
|
||||
Release 3.0.9
|
||||
=============
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix issue 93 by only manually searching jna.library.path, then falling back to passing the mapped library name to dlopen/LoadLibrary. This fixes an issue in JRUBY where the incorrect libc.so.6 was being loaded.
|
||||
|
||||
Release 3.0.8
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Auto-map Pointer[]/String[]/WString[] return values.
|
||||
* Provide utility functions to convert String to primitive array.
|
||||
* Add jna.library.boot.path property to define the directory that the native stub library is loaded from
|
||||
|
||||
Release 3.0.7
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve Win32 loading of libraries with dependencies.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
|
||||
|
||||
Release 3.0.6
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
|
||||
* Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
|
||||
* Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
|
||||
* Add convenience methods to set active Union field and value simultaneously (xylo).
|
||||
* Augment Union read/writeField to set the active field.
|
||||
* Allow Structure auto-synch across native calls to be disabled.
|
||||
* Win64 support.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid overwriting unchanged Structure fields of type Pointer.
|
||||
* Avoid more content dragging on OSX or warn if it's too late.
|
||||
* Fix UnsatisfiedLinkError using transparent window on Win2K.
|
||||
* Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
|
||||
* Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
|
||||
* Ensure structure memory is allocated in Structure.read/writeField.
|
||||
|
||||
Release 3.0.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow explicit declaration of field order for VMs which have an unpredictable field order.
|
||||
* Check for w32 libraries with a "lib" prefix in addition to normal lookup.
|
||||
* Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
|
||||
* Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
|
||||
* Look up libraries using web start library path, if appropriate (Corey Puffalt).
|
||||
* Use constants to return integer boolean values.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly track cursor on alpha-masked windows.
|
||||
* Avoid searching /lib or /usr/lib on 64-bit Linux.
|
||||
* Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
|
||||
* Avoid transparent window events always dragging window bug on OSX.
|
||||
* Fix division by zero error calculating structure size on OSX/ppc.
|
||||
* Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
|
||||
* Fix NPE reading back into StringArray.
|
||||
|
||||
Release 3.0.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Automatically write contents of Structure.ByReference fields on Structure.write().
|
||||
* Use the actual parameter type in Function invocations if no parameter type information is available (whether method is missing or untyped varargs).
|
||||
* Augmented X11 library mappings (xylo).
|
||||
* Support read/write of NativeMapped arrays within Structure (notably NativeLong).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix library load error when /usr/lib32 and /usr/lib both exist (linux) (Marek Slama).
|
||||
* Avoid incorrect matches against libraries named with the same prefix (e.g. libc-client.so vs libc.so) (xylo).
|
||||
* Properly handle arrays of NativeMapped (e.g. NativeLong) as a Structure field (stefan endrullis).
|
||||
* Ensure structure size calculated prior to setting union active type.
|
||||
* XID is 64-bits on 64-bit X clients (xylo).
|
||||
* Ensure proper arch name is used on Debian (amd64 instead of x86_64).
|
||||
|
||||
Release 3.0.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Enable build/run using IBM's J9 VM (leonardo).
|
||||
* Make StdCallFunctionMapper attempt a leading underscore if the simpler mapping doesn't work.
|
||||
* Allow Structure.read to overwrite final fields (may not work on some 1.4 VMs).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix NPE when passing an array of Structure.ByReference.
|
||||
* Compare entire linux library version when finding a match.
|
||||
* Don't pass struct by value unless the method signature declares it.
|
||||
* Restrict custom first element structure alignment to OSX/ppc.
|
||||
* Improve performance and reduce memory footprint for window masks. Optimize polygon-based masks on w32. Use XFillRectangles on X11.
|
||||
* Fix linkage settings on sunos-amd64 to avoid relocation errors.
|
||||
* Fix callback allocation code on w32, solaris, freebsd, darwin (libffi was misconfigured).
|
||||
* Fix bug when NativeMapped fields are used in a Structure.ByValue instance.
|
||||
* Fix NPE calling Structure.read() before memory is initialized.
|
||||
* Fix NPE calling Structure.read/write with uninitialized NativeMapped fields.
|
||||
|
||||
Release 3.0.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Attempt to force unload of jnidispatch library prior to deleting it (w32).
|
||||
* Added amd64 targets for OSX, FreeBSD, and Solaris.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Reduce space allocated for invocation arguments.
|
||||
* Fix NPE when NativeMapped type is used in a Structure.
|
||||
* Fix some X11 type mappings for 64-bit.
|
||||
* Fix OSX Leopard/JRE1.5+ window transparency.
|
||||
* Fix window alpha compositing on X11.
|
||||
* Fix loading of libraries with unicode names on OSX.
|
||||
|
||||
Release 3.0.1
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve transparent window drawing performance on w32
|
||||
* Use closure allocation from libffi
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Ensure nested structure arrays initialized with Structure.toArray use the appropriate native memory.
|
||||
* Ensure structure size is calculated prior to converting to array
|
||||
* Avoid creating new windows when setting a window mask
|
||||
* Fix bug in Pointer.setChar.
|
||||
|
||||
Release 3.0
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* More supported platforms, via GCC's libffi (wmeissner)
|
||||
* Support struct by value as parameter and return value (duncan)
|
||||
* Support struct by reference within structures
|
||||
* Provide access to native peer for java.awt.Component
|
||||
* Provide access to native peer on OS X.
|
||||
* Support MINGW32 builds (fullung)
|
||||
* Allow per-field Structure read/write by field name
|
||||
* Avoid writing Structure fields marked 'volatile'
|
||||
* Read and wrap function pointers in Structure fields when read with a Java proxy to allow easy Java-side invocation (Ken Larson)
|
||||
* Support array-backed Buffers as arguments (wmeissner)
|
||||
* Auto-conversion of custom types (wmeissner)
|
||||
* Allow pointer type-safety
|
||||
* Optional VM crash protection, via Native.setProtected(boolean)
|
||||
* Auto-convert WString[]
|
||||
* Provide library synchronization wrapper similar to Collections.synchronizedX
|
||||
* Support lookup of OSX framework libraries by name
|
||||
* Explicit access to shared library global data
|
||||
* Invocation interception to facilitate translation of C preprocessor macros and inline functions
|
||||
* Provide utility to determine Web Start native library cache location; auto-include this path if jnidispatch is included as a <nativelib> (robertengels)
|
||||
* Provide access to aligned memory
|
||||
* Versioning information embedded in jna.jar and native library
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid attempts to free native library if it failed to load (wmeissner)
|
||||
* Explicitly check method signatures for varargs instead of heuristically guessing (wmeissner)
|
||||
* Disallow declaring Pointer-derived fields in Structures (Function, Memory)
|
||||
* Ensure Object.toString/hashCode/equals methods are intercepted on proxyied interfaces
|
||||
* Update X11 library for 64-bit use (wmeissner)
|
||||
* Properly map arrays of char*/wchar_t* under w32
|
||||
* Allow Pointer[] as a Structure field and Function argument
|
||||
* Fix some misleading Structure error messages
|
||||
* Properly preserve/return GetLastError/errno after native calls
|
||||
* Allocate executable memory on w32 to avoid errors with hardware-enforced data execution protection (DEP)
|
||||
* Fix VM crash on w32 stdcall callbacks
|
||||
* Use long offsets and sizes rather than ints (64-bit safe)
|
||||
* Properly clean up references and release closure memory on JNI_Unload
|
||||
* Use simpler AWT/JAWT library loading workaround
|
||||
* Avoid changing array references within a Structure on read
|
||||
|
||||
Release 2.5
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Unions
|
||||
* Optimized shaped windows (chris deckers & olivier chafik); instantiation time improved by about 2-3 orders of magnitude for large, mostly contiguous shapes
|
||||
* Provide type mapping in callback arguments/results
|
||||
* Provide access to ByteBuffer direct address as a Pointer
|
||||
* Provide customization of native string encoding with jna.encoding system property
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly handle VMs with reversed Structure member storage
|
||||
* Avoid making window undecorated when clearing window mask on X11
|
||||
* Fix structure alignment bug on OSX/PPC when first element is > 4 bytes in size
|
||||
* Clearing OSX window mask by setting to MASK_NONE now works properly
|
||||
* Avoid index exceptions if native buffers are not NUL-terminated on string conversions
|
||||
* Write initialized Structure[] argument memory prior to function calls
|
||||
* Fix IllegalArgumentException reading WString into a Structure
|
||||
* Clear memory when allocating a structure block (fixes VM crash)
|
||||
* Remove versioned JAWT dependency on OSX, allowing use on 10.3/JRE1.4.
|
||||
|
||||
Release 2.4
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Explicitly support unaligned structures
|
||||
* Auto-reallocate structure arrays
|
||||
* Automatic handling of w32 UNICODE/ASCII variants
|
||||
* Automatic mapping of decorated w32 stdcall function names
|
||||
* Customizable, automatic type conversion of arguments and results (wmeissner)
|
||||
* Support char*[] arguments as Java String[]
|
||||
* Structure supports Callback members (wmeissner)
|
||||
* getByteBuffer from Pointer/Memory (wmeissner)
|
||||
* Allow GC of native libraries
|
||||
* Facilitate use from non-Java contexts (JRuby et al.) (wmeissner)
|
||||
* Improve library path searching (wmeissner)
|
||||
* Handle Structure[] arguments
|
||||
* Handle native long arguments and return values
|
||||
* Handle direct and array-based ByteBuffer arguments (wmeissner)
|
||||
* Change default w32 build to use GCC (it's free, yo)
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Structure.toArray failed to initialize members
|
||||
* Disallow explicit free of Structure/Memory
|
||||
* Ensure native libraries are only loaded once until released
|
||||
* Properly handle NULL when the return value is a Structure
|
||||
* Proper conversion to wchar_t on linux
|
||||
* Copy full length of Java strings to C strings instead of stopping when a NUL character is encountered
|
||||
Arquivo executável
+504
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||

|
||||
|
||||
Java Native Access (JNA)
|
||||
========================
|
||||
|
||||
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
|
||||
|
||||
JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.
|
||||
|
||||
The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.
|
||||
|
||||
While some attention is paid to performance, correctness and ease of use take priority.
|
||||
|
||||
JNA includes a platform library with many native functions already mapped as well as a set of utility interfaces that simplify native access.
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
* Automatic mapping from Java to native functions, with simple mappings for all primitive data types
|
||||
* Runs on most platforms which support Java
|
||||
* Automatic conversion between C and Java strings, with customizable encoding/decoding
|
||||
* Structure and Union arguments/return values, by reference and by value
|
||||
* Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct
|
||||
* Auto-generated Java proxies for native function pointers
|
||||
* By-reference (pointer-to-type) arguments
|
||||
* Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer
|
||||
* Nested structures and arrays
|
||||
* Wide (wchar_t-based) strings
|
||||
* Native long support (32- or 64-bit as appropriate)
|
||||
* Demo applications
|
||||
* Supported on 1.4 or later JVMs (earlier VMs may work with stubbed NIO support)
|
||||
* Customizable marshalling/unmarshalling (argument and return value conversions)
|
||||
* Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros
|
||||
* Support for automatic Windows ASCII/UNICODE function mappings
|
||||
* Varargs support
|
||||
* Type-safety for native pointers
|
||||
* VM crash protection (optional)
|
||||
* Optimized direct mapping for high-performance applications.
|
||||
|
||||
Community
|
||||
=========
|
||||
|
||||
All questions should be posted ot the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
|
||||
|
||||
Using the Library
|
||||
=================
|
||||
|
||||
* [Getting Started](jna/tree/master/www/GettingStarted.md)
|
||||
* [Mapping between Java and Native](jna/tree/master/www/Mappings.md)
|
||||
* [Using Pointers and Arrays](jna/tree/master/www/PointersAndArrays.md)
|
||||
* [Using Structures and Unions](jna/tree/master/www/StructuresAndUnions.md)
|
||||
* [Using By-Reference Arguments](jna/tree/master/www/ByRefArguments.md)
|
||||
* [Customization](jna/tree/master/www/CustomMappings.md)
|
||||
* [Callbacks/Closures](jna/tree/master/www/CallbacksAndClosures.md)
|
||||
* [Dynamically Typed Languages (JRuby/Jython)](jna/tree/master/www/DynamicallyTypedLanguages.md)
|
||||
* [Platform Library](jna/tree/master/www/PlatformLibrary.md)
|
||||
* [Direct Method Mapping](jna/tree/master/www/DirectMapping.md)
|
||||
* [Frequently Asked Questions (FAQ)](jna/tree/master/www/FrequentlyAskedQuestions.md)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
You're encouraged to contribute to JNA. Fork the code from [github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
|
||||
|
||||
If you are interested in paid support, feel free to say so on the [jna-users mailing list](http://groups.google.com/group/jna-users). Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is provided under the LGPL, version 2.1 or later.
|
||||
|
||||
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<project name="jna" basedir="." default="default">
|
||||
<target name="recurse">
|
||||
<ant dir="jnalib" target="${ant.target}" />
|
||||
</target>
|
||||
<target name="default">
|
||||
<antcall target="recurse">
|
||||
<param name="ant.target" value="default" />
|
||||
</antcall>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<antcall target="recurse">
|
||||
<param name="ant.target" value="clean" />
|
||||
</antcall>
|
||||
</target>
|
||||
<target name="test">
|
||||
<antcall target="recurse">
|
||||
<param name="ant.target" value="test" />
|
||||
</antcall>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="lib" path="lib/junit.jar" sourcepath="/DEV/junit/src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jna</name>
|
||||
<name>jnalib</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#Wed Aug 29 20:43:29 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -0,0 +1,3 @@
|
||||
#Tue Mar 27 21:18:08 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
Arquivo executável
+33
@@ -0,0 +1,33 @@
|
||||
* RELATED and/or SIMILAR PROJECTS:
|
||||
* Feel free to add notes and/or descriptions here (this should probably go
|
||||
* on a wiki somewhere).
|
||||
----
|
||||
* nlink.dev.java.net:
|
||||
pros: simple definitions (same as jna)
|
||||
cons: w32 only
|
||||
* sf.net/projects/jnative:
|
||||
cons: boilerplate, manual code generation by calling setup methods
|
||||
pros: callbacks, byref args?
|
||||
* JNIWrapper: kinda like jnative (commercial), includes platform "packs"
|
||||
* coroutine for Java, like jnative (commercial)
|
||||
* jnieasy: c++ mappings (http://www.innowhere.com:8080/webapp/jsp/products/jnieasy/index.jsp?_page=products.jnieasy)
|
||||
* j2native (www.smardec.com)
|
||||
* j-interop.sf.net
|
||||
* jawinproject.sf.net (COM DLL access)
|
||||
* jacob-project.sf.net (COM DLL access)
|
||||
* nativecall.sf.net (minimal)
|
||||
* cxxwrap.sf.net
|
||||
* J/Direct (defunct)
|
||||
* NoodleGlue
|
||||
* SWIG
|
||||
* ctypes4j.sf.net
|
||||
* ctypes-java (out of date)
|
||||
* jnbridge
|
||||
* xFunction (http://excelsior-usa.com/xfunction.html, commercial, osx)
|
||||
* JACE c++ mappings
|
||||
* JAW Java API wrapper http://www.aplu.ch/home/apluhome.jsp?site=5
|
||||
|
||||
# OTHER REFERENCES
|
||||
# JNI options: http://staff.develop.com/halloway/JavaWin32.html
|
||||
# List of JNI alternatives: http://weblog.janek.org/Archive/2005/07/28/AlternativestoJavaNativeI.html
|
||||
|
||||
+196
-89
@@ -1,65 +1,80 @@
|
||||
# DESIGN GOALS/REQUIREMENTS
|
||||
o no permanent references to java objects in native code (hard to get rid of)
|
||||
this means no java object arguments to callbacks; use some sort of integer
|
||||
key instead (hashcode?) callbacks can hold local data anyway...
|
||||
o make simplest Java usage map to most common C usage
|
||||
- additional constructs provided for less-common cases
|
||||
(WString,Structure.ByValue/ByReference)
|
||||
o structure is treated as a pointer, except within a struct
|
||||
o primitive types are passed directly
|
||||
o arrays are treated as pointers, except within a struct
|
||||
- in structure (inline; otherwise pointer-to-X should be used)
|
||||
- as function argument (auto-convert to pointer via Memory)
|
||||
o pointer to type in struct should use Pointer or ByReference
|
||||
o "free" should be invisible wherever possible
|
||||
|
||||
# FUTURE DEMOS:
|
||||
* test keyboard keys' state (needs OSX)
|
||||
* get system process information, basic process control
|
||||
* additional file utilities (meta info, free space, etc)
|
||||
* enforce window minimum/maximum size (workaround java bug)
|
||||
|
||||
# TODO:
|
||||
# TODO
|
||||
|
||||
* review/use refactor nativelibrary/function
|
||||
* review/use ByteBuffer everywhere
|
||||
* fix setFieldOrder to *always* apply if used
|
||||
* cache structure information
|
||||
|
||||
* make direct calls call back *once* to Java where conversion is required,
|
||||
and process all arguments from there (instead of potentially swapping back
|
||||
and forth multipel times). This also makes it easer to perform conversions
|
||||
(no native changes required).
|
||||
|
||||
* design:
|
||||
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
|
||||
|
||||
o no permanent references to java objects in native code (hard to get rid of)
|
||||
this means no java object arguments to callbacks; use some sort of integer
|
||||
key instead (hashcode?) callbacks can hold local data anyway...
|
||||
o make simplest Java usage map to most common C usage
|
||||
- additional constructs provided for esoteric cases (WString)
|
||||
o structure is treated as a pointer, except within a struct
|
||||
o primitive types are passed directly
|
||||
o arrays are treated as pointers, except within a struct
|
||||
- in structure (inline; otherwise pointer-to-X should be used)
|
||||
- as function argument (auto-convert to pointer via Memory)
|
||||
- pointer to type in struct should be handled with Pointer
|
||||
- how to do pointer to struct in struct? (Pointer to start with)
|
||||
o "free" should be invisible wherever possible
|
||||
* auto-convert struct pointers in callback args to Java Structure
|
||||
(may need a proxy wrapper around callback to avoid excessive JNI)
|
||||
* per-library jna.library.path: many libraries have a "standard" location (or
|
||||
several); let the library author indicate what these are (X11, for example)
|
||||
* return array of struct (annotation to indicate which argument has the
|
||||
length of the returned value might be nice)
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be avilable in GraphicsDevice->getIDstring
|
||||
* split unit tests
|
||||
* universal OSX build w/cross-compile (callbacks fail)
|
||||
* universal GCC build w/cross-compile
|
||||
* catch native crash/exception/faults and re-throw as java exception
|
||||
* use libffi from gcc to handle calls and callbacks?
|
||||
or move callback asm templates into dispatch_<arch>.c
|
||||
* auto-generate stdcall decorated symbols (try if undecorated lookup fails)
|
||||
* make Pointer free-able (system allocates memory, client frees it); actually,
|
||||
this should probably be automatic so the user doesn't have to think about it.
|
||||
Maybe a custom type representing "function-allocated-pointer" or
|
||||
"pointer-requiring-free" (which is just Memory).
|
||||
* callbacks need a dispose if they are to live beyond the lifetime of the
|
||||
function to which they are passed; maybe a simpler callback interface for
|
||||
transient callbacks, and require callback+dispose for most callbacks?
|
||||
TransientCallback: callback
|
||||
NonTransientCallback: callback+dispose
|
||||
* ppc64 direct/raw failures (multiple)
|
||||
|
||||
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
|
||||
now
|
||||
|
||||
* combine direct and interface mapping calling code where possible
|
||||
|
||||
* make native dll extraction from jar public, to use with user dlls packaged
|
||||
in a jar
|
||||
|
||||
* Callback.PostCallWrite.write() cf PostCallRead
|
||||
|
||||
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
|
||||
|
||||
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
|
||||
Can use annotations as shorthand to initialize a map, but basically set up a
|
||||
per-NativeLibrary (or per-Function?) map of methods to mappers.
|
||||
|
||||
Requires separate compilation of annotation handling.
|
||||
|
||||
* ditch type conversion context (?)
|
||||
|
||||
* packaging: 'types', 'convert/marshal' subpackages?
|
||||
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
|
||||
explicit, since marshal/unmarshal doesn't indicate src/dst.
|
||||
o moving conversion contexts to subpackage cleans up top level
|
||||
substantially, but we probably don't want to move things like Structure and
|
||||
Pointer into a types subpackage (which would leave just a few top-level
|
||||
classes). Javadoc is cluttered by example classes anyway.
|
||||
|
||||
* support annotations of parameters and return values w/o breaking
|
||||
1.4 compatibility (retroweaver?), e.g.
|
||||
-- retroweaver (requires retroweaver runtime classes to provide annotation
|
||||
features) not yet worth doing
|
||||
|
||||
void my_function(@MarshalAs(off_t)long arg);
|
||||
|
||||
trading off cruft in the interface def to avoid cruft in the usage:
|
||||
|
||||
my_function(0) versus my_function(new off_t(0))
|
||||
|
||||
this only really applies to NativeLong/IntegerType types that want to use a
|
||||
primitive value instead of creating an object instance.
|
||||
|
||||
* return Pointer.SIZE/LONG_SIZE in bits (for consistency with 1.5)
|
||||
* use proxy for callbacks to enable auto-conversion of arguments and/or return
|
||||
value (in java-land instead of C-land).
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* how to do direct struct argument (vs struct pointer) (uncommon)?
|
||||
* how to do struct return (vs struct pointer) (uncommon)?
|
||||
* more tests for argument types (2 args, all permutations of basic data types)
|
||||
ensures native stack handling is done properly
|
||||
* flag string(/wstring)-returning methods which need to free their result
|
||||
to avoid leaking memory whan auto-creating strings from the result
|
||||
(since normally we don't take explicit ownership of any returned pointers)
|
||||
@@ -70,26 +85,121 @@ transient callbacks, and require callback+dispose for most callbacks?
|
||||
Maybe make function return "Memory", which can then be converted to a
|
||||
Structure or some other type. Then memory will free itself when no longer
|
||||
referenced.
|
||||
* unions (copy-on-call is problematic: which member is active?) must require
|
||||
explicit write, either per member or whole object before export
|
||||
* verify get/set methods vs read/write is for performance (Pointer)?
|
||||
* type safety between returned and passed in pointers (w32 API)
|
||||
* bitfields et al. for structs
|
||||
* auto-convert strings in w32 functions ending in 'W'? would this introduce
|
||||
any ambiguity?
|
||||
* use annotations + result codes + GetLastError/errno/errstr to auto-generate
|
||||
* make Pointer free-able (system allocates memory, client frees it); actually,
|
||||
this should probably be automatic so the user doesn't have to think about it.
|
||||
Maybe a custom type representing "function-allocated-pointer" or
|
||||
"pointer-requiring-free" (which is just Memory). For now, leave it up to
|
||||
the user to manage the pointer, since they have to define the free method
|
||||
anyway. use could always put a finalizer on a PointerType-derived type.
|
||||
* universal GCC build w/cross-compile (needs cross compilers...)
|
||||
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
|
||||
Long.SIZE, Integer.SIZE, et al.
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* bitfields for structs (how?)
|
||||
|
||||
|
||||
# DONE
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* check Structure "final" fields; should never write back to native memory
|
||||
* OSX ObjC access (see rococoa)
|
||||
* do Structure.write for any callback args
|
||||
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
|
||||
methods out of Structure, to be used by Function w/NativeMapped[] parameter
|
||||
|
||||
* if method has "GetLastErrorException/ErrnoException" in its signature, use
|
||||
result codes + GetLastError/errno/errstr to auto-generate
|
||||
runtime exceptions? (cf P/Invoke; also useful for X11 return types)
|
||||
provide annotation/custom invocation handler/hook to examine return value and
|
||||
throw and exception if the return value indicates an error
|
||||
throw an exception if the return value indicates an error
|
||||
|
||||
o are error return values consistent (if so, a single handler works)?
|
||||
if null -> call GetLastError
|
||||
if nonzero ?
|
||||
o otherwise, need an ExceptionOnZero, ExceptionOnNonZero runtime, from which
|
||||
derive GetLastError/ErrnoExceptionOnZero/NZ
|
||||
* verify get/set methods vs read/write for performance (Pointer)?
|
||||
(see RawTest for performance comparisons)
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
|
||||
* embed version in DLL ('depends'-done)/so (symlink?)
|
||||
* use libffi closure allocation/deallocation
|
||||
|
||||
* ensure Library options are passed to NativeFunctionHandler
|
||||
(needs getLibraryOptions(Class cls))
|
||||
|
||||
* handle array of Structure.ByReference as parameter/return value (cf Pointer[])
|
||||
* test performance of setByte/getByte and pass pointer field directly if it
|
||||
makes sense to do so (done, halves access time to use pointer field directly,
|
||||
slight variations on 1.4/1.5/1.6).
|
||||
* test callback arg/return value for callback type
|
||||
* structure by value in callback
|
||||
|
||||
* call native to fix up FFIType on creation (avoid multithreading problems)
|
||||
properly handle union by value (or punt; must pass union field instead)
|
||||
|
||||
* hash javah-generated headers; when changed, invalidate platform-specific
|
||||
|
||||
* add main class which spits out version information
|
||||
|
||||
* docs: split pages: FAQ
|
||||
FAQ: J2ME, new platform builds, stdcall
|
||||
|
||||
# DONE
|
||||
* struct by reference within structure
|
||||
* struct by value
|
||||
(how to do struct value return (vs struct pointer) (uncommon)?)
|
||||
(how to do struct value argument (vs struct pointer) (uncommon)?)
|
||||
* use appropriate size_t and off_t sizes (use long offsets everywhere in
|
||||
Pointer)
|
||||
* Callback/function pointer as return value (e.g. signal())
|
||||
* type safety between returned and passed in pointers (w32 API); advantage of
|
||||
deriving from Pointer is that type mapping can be made automatic, without an
|
||||
explicit type mapping defined.
|
||||
* catch native crash/exception/faults and re-throw as java exception
|
||||
this is mostly for debugging a new mapping to avoid crashing the VM
|
||||
could do setjmp/longjmp on *nix and catch C++ exception on w32
|
||||
* NativeMapped: provide interface to automatically convert custom Java
|
||||
type to/from native types.
|
||||
* update X11 libs for 64-bit
|
||||
* use libffi from gcc to handle calls and callbacks?
|
||||
or move callback asm templates into dispatch_<arch>.c
|
||||
* more tests for argument types (2 args, all permutations of basic data types)
|
||||
ensures native stack handling is done properly (handled by libffi)
|
||||
* universal OSX build w/cross-compile (hard to do with libffi)
|
||||
* use jna.encoding property to affect string encoding instead of just using
|
||||
the system default encoding.
|
||||
* change/augment getWindowHandle0 to provide any heavyweight component window
|
||||
* unions (copy-on-call is problematic: which member is active?) must require
|
||||
explicit write, either per member or whole object before export
|
||||
* rename Argument/Result Converter to be fromNative/toNative
|
||||
* split unit tests
|
||||
* auto-convert struct pointers in callback args to Java Structure
|
||||
(may need a proxy wrapper around callback to avoid excessive JNI)
|
||||
use proxy for callbacks to enable auto-conversion of arguments and/or return
|
||||
value (in java-land instead of C-land).
|
||||
* review/use refactor nativelibrary/function
|
||||
* auto-generate stdcall decorated symbols (try if undecorated lookup fails)
|
||||
* per-library jna.library.path: many libraries have a "standard" location (or
|
||||
several); let the library author indicate what these are (X11, for example)
|
||||
* return array of struct (annotation to indicate which argument has the
|
||||
length of the returned value might be nice) (this can now be done with a
|
||||
type mapper)
|
||||
* callbacks need a dispose if they are to live beyond the lifetime of the
|
||||
function to which they are passed; maybe a simpler callback interface for
|
||||
transient callbacks, and require callback+dispose for most callbacks?
|
||||
TransientCallback: callback
|
||||
NonTransientCallback: callback+dispose
|
||||
(callback is disposed when no longer referenced; user must ensure callback
|
||||
is not GC'd until it is removed as a native callback)
|
||||
* auto-convert strings in w32 functions ending in 'W'? would this introduce
|
||||
any ambiguity?
|
||||
* Dispose/unload library on GC (use ref queue)
|
||||
* fix dnd on linux (no hole?) (mostly fixed, still some artifacts)
|
||||
* transparent/shaped drag image
|
||||
@@ -138,33 +248,30 @@ transient callbacks, and require callback+dispose for most callbacks?
|
||||
void setWindowMask(Window w, Shape clip);
|
||||
// needs:
|
||||
int findNativeWindow(Window w);
|
||||
|
||||
#MAYBE NOT
|
||||
* should structure offsets be 64-bit? technically yes, but in practice I don't
|
||||
think a structure that big actually works.
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
o when used as struct fields, could allow detection of field order by order
|
||||
of initialization (requires all-or-nothing usage, though)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
|
||||
# SIMILAR PROJECTS:
|
||||
# nlink.dev.java.net:
|
||||
# pros: simple definitions (same as jna)
|
||||
# cons: w32 only
|
||||
# sf.net/projects/jnative:
|
||||
# cons: boilerplate, manual code generation by calling setup methods
|
||||
# pros: callbacks, byref args?
|
||||
# JNIWrapper: kinda like jnative (commercial), includes platform "packs"
|
||||
# coroutine for Java, like jnative (commercial)
|
||||
# jnieasy: c++ mappings (http://www.innowhere.com:8080/webapp/jsp/products/jnieasy/index.jsp?_page=products.jnieasy)
|
||||
# j2native (www.smardec.com)
|
||||
# j-interop.sf.net
|
||||
# jawinproject.sf.net
|
||||
# nativecall.sf.net (minimal)
|
||||
# cxxwrap.sf.net
|
||||
# xFunction (osx)
|
||||
# J/Direct (defunct)
|
||||
# NoodleGlue
|
||||
# SWIG
|
||||
# ctypes4j.sf.net
|
||||
# ctypes-java (out of date)
|
||||
# jnbridge
|
||||
# xFunction (http://excelsior-usa.com/xfunction.html, commercial)
|
||||
# libffi (now part of GCC) (this might be useful as the dispatch layer)
|
||||
# JACE c++ mappings
|
||||
# JNI options: http://staff.develop.com/halloway/JavaWin32.html
|
||||
# JAW Java API wrapper http://www.aplu.ch/home/apluhome.jsp?site=5
|
||||
# List of JNI alternatives: http://weblog.janek.org/Archive/2005/07/28/AlternativestoJavaNativeI.html
|
||||
|
||||
|
||||
+446
-116
@@ -12,63 +12,145 @@
|
||||
-->
|
||||
|
||||
<!-- global properties -->
|
||||
<!-- (all build-related props should go in dynamic-properties) -->
|
||||
<!-- (all build-related props should go in -dynamic-properties) -->
|
||||
<property name="name" value="jna"/>
|
||||
<property name="jar" value="${name}.jar"/>
|
||||
<property name="testjar" value="${name}-test.jar"/>
|
||||
<property name="debug" value="true"/>
|
||||
<property name="debug.native" value="false"/>
|
||||
<property name="cflags_extra.native" value=""/>
|
||||
<property name="dynlink.native" value="false"/>
|
||||
<property name="native" location="native"/>
|
||||
<property name="src" location="src"/>
|
||||
<property name="platform.src" location="contrib/platform/src"/>
|
||||
<property name="contrib" location="contrib"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="test.src" location="test"/>
|
||||
<property name="doc" location="doc"/>
|
||||
<property name="stylesheet" location="${doc}/api/doc/css/javadoc.css"/>
|
||||
<property name="company" value="Technomage"/>
|
||||
<property name="company.full" value="Timothy Wall"/>
|
||||
<property name="javadoc" location="${doc}/javadoc"/>
|
||||
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
|
||||
<property name="vendor" value="JNA Development Team"/>
|
||||
<property name="copyright"
|
||||
value="Copyright &copy; 2007 ${company.full}. All Rights Reserved."/>
|
||||
value="Copyright &copy; 2007-2010 Timothy Wall. All Rights Reserved."/>
|
||||
<buildnumber/>
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="3"/>
|
||||
<property name="jna.revision" value="0"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
<property name="jni.major" value="3"/>
|
||||
<property name="jni.minor" value="3"/>
|
||||
<property name="jni.revision" value="0"/>
|
||||
<property name="jni.build" value="${build.number}"/>
|
||||
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
|
||||
<property name="jni.md5" value="4c69bcf40b30785215211b5a5dad211e"/>
|
||||
<property name="spec.title" value="Java Native Access (JNA)"/>
|
||||
<property name="spec.vendor" value="${vendor}"/>
|
||||
<property name="spec.version" value="${jna.major}"/>
|
||||
<property name="impl.title" value="com.sun.jna"/>
|
||||
<property name="impl.vendor" value="${spec.vendor}"/>
|
||||
<property name="impl.version" value="${jna.version} (b${jna.build})"/>
|
||||
|
||||
<!-- Software release version -->
|
||||
<property name="version" value="2.4"/>
|
||||
<property name="jdk" value="1.4"/>
|
||||
<property name="compatibility" value="1.4"/>
|
||||
<property name="test.compatibility" value="1.5"/>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<property name="build.compiler.emacs" value="true"/>
|
||||
|
||||
<target name="default" depends="test" description="Build and Test."/>
|
||||
|
||||
<target name="dynamic-properties">
|
||||
<echo>Java version: ${java.version}, compatibility: ${jdk}</echo>
|
||||
<echo>Build ${version}</echo>
|
||||
<property name="build" location="build"/>
|
||||
<!-- uncomment for netbeans profiling -->
|
||||
<!--<import file="nbproject/profiler-build-impl.xml"/>-->
|
||||
<target name="init" depends="-setup"/>
|
||||
<target name="compile-test-single" depends="compile-tests"/>
|
||||
<target name="compile-single" depends="compile"/>
|
||||
|
||||
<target name="-dynamic-properties">
|
||||
<echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
|
||||
<echo>JNA version ${jna.version}, native ${jni.version}</echo>
|
||||
<echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
|
||||
<echo>java.home=${java.home}</echo>
|
||||
<echo>java.library.path=${java.library.path}</echo>
|
||||
|
||||
<replaceregexp match="(<version>).*(</version>)"
|
||||
replace="\1${jna.version}\2"
|
||||
file="pom.xml"/>
|
||||
<replaceregexp match='VERSION = ".*";'
|
||||
replace='VERSION = "${jna.version}";'
|
||||
file="src/com/sun/jna/Native.java"/>
|
||||
|
||||
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
|
||||
<isset property="omit-jnilib"/>
|
||||
</condition>
|
||||
<condition property="vm.arch" value="-d64" else="">
|
||||
<or>
|
||||
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
|
||||
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
|
||||
<os arch="x86_64"/>
|
||||
<os arch="ppc64"/>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="amd64"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
|
||||
<and>
|
||||
<os name="SunOS"/>
|
||||
<equals arg1="${vm.arch}" arg2="-d64"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="build" value="build${vm.arch}"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="eclipse.classes" location="build.eclipse/classes"/>
|
||||
<property name="test.classes" location="${build}/test-classes"/>
|
||||
<property name="reports" value="${build}/reports"/>
|
||||
|
||||
<!-- Add other supported platforms here -->
|
||||
<condition property="jre.arch" value="i386">
|
||||
<equals arg1="x86" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<condition property="jre.arch" value="amd64">
|
||||
<equals arg1="x86_64" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<property name="jre.arch" value="${os.arch}"/>
|
||||
<condition property="os.prefix" value="linux-${jre.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="win32-${os.arch}">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="linux-${os.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="darwin-${os.arch}">
|
||||
<!-- Darwin builds are universal, no arch required -->
|
||||
<condition property="os.prefix" value="darwin">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="sunos-${os.arch}">
|
||||
<os family="unix" arch="sparc"/>
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch})"/>
|
||||
<condition property="os.prefix" value="freebsd-${os.arch}">
|
||||
<os name="FreeBSD"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="openbsd-${os.arch}">
|
||||
<os name="OpenBSD"/>
|
||||
</condition>
|
||||
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
|
||||
<condition property="jdk.home" value="${java.home}">
|
||||
<available file="${java.home}/include"/>
|
||||
</condition>
|
||||
<condition property="jdk.home" value="${java.home}/..">
|
||||
<available file="${java.home}/../include"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
|
||||
|
||||
<condition property="jdk.home" value="/System/Library/Frameworks/JavaVM.framework/Home">
|
||||
<available file="/System/Library/Frameworks/JavaVM.framework/Headers"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="Can't find JNI headers (java.home=${java.home})"/>
|
||||
<condition property="libjsig"
|
||||
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
|
||||
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
|
||||
</condition>
|
||||
<property name="native.jar" value="${os.prefix}.jar"/>
|
||||
<property name="build.native" location="${build}/native"/>
|
||||
<property name="md5.file" location="${build.native}/sig"/>
|
||||
|
||||
<mkdir dir="${build}"/>
|
||||
<mkdir dir="${build.native}"/>
|
||||
@@ -79,8 +161,8 @@
|
||||
|
||||
</target>
|
||||
|
||||
<target name="setup" depends="dynamic-properties">
|
||||
<path id="compile-test.path">
|
||||
<target name="-setup" depends="-dynamic-properties">
|
||||
<path id="compile-test.path">
|
||||
<pathelement path="${test.src}"/>
|
||||
<path id="test.libs">
|
||||
<fileset dir="lib">
|
||||
@@ -92,23 +174,24 @@
|
||||
<path id="src.path">
|
||||
<pathelement location="${src}"/>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
|
||||
<path id="test.runpath">
|
||||
<pathelement path="${build}/${jar}"/>
|
||||
<pathelement path="${build}/examples.jar"/>
|
||||
<pathelement path="${test.classes}"/>
|
||||
<pathelement path="${ant.home}/lib/clover.jar"/>
|
||||
<pathelement path="lib/clover.jar"/>
|
||||
<path refid="test.libs"/>
|
||||
</path>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="setup"
|
||||
<target name="compile" depends="-setup"
|
||||
description="Compile all Java source">
|
||||
<javac classpathref="compile.path"
|
||||
source="${jdk}"
|
||||
target="${jdk}"
|
||||
source="${compatibility}"
|
||||
target="${compatibility}"
|
||||
destdir="${classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${src}"/>
|
||||
</javac>
|
||||
@@ -120,42 +203,50 @@
|
||||
<patternset id="jar-compiled">
|
||||
<include name="com/sun/jna/*"/>
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
<exclude name="com/sun/jna/examples/*"/>
|
||||
<exclude name="com/sun/jna/examples/**/*"/>
|
||||
</patternset>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
</target>
|
||||
<target name="jar" depends="setup,compile-tests,native,:jar" unless="-jar"
|
||||
<target name="jar" depends="-setup,native,:jar" unless="-jar"
|
||||
description="Build primary jar">
|
||||
<jar jarfile="${build}/${jar}">
|
||||
<manifest>
|
||||
<attribute name="Implementation-Vendor" value="${company.full}"/>
|
||||
<attribute name="Implementation-Version" value="${version}"/>
|
||||
<attribute name="Specification-Vendor" value="${company.full}"/>
|
||||
<attribute name="Specification-Version" value="${version}"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!-- OSGi Bundle attributes -->
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="com.sun.jna*"/>
|
||||
</section>
|
||||
</manifest>
|
||||
<fileset dir="${classes}"><patternset refid="jar-compiled"/></fileset>
|
||||
<fileset dir="${classes}" excludes="${jar.omitted}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
<target name="examples-jar" depends="jar,native-jar">
|
||||
<jar jarfile="${build}/examples.jar">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="jna.jar"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
|
||||
</manifest>
|
||||
<fileset dir="${src}" includes="**/examples/**/*.png"/>
|
||||
<fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
|
||||
<fileset dir="${classes}" includes="jnidispatch.dll"/>
|
||||
</jar>
|
||||
</target>
|
||||
<target name="native-jar" depends="native,jar"
|
||||
description="Build native jar">
|
||||
<!-- For web start, native libraries need to be in a separate jar file -->
|
||||
<!-- at the root -->
|
||||
<jar jarfile="${build}/${native.jar}">
|
||||
<fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</jar>
|
||||
|
||||
<target name="contrib-jars" depends="jar" description="Build contrib jars">
|
||||
<subant target="jar">
|
||||
<property name="file.reference.jna.build" location="${build}"/>
|
||||
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
|
||||
<property name="libs.junit.classpath" location="lib/junit.jar"/>
|
||||
<!-- platform.jar needs to be built first -->
|
||||
<fileset dir="${contrib}" includes="platform/build.xml" />
|
||||
<fileset dir="${contrib}" includes="*/build.xml" excludes="platform/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="javah" depends="compile">
|
||||
@@ -165,11 +256,92 @@
|
||||
<class name="com.sun.jna.Memory"/>
|
||||
<class name="com.sun.jna.Native"/>
|
||||
<class name="com.sun.jna.NativeLibrary"/>
|
||||
<class name="com.sun.jna.CallbackReference"/>
|
||||
</javah>
|
||||
<condition property="grep" value="/usr/sfw/bin/ggrep">
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<condition property="grep" value="ggrep">
|
||||
<os name="OpenBSD"/>
|
||||
</condition>
|
||||
<property name="grep" value="grep"/>
|
||||
<apply dir="${build.native}" executable="${grep}" parallel="true"
|
||||
failonerror="true" relative="true" output="${md5.file}">
|
||||
<arg value="-A"/>
|
||||
<arg value="1"/>
|
||||
<arg value="JNIEXPORT"/>
|
||||
<fileset dir="${build.native}" includes="*.h"/>
|
||||
</apply>
|
||||
<fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
|
||||
<checksum property="md5" file="${md5.file}" />
|
||||
<condition property="jni.valid" value="true">
|
||||
<or>
|
||||
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
|
||||
<equals arg1="${jni.md5}" arg2=""/>
|
||||
</or>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="native" depends="setup,javah"
|
||||
description="Build native libraries. Use 'ant -DCC=gcc' to build using gcc on w32">
|
||||
<!-- Invalidate native libraries when native API changes -->
|
||||
<target name="-native-api-check" depends="javah" unless="jni.valid">
|
||||
<echo>Invalidating native code, new checksum is ${md5}</echo>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
|
||||
<delete failOnError="false" includeEmptyDirs="true">
|
||||
<fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
|
||||
</delete>
|
||||
<fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
|
||||
</target>
|
||||
|
||||
<target name=":rsrc">
|
||||
<condition property="-rsrc">
|
||||
<not><os family="windows"/></not>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
|
||||
description="Generate w32 DLL version resource information">
|
||||
<property name="rsrc" location="${build.native}/jnidispatch.rc"/>
|
||||
<copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
|
||||
<replaceregexp match="FILEVERSION.*"
|
||||
replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
|
||||
file="${rsrc}" byline="true"/>
|
||||
<replaceregexp match="PRODUCTVERSION.*"
|
||||
replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
|
||||
file="${rsrc}" byline="true"/>
|
||||
<replaceregexp match="FileVersion.*"
|
||||
replace="FileVersion","${jni.version}""
|
||||
file="${rsrc}" byline="true"/>
|
||||
<replaceregexp match="Full Version.*"
|
||||
replace="Full Version","${jni.version} b${jni.build}""
|
||||
file="${rsrc}" byline="true"/>
|
||||
<replaceregexp match="ProductVersion.*"
|
||||
replace="ProductVersion","${spec.version}""
|
||||
file="${rsrc}" byline="true"/>
|
||||
</target>
|
||||
|
||||
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
|
||||
description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
|
||||
<property name="comment" value="# auto-generated by ant"/>
|
||||
<replaceregexp match="^JNA_JNI_VERSION=.*"
|
||||
replace="JNA_JNI_VERSION=${jni.version} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<replaceregexp match="^CHECKSUM=.*"
|
||||
replace="CHECKSUM=${jni.md5} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
|
||||
<!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
|
||||
<property name="ARCH" value="${os.arch}"/>
|
||||
<condition property="make.CC" value="CC=${CC}" else="IGNORE=">
|
||||
<isset property="CC"/>
|
||||
</condition>
|
||||
@@ -179,69 +351,149 @@
|
||||
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
|
||||
<isset property="SDKROOT"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT" value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
|
||||
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
|
||||
</condition>
|
||||
<!-- Windows' drive letters in absolute paths wreak havoc on make -->
|
||||
<condition property="make.BUILD" value="BUILD=../build/native" else="BUILD=${build.native}">
|
||||
<!-- Windows' drive letters and spaces in absolute paths wreak havoc on
|
||||
make -->
|
||||
<condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<exec executable="make" dir="${native}" failonerror="true">
|
||||
<condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<condition property="make" value="/usr/sfw/bin/gmake">
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<condition property="make" value="gmake">
|
||||
<or>
|
||||
<os name="FreeBSD"/>
|
||||
<os name="OpenBSD"/>
|
||||
</or>
|
||||
</condition>
|
||||
|
||||
<!-- Default make program -->
|
||||
<property name="make" value="make"/>
|
||||
|
||||
<exec executable="${make}" dir="${native}" failonerror="true">
|
||||
<arg value="JAVA_HOME=${jdk.home}"/>
|
||||
<arg value="JAVAH=${build.native}"/>
|
||||
<arg value="DEBUG=${debug.native}"/>
|
||||
<arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
|
||||
<arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
|
||||
<arg value="${make.CC}"/>
|
||||
<arg value="${make.BUILD}"/>
|
||||
<arg value="${make.SDKROOT}"/>
|
||||
<arg value="${make.ARCH}"/>
|
||||
<arg value="${make.PATH}"/>
|
||||
<arg value="JNA_JNI_VERSION=${jni.version}"/>
|
||||
<arg value="CHECKSUM=${jni.md5}"/>
|
||||
</exec>
|
||||
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${classes}/com/sun/jna/${os.prefix}">
|
||||
<fileset dir="${build.native}"
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</copy>
|
||||
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
|
||||
failonerror="false">
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</copy>
|
||||
<!-- For web start, native libraries may be provided in the root of -->
|
||||
<!-- an included jar file -->
|
||||
<jar jarfile="${build}/${native.jar}">
|
||||
<fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
<manifest>
|
||||
<attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
|
||||
<attribute name="Specification-Version" value="${jni.version}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile"
|
||||
description="Compile all test code">
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<javac classpathref="compile-test.path"
|
||||
source="${jdk}"
|
||||
target="${jdk}"
|
||||
source="${test.compatibility}"
|
||||
target="${test.compatibility}"
|
||||
destdir="${test.classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${test.src}"/>
|
||||
</javac>
|
||||
<jar jarfile="${build}/${testjar}">
|
||||
<fileset dir="${test.classes}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<mkdir dir="${build}/jws"/>
|
||||
<copy todir="${build}/jws" file="${build}/${jar}"/>
|
||||
<copy todir="${build}/jws" file="${build}/${testjar}"/>
|
||||
<copy todir="${build}/jws" file="lib/junit.jar"/>
|
||||
<copy todir="${build}/jws" file="lib/clover.jar"/>
|
||||
<jar jarfile="${build}/jws/jnidispatch.jar">
|
||||
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
|
||||
</jar>
|
||||
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
|
||||
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
</signjar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found -->
|
||||
<target name="test" depends="jar,examples-jar,compile-tests"
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,contrib-jars,compile-tests"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="reports.junit" location="${reports}/junit"/>
|
||||
<property name="results.junit" location="${build}/junit-results"/>
|
||||
<mkdir dir="${results.junit}"/>
|
||||
<echo>Saving test results in ${results.junit}</echo>
|
||||
<condition property="tests.w32" value="**/win32/*Test.java">
|
||||
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
|
||||
<condition property="tests.platform" value="**/win32/**/*Test.java">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.unix" value="**/unix/*Test.java">
|
||||
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
|
||||
<and><os family="windows"/><not><os arch="x86"/></not></and>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="**/unix/*Test.java">
|
||||
<and>
|
||||
<os family="unix"/>
|
||||
<not><os family="mac"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
<junit printsummary="yes" fork="${test.fork}">
|
||||
<!--<jvmarg value="-verbose:jni"/>-->
|
||||
<condition property="vmopt.arch" value="-d64" else="-Dignore">
|
||||
<and>
|
||||
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
|
||||
<not><os family="windows"/></not>
|
||||
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="tests.platform" value=""/>
|
||||
<property name="tests.exclude" value=""/>
|
||||
<junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
|
||||
<!-- avoid VM conflicts with JNA protected mode -->
|
||||
<env key="${ld.preload}" file="${libjsig}"/>
|
||||
<jvmarg value="-Djna.library.path=${build.native}"/>
|
||||
<!-- Avoid VM crashes, if possible -->
|
||||
<jvmarg value="-Djna.protected=true"/>
|
||||
<jvmarg value="-Djna.builddir=${build}"/>
|
||||
<jvmarg value="${vmopt.arch}"/>
|
||||
<classpath><path refid="test.runpath"/></classpath>
|
||||
<formatter type="xml"/>
|
||||
<batchtest todir="${results.junit}">
|
||||
<fileset dir="${test.src}">
|
||||
<include name="com/sun/jna/*Test.java"/>
|
||||
<include name="com/sun/jna/examples/*Test.java"/>
|
||||
<include name="${tests.w32}"/>
|
||||
<include name="${tests.unix}"/>
|
||||
<include name="${tests.platform}"/>
|
||||
<exclude name="${tests.exclude}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
@@ -252,15 +504,17 @@
|
||||
<report todir="${reports.junit}"/>
|
||||
</junitreport>
|
||||
<echo>View test report in file://${reports.junit}/index.html</echo>
|
||||
<subant target="test">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
<fail if="testfailure" unless="clover">One or more tests failed</fail>
|
||||
</target>
|
||||
|
||||
<target name="with.clover" description="Enable code coverage for tests">
|
||||
<taskdef resource="clovertasks"/>
|
||||
<taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
|
||||
<property name="clover" value="true"/>
|
||||
<property name="build" value="build.clover"/>
|
||||
<property name="clover.include" value="**/*.java"/>
|
||||
<clover-setup initString="${build}/coverage.db">
|
||||
<fileset dir="${src}" includes="${clover.include}"/>
|
||||
</clover-setup>
|
||||
<clover-setup/>
|
||||
</target>
|
||||
|
||||
<target name="clover" depends="with.clover,test"
|
||||
@@ -269,27 +523,37 @@
|
||||
<mkdir dir="${reports.clover}"/>
|
||||
<clover-report>
|
||||
<current outfile="${reports.clover}" title="clover">
|
||||
<fileset dir="." includes="**/*.java" />
|
||||
<testresults dir="${results.junit}" includes="TEST-*.xml"/>
|
||||
<format type="html"/>
|
||||
</current>
|
||||
</clover-report>
|
||||
<echo>Reports generated in ${reports.clover}</echo>
|
||||
</target>
|
||||
|
||||
<target name="javadoc" depends="setup">
|
||||
<target name="javadoc" depends="-setup">
|
||||
<path id="javadoc.src.path">
|
||||
<path refid="src.path"/>
|
||||
<pathelement location="${platform.src}"/>
|
||||
</path>
|
||||
<path id="javadoc.compile.path">
|
||||
<path refid="compile.path"/>
|
||||
<pathelement location="${classes}"/>
|
||||
</path>
|
||||
<property name="header"
|
||||
value="<b>JNA API</><font size="-1"> ${version}</font>"/>
|
||||
value="<b>JNA API</><font size="-1"> ${jna.version}</font>"/>
|
||||
<property name="footer"
|
||||
value="<center><i>${copyright}</i></center>"/>
|
||||
|
||||
<mkdir dir="${doc}/api"/>
|
||||
<mkdir dir="${javadoc}"/>
|
||||
<javadoc package="true"
|
||||
windowtitle="JNA API"
|
||||
sourcepathref="src.path"
|
||||
classpathref="compile.path"
|
||||
sourcepathref="javadoc.src.path"
|
||||
classpathref="javadoc.compile.path"
|
||||
maxmemory="256m"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32"
|
||||
overview="${src}/com/sun/jna/overview.html"
|
||||
destdir="${doc}/api">
|
||||
destdir="${javadoc}">
|
||||
<!-- stylesheetfile="${stylesheet}" -->
|
||||
<doctitle>JNA API Documentation</doctitle>
|
||||
<header>${header}</header>
|
||||
@@ -301,62 +565,128 @@
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
<packageset dir="${platform.src}" defaultexcludes="yes">
|
||||
<patternset>
|
||||
<include name="com/sun/jna/platform/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
|
||||
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr"/>
|
||||
<group title="Examples" packages="com.sun.jna.examples"/>
|
||||
<group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
|
||||
<group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
|
||||
|
||||
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
|
||||
<group title="Platform Utilities" packages="com.sun.jna.platform,com.sun.jna.platform.dnd"/>
|
||||
<group title="Platform Specific" packages="com.sun.jna.platform.*"/>
|
||||
|
||||
<arg value="-notimestamp"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="jar,native-jar,examples-jar"
|
||||
description="Build examples">
|
||||
<target name="dist" depends="jar,contrib-jars,compile-tests,native,javadoc"
|
||||
description="Build distribution files">
|
||||
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
</section>
|
||||
</manifest>
|
||||
<zipfileset src="${build}/${jar}"/>
|
||||
<zipfileset src="${dist}/win32-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-x86"/>
|
||||
<zipfileset src="${dist}/darwin-i386.jar"
|
||||
<zipfileset src="${dist}/darwin.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/darwin-i386"/>
|
||||
<zipfileset src="${dist}/darwin-ppc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/darwin-ppc"/>
|
||||
prefix="com/sun/jna/darwin"/>
|
||||
<zipfileset src="${dist}/linux-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-i386"/>
|
||||
<zipfileset src="${dist}/linux-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-amd64"/>
|
||||
<zipfileset src="${dist}/linux-ia64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ia64"/>
|
||||
<zipfileset src="${dist}/sunos-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-x86"/>
|
||||
<zipfileset src="${dist}/sunos-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-amd64"/>
|
||||
<zipfileset src="${dist}/sunos-sparc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparc"/>
|
||||
<zipfileset src="${dist}/sunos-sparcv9.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparcv9"/>
|
||||
<zipfileset src="${dist}/freebsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-i386"/>
|
||||
<zipfileset src="${dist}/freebsd-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-amd64"/>
|
||||
<zipfileset src="${dist}/openbsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/openbsd-i386"/>
|
||||
<zipfileset src="${dist}/win32-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-amd64"/>
|
||||
</jar>
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${build}">
|
||||
<include name="${native.jar}"/>
|
||||
<include name="examples.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${contrib}/platform/dist">
|
||||
<include name="platform.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!--
|
||||
<copy todir="${dist}/doc">
|
||||
<fileset dir="${doc}"/>
|
||||
</copy>-->
|
||||
<copy todir="${dist}/jnacontrib" flatten="true">
|
||||
<fileset dir="${contrib}">
|
||||
<include name="**/build/demo-*.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<zip zipfile="${dist}/doc.zip">
|
||||
<zipfileset dir="${javadoc}" prefix="javadoc"/>
|
||||
</zip>
|
||||
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
|
||||
<zip zipfile="${dist}/src.zip">
|
||||
<zipfileset dir="." includes="build.xml,pom.xml,LICENSE.txt"/>
|
||||
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
|
||||
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*,build,build/**/*" prefix="native"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
|
||||
</zip>
|
||||
<!-- Full sources required to build and test everything -->
|
||||
<zip zipfile="${dist}/src-full.zip">
|
||||
<zipfileset src="${dist}/src.zip"/>
|
||||
<zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
|
||||
<zipfileset dir="." includes=".classpath,.project"/>
|
||||
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
|
||||
<zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
|
||||
</zip>
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${dist}/src-mvn.zip">
|
||||
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="dynamic-properties">
|
||||
<target name="clean" depends="-dynamic-properties">
|
||||
<delete failOnError="false" includeEmptyDirs="true">
|
||||
<fileset dir="${build}"/>
|
||||
</delete>
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${doc}/api"/>
|
||||
<fileset dir=".clover"/>
|
||||
<fileset dir="${javadoc}"/>
|
||||
<fileset dir="." includes="*~,**/*~"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="profile-single" depends="examples-jar" description="Profile Class">
|
||||
<fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
<classpath> <pathelement location="${build}/examples.jar"/> </classpath>
|
||||
</nbprofiledirect>
|
||||
<java jar="${build}/examples.jar" fork="true">
|
||||
<jvmarg value="${profiler.info.jvmargs.agent}"/>
|
||||
</java>
|
||||
<subant target="clean">
|
||||
<fileset dir="${contrib}" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alphamaskdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+93
-47
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -10,7 +10,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -25,6 +26,7 @@ import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
@@ -37,6 +39,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@@ -51,16 +54,26 @@ import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.XSetWindowAttributes;
|
||||
import com.sun.jna.examples.win32.GDI32;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.examples.win32.User32.POINT;
|
||||
import com.sun.jna.examples.win32.User32.SIZE;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.unix.X11.GC;
|
||||
import com.sun.jna.platform.win32.GDI32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinGDI;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
@@ -80,6 +93,10 @@ public class AlphaMaskDemo implements Runnable {
|
||||
private float alpha = 1f;
|
||||
private Image image;
|
||||
|
||||
private void update() {
|
||||
update(false, true);
|
||||
}
|
||||
|
||||
private void update(boolean a, boolean i) {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows"))
|
||||
@@ -110,21 +127,18 @@ public class AlphaMaskDemo implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
private com.sun.jna.Memory buffer;
|
||||
private int[] pixels;
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
X11 x11 = X11.INSTANCE;
|
||||
int win = X11.None;
|
||||
Pointer dpy = x11.XOpenDisplay(null);
|
||||
X11.Window win = X11.Window.None;
|
||||
Display dpy = x11.XOpenDisplay(null);
|
||||
try {
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
if (System.getProperty("java.version").matches("^1\\.4\\..*"))
|
||||
alphaWindow.setVisible(true);
|
||||
win = (int)Native.getWindowID(alphaWindow);
|
||||
XSetWindowAttributes xswa = new XSetWindowAttributes();
|
||||
xswa.background_pixel = 0x0;
|
||||
Pointer visual = x11.XDefaultVisual(dpy, x11.XDefaultScreen(dpy));
|
||||
xswa.colormap = x11.XCreateColormap(dpy, win, visual, X11.AllocNone);
|
||||
x11.XChangeWindowAttributes(dpy, win, X11.CWBackPixel|X11.CWColormap, xswa);
|
||||
win = new X11.Window((int)Native.getWindowID(alphaWindow));
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
@@ -133,41 +147,61 @@ public class AlphaMaskDemo implements Runnable {
|
||||
alphaWindow.setBackground(new Color(0,0,0,0));
|
||||
}
|
||||
else {
|
||||
win = (int)Native.getWindowID(alphaWindow);
|
||||
win = new X11.Window((int)Native.getWindowID(alphaWindow));
|
||||
}
|
||||
|
||||
if (i) {
|
||||
int w = image.getWidth(null);
|
||||
int h = image.getHeight(null);
|
||||
alphaWindow.setSize(w, h);
|
||||
if (buffer == null || buffer.getSize() != w*h*4) {
|
||||
buffer = new com.sun.jna.Memory(w*h*4);
|
||||
pixels = new int[w*h];
|
||||
}
|
||||
|
||||
BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
|
||||
Graphics g = buf.getGraphics();
|
||||
g.drawImage(image, 0, 0, w, h, null);
|
||||
|
||||
Pointer gc = x11.XCreateGC(dpy, win, 0, null);
|
||||
int pixmap = x11.XCreatePixmap(dpy, win, w, h, 32);
|
||||
long start = System.currentTimeMillis();
|
||||
long blitTime, putImageTime, write;
|
||||
GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null);
|
||||
long gcTime = System.currentTimeMillis();
|
||||
try {
|
||||
x11.XSetForeground(dpy, gc, 0);
|
||||
x11.XFillRectangle(dpy, pixmap, gc, 0, 0, w, h);
|
||||
Raster raster = buf.getData();
|
||||
int[] pixel = new int[4];
|
||||
for (int y=0;y < h;y++) {
|
||||
for (int x=0;x < w;x++) {
|
||||
raster.getPixel(x, h-y-1, pixel);
|
||||
raster.getPixel(x, y, pixel);
|
||||
int alpha = (pixel[3]&0xFF)<<24;
|
||||
int red = (pixel[2]&0xFF);
|
||||
int green = (pixel[1]&0xFF)<<8;
|
||||
int blue = (pixel[0]&0xFF)<<16;
|
||||
x11.XSetForeground(dpy, gc, alpha|red|green|blue);
|
||||
x11.XFillRectangle(dpy, pixmap, gc, x, h-y-1, 1, 1);
|
||||
pixels[y*w+x] = alpha|red|green|blue;
|
||||
}
|
||||
}
|
||||
x11.XCopyArea(dpy, pixmap, win, gc, 0, 0, w, h, 0, 0);
|
||||
blitTime = System.currentTimeMillis();
|
||||
X11.XWindowAttributes xwa = new X11.XWindowAttributes();
|
||||
x11.XGetWindowAttributes(dpy, win, xwa);
|
||||
X11.XImage image = x11.XCreateImage(dpy, xwa.visual,
|
||||
32, X11.ZPixmap,
|
||||
0, buffer, w, h, 32, w*4);
|
||||
buffer.write(0, pixels, 0, pixels.length);
|
||||
write = System.currentTimeMillis();
|
||||
x11.XPutImage(dpy, win, gc, image, 0,0,0,0,w,h);
|
||||
x11.XFree(image.getPointer());
|
||||
putImageTime = System.currentTimeMillis();
|
||||
}
|
||||
finally {
|
||||
if (gc != null)
|
||||
x11.XFreeGC(dpy, gc);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
//System.out.println("gc: " + (gcTime-start) + "ms");
|
||||
//System.out.println("blit: " + (blitTime-gcTime) + "ms");
|
||||
//System.out.println("write: " + (write-blitTime) + "ms");
|
||||
//System.out.println("put image: " + (putImageTime-write) + "ms");
|
||||
//System.out.println("total: " + (end-start) + "ms");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -183,34 +217,40 @@ public class AlphaMaskDemo implements Runnable {
|
||||
update(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
private HWND getHwnd(Window w) {
|
||||
HWND hwnd = new HWND();
|
||||
hwnd.setPointer(Native.getWindowPointer(w));
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
private void updateW32(boolean a, boolean i) {
|
||||
User32 user = User32.INSTANCE;
|
||||
GDI32 gdi = GDI32.INSTANCE;
|
||||
Pointer hWnd = null;
|
||||
HWND hWnd = null;
|
||||
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
hWnd = Native.getWindowPointer(alphaWindow);
|
||||
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
|
||||
flags |= User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
alphaWindow.setLocation(where);
|
||||
}
|
||||
else {
|
||||
hWnd = Native.getWindowPointer(alphaWindow);
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
}
|
||||
|
||||
if (i) {
|
||||
int w = image.getWidth(null);
|
||||
int h = image.getHeight(null);
|
||||
Pointer screenDC = user.GetDC(null);
|
||||
Pointer memDC = gdi.CreateCompatibleDC(screenDC);
|
||||
Pointer hBitmap = null;
|
||||
Pointer oldBitmap = null;
|
||||
HDC screenDC = user.GetDC(null);
|
||||
HDC memDC = gdi.CreateCompatibleDC(screenDC);
|
||||
HBITMAP hBitmap = null;
|
||||
HANDLE oldBitmap = null;
|
||||
|
||||
try {
|
||||
BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
|
||||
@@ -222,11 +262,11 @@ public class AlphaMaskDemo implements Runnable {
|
||||
bmi.bmiHeader.biHeight = h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
|
||||
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
PointerByReference ppbits = new PointerByReference();
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, GDI32.DIB_RGB_COLORS,
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
oldBitmap = gdi.SelectObject(memDC, hBitmap);
|
||||
Pointer pbits = ppbits.getValue();
|
||||
@@ -255,9 +295,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
POINT srcLoc = new POINT();
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, screenDC, loc, size, memDC, srcLoc,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
finally {
|
||||
user.ReleaseDC(null, screenDC);
|
||||
@@ -271,9 +311,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
else if (a) {
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null, null,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
|
||||
if (!alphaWindow.isVisible()) {
|
||||
@@ -348,8 +388,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR)
|
||||
|| list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
@@ -386,8 +427,8 @@ public class AlphaMaskDemo implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
|
||||
List files = (List)t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://" + f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
@@ -454,6 +495,11 @@ public class AlphaMaskDemo implements Runnable {
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
centerOnScreen(frame);
|
||||
frame.setVisible(true);
|
||||
p.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
URL url = getClass().getResource("tardis.png");
|
||||
+2
-5
@@ -23,11 +23,8 @@
|
||||
<property name="jna.library.path" value="/usr/X11R6/lib:/usr/lib32:/usr/lib"/>
|
||||
<nativelib href="linux-i386.jar"/>
|
||||
</resources>
|
||||
<resources os="Mac" arch="i386">
|
||||
<nativelib href="darwin-i386.jar"/>
|
||||
</resources>
|
||||
<resources os="Mac" arch="ppc">
|
||||
<nativelib href="darwin-ppc.jar"/>
|
||||
<resources os="Mac">
|
||||
<nativelib href="darwin.jar"/>
|
||||
</resources>
|
||||
<application-desc main-class="com.sun.jna.examples.AlphaMaskDemo"/>
|
||||
<security>
|
||||
+17
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Timothy Wall, All Rights Reserved This library is
|
||||
* Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved This library is
|
||||
* free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation; either version 2.1 of the License, or (at
|
||||
@@ -8,9 +8,10 @@
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
@@ -33,6 +34,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
@@ -50,16 +52,13 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
// just hard-coded blitting of an image into a window
|
||||
// Thanks to Rui Lopes for the C# example on which this is based:
|
||||
// rui@ruilopes.com
|
||||
// http://www.codeproject.com/cs/media/perpxalpha_sharp.asp?df=100&forumid=3270&exp=0&select=773155
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
public class AlphaMaskDemo2 implements Runnable {
|
||||
private static final DataFlavor URL_FLAVOR = new DataFlavor("application/x-java-url; class=java.net.URL",
|
||||
"URL");
|
||||
private static final DataFlavor URI_LIST_FLAVOR = new DataFlavor("text/uri-list; class=java.lang.String",
|
||||
"URI list");
|
||||
private static final DataFlavor URL_FLAVOR =
|
||||
new DataFlavor("application/x-java-url; class=java.net.URL", "URL");
|
||||
private static final DataFlavor URI_LIST_FLAVOR =
|
||||
new DataFlavor("text/uri-list; class=java.lang.String", "URI list");
|
||||
private JFrame frame;
|
||||
private JWindow alphaWindow;
|
||||
private JLabel icon;
|
||||
@@ -106,6 +105,7 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
frame = new JFrame("Alpha Mask Demo");
|
||||
alphaWindow = new JWindow(frame, gconfig);
|
||||
icon = new JLabel();
|
||||
icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
alphaWindow.getContentPane().add(icon);
|
||||
JButton quit = new JButton("Quit");
|
||||
JLabel label = new JLabel("Drag this window by its image");
|
||||
@@ -145,9 +145,10 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
public boolean canImport(JComponent comp,
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp,
|
||||
DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
|| list.contains(DataFlavor.javaFileListFlavor)) {
|
||||
@@ -185,9 +186,8 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
List files = (List)t
|
||||
.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://"
|
||||
+ f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
@@ -251,6 +251,7 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
"<html><center>Drop an image with an alpha channel onto this window<br>"
|
||||
+ "You may also adjust the overall transparency with the slider</center></html>"),
|
||||
BorderLayout.NORTH);
|
||||
p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
final JSlider slider = new JSlider(0, 255, 255);
|
||||
slider.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
|
Antes Largura: | Altura: | Tamanho: 18 KiB Depois Largura: | Altura: | Tamanho: 18 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloonmanagerdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+40
-23
@@ -10,7 +10,7 @@
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -31,11 +31,14 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* Provides a popup balloon containing an arbitrary component. This provides
|
||||
* a form of content-specific decoration less transient than a tooltip, and less
|
||||
@@ -48,17 +51,16 @@ import javax.swing.SwingUtilities;
|
||||
// TODO: lightweight popups
|
||||
public class BalloonManager {
|
||||
|
||||
// Mac does it's own shadows (as does vista and some x11+xcompmgr)
|
||||
// Avoid using drop shadow in some instances
|
||||
private static boolean useDropShadow() {
|
||||
return WindowUtils.isWindowAlphaSupported()
|
||||
&& !System.getProperty("os.name").startsWith("Mac");
|
||||
return WindowUtils.isWindowAlphaSupported();
|
||||
}
|
||||
|
||||
|
||||
private static class DropShadow extends JWindow {
|
||||
private static final float ALPHA = .5f;
|
||||
private static final float YSCALE = .90f;
|
||||
private static final double ANGLE = 2*Math.PI/48;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final float SHADOW_ALPHA = .25f;
|
||||
private static final float YSCALE = .80f;
|
||||
private static final double ANGLE = 2*Math.PI/24;
|
||||
private static final Point OFFSET = new Point(8, 8);
|
||||
private static final Color COLOR = new Color(0, 0, 0, 50);
|
||||
|
||||
@@ -69,7 +71,8 @@ public class BalloonManager {
|
||||
setFocusableWindowState(false);
|
||||
setName("###overrideRedirect###");
|
||||
|
||||
Point where = parent.getLocation();
|
||||
Point where = parent.isShowing()
|
||||
? parent.getLocationOnScreen() : parent.getLocation();
|
||||
setLocation(where.x + OFFSET.x, where.y + OFFSET.y);
|
||||
setBackground(COLOR);
|
||||
getContentPane().setBackground(COLOR);
|
||||
@@ -77,12 +80,15 @@ public class BalloonManager {
|
||||
parentMask = mask;
|
||||
parent.addComponentListener(listener = new ComponentAdapter() {
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
Point where = e.getComponent().getLocationOnScreen();
|
||||
Point where = getOwner().isShowing()
|
||||
? getOwner().getLocationOnScreen()
|
||||
: getOwner().getLocation();
|
||||
setLocation(where.x + OFFSET.x, where.y + OFFSET.y);
|
||||
}
|
||||
public void componentResized(ComponentEvent e) {
|
||||
Component c = e.getComponent();
|
||||
setSize(c.getWidth(), c.getHeight());
|
||||
int extra = c.getWidth() + (int)Math.sin(ANGLE)*c.getHeight();
|
||||
setSize(c.getWidth() + extra, c.getHeight());
|
||||
WindowUtils.setWindowMask(DropShadow.this, getMask());
|
||||
}
|
||||
public void componentShown(ComponentEvent e) {
|
||||
@@ -101,7 +107,7 @@ public class BalloonManager {
|
||||
}
|
||||
});
|
||||
WindowUtils.setWindowMask(DropShadow.this, getMask());
|
||||
WindowUtils.setWindowAlpha(DropShadow.this, ALPHA);
|
||||
WindowUtils.setWindowAlpha(DropShadow.this, SHADOW_ALPHA);
|
||||
if (parent.isVisible()) {
|
||||
pack();
|
||||
setVisible(true);
|
||||
@@ -110,6 +116,9 @@ public class BalloonManager {
|
||||
|
||||
public void paint(Graphics graphics) {
|
||||
Graphics2D g = (Graphics2D)graphics.create();
|
||||
// Workaround for OSX since we only get automatic clipping
|
||||
// on the content pane and below
|
||||
g.setClip(getMask());
|
||||
g.setPaint(new GradientPaint(0, getHeight()/2, new Color(0,0,0,0), getWidth(), getHeight()/2, new Color(0,0,0,255)));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
g.dispose();
|
||||
@@ -125,13 +134,14 @@ public class BalloonManager {
|
||||
private Shape getMask() {
|
||||
Area area = new Area(parentMask);
|
||||
Area clip = new Area(parentMask);
|
||||
// TODO: shear right and shrink height
|
||||
//AffineTransform tx = new AffineTransform();
|
||||
//tx.shear(-Math.tan(ANGLE), 0);
|
||||
//tx.translate(Math.sin(ANGLE)*getHeight(), getHeight()-getHeight()*YSCALE);
|
||||
//tx.scale(1, YSCALE);
|
||||
//area.transform(tx);
|
||||
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.translate(Math.sin(ANGLE)*getOwner().getHeight(), 0);
|
||||
tx.shear(-Math.tan(ANGLE), 0);
|
||||
tx.scale(1, YSCALE);
|
||||
tx.translate(0, (1-YSCALE)*getOwner().getHeight());
|
||||
area.transform(tx);
|
||||
tx = new AffineTransform();
|
||||
tx.translate(-OFFSET.x, -OFFSET.y);
|
||||
clip.transform(tx);
|
||||
area.subtract(clip);
|
||||
@@ -140,15 +150,19 @@ public class BalloonManager {
|
||||
}
|
||||
|
||||
private static final class BubbleWindow extends JWindow {
|
||||
private final int Y_OFFSET = 50;
|
||||
private final int ARC = 25;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int Y_OFFSET = 50;
|
||||
private static final int ARC = 25;
|
||||
|
||||
private Point offset;
|
||||
private Area mask;
|
||||
private Dimension maskSize;
|
||||
private ComponentListener moveTracker = new ComponentAdapter() {
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
Point where = e.getComponent().getLocationOnScreen();
|
||||
Point where =
|
||||
e.getComponent().isShowing()
|
||||
? e.getComponent().getLocationOnScreen()
|
||||
: e.getComponent().getLocation();
|
||||
setLocation(where.x - offset.x, where.y - offset.y);
|
||||
// TODO preserve stacking order (linux)
|
||||
}
|
||||
@@ -185,7 +199,8 @@ public class BalloonManager {
|
||||
super.setLocation(x, y);
|
||||
Window owner = getOwner();
|
||||
if (owner != null) {
|
||||
Point ref = owner.getLocationOnScreen();
|
||||
Point ref = owner.isShowing()
|
||||
? owner.getLocationOnScreen() : owner.getLocation();
|
||||
offset = new Point(ref.x - x, ref.y - y);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +238,9 @@ public class BalloonManager {
|
||||
|
||||
// Simulate PopupFactory, ensuring we get a heavyweight "popup"
|
||||
final Point origin =
|
||||
owner == null ? new Point(0, 0) : owner.getLocationOnScreen();
|
||||
owner == null ? new Point(0, 0)
|
||||
: (owner.isShowing()
|
||||
? owner.getLocationOnScreen() : owner.getLocation());
|
||||
final Window parent = owner != null
|
||||
? SwingUtilities.getWindowAncestor(owner) : null;
|
||||
origin.translate(x, y);
|
||||
+6
-3
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -24,6 +24,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
@@ -35,6 +36,8 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Demonstration of BalloonManager. */
|
||||
public class BalloonManagerDemo {
|
||||
private static final int ICON_SIZE = 48;
|
||||
@@ -105,6 +108,7 @@ public class BalloonManagerDemo {
|
||||
f.setSize(new Dimension(300, 300));
|
||||
f.setLocation(100, 100);
|
||||
try {
|
||||
// Force a load of JNA
|
||||
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
|
||||
f.setVisible(true);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@@ -112,8 +116,7 @@ public class BalloonManagerDemo {
|
||||
catch(UnsatisfiedLinkError e) {
|
||||
e.printStackTrace();
|
||||
String msg = e.getMessage()
|
||||
+ "\nError loading the JNA library after looking in "
|
||||
+ System.getProperty("java.library.path");
|
||||
+ "\nError loading the JNA library";
|
||||
JTextArea area = new JTextArea(msg);
|
||||
area.setOpaque(false);
|
||||
area.setFont(UIManager.getFont("Label.font"));
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloontips</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+3
-6
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -30,7 +30,7 @@ import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* The BalloonTipManager class handles creation and disposal of balloon style
|
||||
@@ -61,8 +61,8 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* The BalloonTip class defines the look of the BalloonTip object.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static final class BalloonTip extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Integer HMARGIN = 10;
|
||||
private static final Integer VMARGIN = 6;
|
||||
private static final Integer VSPACER = 4;
|
||||
@@ -476,7 +476,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned from moving the component.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class ComponentEar extends ComponentAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -491,7 +490,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when a mouse button is pressed.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class MouseEar extends MouseAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -506,7 +504,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when the component loses focus.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class FocusEar extends FocusAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>dnddemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+8
-3
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
@@ -25,13 +25,17 @@ import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.platform.dnd.DragHandler;
|
||||
import com.sun.jna.platform.dnd.DropHandler;
|
||||
|
||||
|
||||
/** Demonstrate ghosted drag images. Unfortunately, Swing drag support hides
|
||||
* the hooks we need to move the drag image around, so we don't use it and
|
||||
* roll our own.
|
||||
@@ -59,7 +63,8 @@ public class GhostedDragImageDemo {
|
||||
}
|
||||
|
||||
public static class DragLabel extends JLabel {
|
||||
private boolean dragging;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean dragging;
|
||||
public DragLabel(Icon icon) {
|
||||
super(icon);
|
||||
new DragHandler(this, DnDConstants.ACTION_COPY_OR_MOVE) {
|
||||
Arquivo executável → Arquivo normal
|
Antes Largura: | Altura: | Tamanho: 28 KiB Depois Largura: | Altura: | Tamanho: 28 KiB |
+1
-1
@@ -7,7 +7,7 @@
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides Windows-specific support for JNA.
|
||||
Cross-platform ghosted drag image implementation with demo application.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ntservice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,60 @@
|
||||
Copyright (c) 2007 Thomas Boerkel, All Rights Reserved
|
||||
|
||||
Disclaimer:
|
||||
===========
|
||||
This code is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
Description:
|
||||
============
|
||||
|
||||
Accounts.java:
|
||||
--------------
|
||||
Static methods for getting information about Win32 accounts (users
|
||||
and groups).
|
||||
- list all domain users
|
||||
- list all domain groups
|
||||
- list all local or domain groups where a user belongs to
|
||||
- get account by SID
|
||||
- get SID of account
|
||||
- get domain controller name
|
||||
- get domain name
|
||||
|
||||
Registry.java:
|
||||
--------------
|
||||
Static methods for reading and manipulating the Windows Registry.
|
||||
Only String and DWORD values supported, but could be easily
|
||||
extended.
|
||||
- create key
|
||||
- delete key
|
||||
- delete value
|
||||
- read value
|
||||
- get all sub keys of a key
|
||||
- get all values of a key
|
||||
- set value
|
||||
- check existence of value
|
||||
|
||||
Win32Service.java:
|
||||
------------------
|
||||
Abstract class to wrap a Win32 service. Derive from this class
|
||||
to build your own service. Supports only one type of service and
|
||||
startup, but could be easily extended.
|
||||
- install service
|
||||
- uninstall service
|
||||
- start service
|
||||
- stop service
|
||||
- callback for service start request (onStart), should spawn a thread
|
||||
- callback for service stop request (onStop)
|
||||
|
||||
TestService.java:
|
||||
-----------------
|
||||
Very simple example of an implementation of Win32Service.java.
|
||||
Does nothing but starting and stopping (no "useful" work).
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<project name="JnaContrib" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project JnaContrib.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
||||
@@ -0,0 +1,541 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=94714fd7
|
||||
build.xml.script.CRC32=64128189
|
||||
build.xml.stylesheet.CRC32=240b97a2
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=94714fd7
|
||||
nbproject/build-impl.xml.script.CRC32=9d2a0176
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=65d7ca21
|
||||
@@ -0,0 +1,59 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/contrib-ntservice.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>ntservice</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Advapi32.java
|
||||
*
|
||||
* Created on 6. August 2007, 11:24
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.*;
|
||||
import com.sun.jna.win32.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenSCManager(
|
||||
LPCTSTR lpMachineName,
|
||||
LPCTSTR lpDatabaseName,
|
||||
DWORD dwDesiredAccess
|
||||
);*/
|
||||
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
BOOL WINAPI CloseServiceHandle(
|
||||
SC_HANDLE hSCObject
|
||||
);*/
|
||||
public boolean CloseServiceHandle(Pointer hSCObject);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenService(
|
||||
SC_HANDLE hSCManager,
|
||||
LPCTSTR lpServiceName,
|
||||
DWORD dwDesiredAccess
|
||||
);*/
|
||||
public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
BOOL WINAPI StartService(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwNumServiceArgs,
|
||||
LPCTSTR* lpServiceArgVectors
|
||||
);*/
|
||||
public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ControlService(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwControl,
|
||||
LPSERVICE_STATUS lpServiceStatus
|
||||
);*/
|
||||
public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
BOOL WINAPI StartServiceCtrlDispatcher(
|
||||
const SERVICE_TABLE_ENTRY* lpServiceTable
|
||||
);*/
|
||||
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
|
||||
|
||||
/*
|
||||
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
|
||||
LPCTSTR lpServiceName,
|
||||
LPHANDLER_FUNCTION lpHandlerProc
|
||||
);*/
|
||||
public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
|
||||
|
||||
/*
|
||||
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
|
||||
LPCTSTR lpServiceName,
|
||||
LPHANDLER_FUNCTION_EX lpHandlerProc,
|
||||
LPVOID lpContext
|
||||
);*/
|
||||
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
|
||||
|
||||
/*
|
||||
BOOL WINAPI SetServiceStatus(
|
||||
SERVICE_STATUS_HANDLE hServiceStatus,
|
||||
LPSERVICE_STATUS lpServiceStatus
|
||||
);*/
|
||||
public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI CreateService(
|
||||
SC_HANDLE hSCManager,
|
||||
LPCTSTR lpServiceName,
|
||||
LPCTSTR lpDisplayName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwServiceType,
|
||||
DWORD dwStartType,
|
||||
DWORD dwErrorControl,
|
||||
LPCTSTR lpBinaryPathName,
|
||||
LPCTSTR lpLoadOrderGroup,
|
||||
LPDWORD lpdwTagId,
|
||||
LPCTSTR lpDependencies,
|
||||
LPCTSTR lpServiceStartName,
|
||||
LPCTSTR lpPassword
|
||||
);*/
|
||||
public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
|
||||
int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
|
||||
String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
|
||||
String lpDependencies, String lpServiceStartName, String lpPassword);
|
||||
|
||||
/*
|
||||
BOOL WINAPI DeleteService(
|
||||
SC_HANDLE hService
|
||||
);*/
|
||||
public boolean DeleteService(Pointer hService);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ChangeServiceConfig2(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwInfoLevel,
|
||||
LPVOID lpInfo
|
||||
);*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumValue(
|
||||
HKEY hKey,
|
||||
DWORD dwIndex,
|
||||
LPTSTR lpValueName,
|
||||
LPDWORD lpcchValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);*/
|
||||
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
|
||||
/*
|
||||
VOID WINAPI ServiceMain(
|
||||
DWORD dwArgc,
|
||||
LPTSTR* lpszArgv
|
||||
);*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv);
|
||||
}
|
||||
|
||||
interface Handler extends StdCallCallback {
|
||||
/*
|
||||
VOID WINAPI Handler(
|
||||
DWORD fdwControl
|
||||
);*/
|
||||
public void callback(int fdwControl);
|
||||
}
|
||||
|
||||
interface HandlerEx extends StdCallCallback {
|
||||
/*
|
||||
DWORD WINAPI HandlerEx(
|
||||
DWORD dwControl,
|
||||
DWORD dwEventType,
|
||||
LPVOID lpEventData,
|
||||
LPVOID lpContext
|
||||
);*/
|
||||
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_STATUS {
|
||||
DWORD dwServiceType;
|
||||
DWORD dwCurrentState;
|
||||
DWORD dwControlsAccepted;
|
||||
DWORD dwWin32ExitCode;
|
||||
DWORD dwServiceSpecificExitCode;
|
||||
DWORD dwCheckPoint;
|
||||
DWORD dwWaitHint;
|
||||
} SERVICE_STATUS,
|
||||
*LPSERVICE_STATUS;*/
|
||||
public static class SERVICE_STATUS extends Structure {
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_TABLE_ENTRY {
|
||||
LPTSTR lpServiceName;
|
||||
LPSERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
} SERVICE_TABLE_ENTRY,
|
||||
*LPSERVICE_TABLE_ENTRY;*/
|
||||
public static class SERVICE_TABLE_ENTRY extends Structure {
|
||||
public String lpServiceName;
|
||||
public SERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
}
|
||||
|
||||
public static class ChangeServiceConfig2Info extends Structure {
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_DESCRIPTION {
|
||||
LPTSTR lpDescription;
|
||||
} SERVICE_DESCRIPTION,
|
||||
*LPSERVICE_DESCRIPTION;*/
|
||||
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
|
||||
public String lpDescription;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* WINERROR.java
|
||||
*
|
||||
* Created on 7. August 2007, 08:09
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINERROR {
|
||||
public final static int ERROR_SUCCESS = 0;
|
||||
public final static int NO_ERROR = 0;
|
||||
public final static int ERROR_FILE_NOT_FOUND = 2;
|
||||
public final static int ERROR_MORE_DATA = 234;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* WINNT.java
|
||||
*
|
||||
* Created on 8. August 2007, 13:41
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINNT {
|
||||
public final static int DELETE = 0x00010000;
|
||||
public final static int READ_CONTROL = 0x00020000;
|
||||
public final static int WRITE_DAC = 0x00040000;
|
||||
public final static int WRITE_OWNER = 0x00080000;
|
||||
public final static int SYNCHRONIZE = 0x00100000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
|
||||
|
||||
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
|
||||
|
||||
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
|
||||
|
||||
public final static int GENERIC_EXECUTE = 0x20000000;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* WINSVC.java
|
||||
*
|
||||
* Created on 8. August 2007, 15:07
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINSVC {
|
||||
public final static int SERVICE_CONTROL_STOP = 0x00000001;
|
||||
public final static int SERVICE_CONTROL_SHUTDOWN = 0x00000005;
|
||||
|
||||
public final static int SERVICE_STOPPED = 0x00000001;
|
||||
public final static int SERVICE_START_PENDING = 0x00000002;
|
||||
public final static int SERVICE_STOP_PENDING = 0x00000003;
|
||||
public final static int SERVICE_RUNNING = 0x00000004;
|
||||
public final static int SERVICE_CONTINUE_PENDING = 0x00000005;
|
||||
public final static int SERVICE_PAUSE_PENDING = 0x00000006;
|
||||
public final static int SERVICE_PAUSED = 0x00000007;
|
||||
|
||||
public final static int SERVICE_ACCEPT_STOP = 0x00000001;
|
||||
public final static int SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002;
|
||||
public final static int SERVICE_ACCEPT_SHUTDOWN = 0x00000004;
|
||||
public final static int SERVICE_ACCEPT_PARAMCHANGE = 0x00000008;
|
||||
public final static int SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010;
|
||||
|
||||
public final static int SC_MANAGER_CONNECT = 0x0001;
|
||||
public final static int SC_MANAGER_CREATE_SERVICE = 0x0002;
|
||||
public final static int SC_MANAGER_ENUMERATE_SERVICE = 0x0004;
|
||||
public final static int SC_MANAGER_LOCK = 0x0008;
|
||||
public final static int SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;
|
||||
public final static int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020;
|
||||
|
||||
public final static int SC_MANAGER_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
|
||||
SC_MANAGER_CONNECT |
|
||||
SC_MANAGER_CREATE_SERVICE |
|
||||
SC_MANAGER_ENUMERATE_SERVICE |
|
||||
SC_MANAGER_LOCK |
|
||||
SC_MANAGER_QUERY_LOCK_STATUS |
|
||||
SC_MANAGER_MODIFY_BOOT_CONFIG;
|
||||
|
||||
public final static int SERVICE_QUERY_CONFIG = 0x0001;
|
||||
public final static int SERVICE_CHANGE_CONFIG = 0x0002;
|
||||
public final static int SERVICE_QUERY_STATUS = 0x0004;
|
||||
public final static int SERVICE_ENUMERATE_DEPENDENTS = 0x0008;
|
||||
public final static int SERVICE_START = 0x0010;
|
||||
public final static int SERVICE_STOP = 0x0020;
|
||||
public final static int SERVICE_PAUSE_CONTINUE = 0x0040;
|
||||
public final static int SERVICE_INTERROGATE = 0x0080;
|
||||
public final static int SERVICE_USER_DEFINED_CONTROL = 0x0100;
|
||||
|
||||
public final static int SERVICE_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
|
||||
SERVICE_QUERY_CONFIG |
|
||||
SERVICE_CHANGE_CONFIG |
|
||||
SERVICE_QUERY_STATUS |
|
||||
SERVICE_ENUMERATE_DEPENDENTS |
|
||||
SERVICE_START |
|
||||
SERVICE_STOP |
|
||||
SERVICE_PAUSE_CONTINUE |
|
||||
SERVICE_INTERROGATE |
|
||||
SERVICE_USER_DEFINED_CONTROL;
|
||||
|
||||
public final static int SERVICE_CONFIG_DESCRIPTION = 1;
|
||||
public final static int SERVICE_CONFIG_FAILURE_ACTIONS = 2;
|
||||
|
||||
public final static int SERVICE_KERNEL_DRIVER = 0x00000001;
|
||||
public final static int SERVICE_FILE_SYSTEM_DRIVER = 0x00000002;
|
||||
public final static int SERVICE_ADAPTER = 0x00000004;
|
||||
public final static int SERVICE_RECOGNIZER_DRIVER = 0x00000008;
|
||||
|
||||
public final static int SERVICE_DRIVER = SERVICE_KERNEL_DRIVER |
|
||||
SERVICE_FILE_SYSTEM_DRIVER |
|
||||
SERVICE_RECOGNIZER_DRIVER;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
public final static int SERVICE_WIN32_SHARE_PROCESS = 0x00000020;
|
||||
public final static int SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS;
|
||||
|
||||
public final static int SERVICE_INTERACTIVE_PROCESS = 0x00000100;
|
||||
|
||||
public final static int SERVICE_TYPE_ALL = SERVICE_WIN32 |
|
||||
SERVICE_ADAPTER |
|
||||
SERVICE_DRIVER |
|
||||
SERVICE_INTERACTIVE_PROCESS;
|
||||
|
||||
public final static int SERVICE_BOOT_START = 0x00000000;
|
||||
public final static int SERVICE_SYSTEM_START = 0x00000001;
|
||||
public final static int SERVICE_AUTO_START = 0x00000002;
|
||||
public final static int SERVICE_DEMAND_START = 0x00000003;
|
||||
public final static int SERVICE_DISABLED = 0x00000004;
|
||||
|
||||
public final static int SERVICE_ERROR_IGNORE = 0x00000000;
|
||||
public final static int SERVICE_ERROR_NORMAL = 0x00000001;
|
||||
public final static int SERVICE_ERROR_SEVERE = 0x00000002;
|
||||
public final static int SERVICE_ERROR_CRITICAL = 0x00000003;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* TestService.java
|
||||
*
|
||||
* Created on 12. September 2007, 12:49
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.win32;
|
||||
|
||||
/**
|
||||
* TestService.
|
||||
*/
|
||||
public class TestService extends Win32Service {
|
||||
|
||||
/**
|
||||
* main.
|
||||
* @param args arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestService service = new TestService();
|
||||
|
||||
if(args.length == 1) {
|
||||
|
||||
if(args[0].equalsIgnoreCase("install")) {
|
||||
System.out.println(service.install("TestService DisplayName", "TestService Description",
|
||||
null, null, null));
|
||||
|
||||
} else if(args[0].equalsIgnoreCase("uninstall")) {
|
||||
System.out.println(service.uninstall());
|
||||
|
||||
} else {
|
||||
System.out.println("Arguments:");
|
||||
System.out.println("install = install service");
|
||||
System.out.println("uninstall = uninstall service");
|
||||
System.out.println("<none> = run service");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
} else {
|
||||
service.init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of TestService.
|
||||
*/
|
||||
public TestService() {
|
||||
super("TestService");
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called on start.
|
||||
*/
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called on stop.
|
||||
*/
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Win32Service.java
|
||||
*
|
||||
* Created on 12. September 2007, 12:05
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.win32;
|
||||
|
||||
import jnacontrib.jna.*;
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
/**
|
||||
* Baseclass for a Win32 service.
|
||||
*/
|
||||
public abstract class Win32Service {
|
||||
protected String serviceName;
|
||||
private ServiceMain serviceMain;
|
||||
private ServiceControl serviceControl;
|
||||
private Pointer serviceStatusHandle;
|
||||
private Object waitObject = new Object();
|
||||
|
||||
/**
|
||||
* Creates a new instance of Win32Service.
|
||||
*
|
||||
* @param serviceName internal name of the service
|
||||
*/
|
||||
public Win32Service(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the service.
|
||||
*
|
||||
* @param displayName visible name
|
||||
* @param description description
|
||||
* @param dependencies array of other services to depend on or null
|
||||
* @param account service account or null for LocalSystem
|
||||
* @param password password for service account or null
|
||||
* @throws java.lang.Exception
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean install(String displayName, String description, String[] dependencies, String account, String password) {
|
||||
return(install(displayName, description, dependencies, account, password, "java.exe -cp \"" +
|
||||
System.getProperty("java.class.path") + "\" -Xrs " + this.getClass().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the service.
|
||||
*
|
||||
* @return true on success
|
||||
* @param displayName visible name
|
||||
* @param description description
|
||||
* @param dependencies array of other services to depend on or null
|
||||
* @param account service account or null for LocalSystem
|
||||
* @param password password for service account or null
|
||||
* @param command command line to start the service
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public boolean install(String displayName, String description, String[] dependencies, String account, String password, String command) {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_DESCRIPTION desc;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
String dep = "";
|
||||
|
||||
if(dependencies != null) {
|
||||
for(String s : dependencies) {
|
||||
dep += s + "\0";
|
||||
}
|
||||
}
|
||||
dep += "\0";
|
||||
|
||||
desc = new Advapi32.SERVICE_DESCRIPTION();
|
||||
desc.lpDescription = description;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.CreateService(serviceManager, serviceName, displayName,
|
||||
WINSVC.SERVICE_ALL_ACCESS, WINSVC.SERVICE_WIN32_OWN_PROCESS, WINSVC.SERVICE_DEMAND_START,
|
||||
WINSVC.SERVICE_ERROR_NORMAL,
|
||||
command,
|
||||
null, null, dep, account, password);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.ChangeServiceConfig2(service, WINSVC.SERVICE_CONFIG_DESCRIPTION, desc);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall the service.
|
||||
*
|
||||
* @throws java.lang.Exception
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean uninstall() {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINSVC.SERVICE_ALL_ACCESS);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.DeleteService(service);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the ServiceControlManager to start the service.
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean start() {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(service != null) {
|
||||
success = advapi32.StartService(service, 0, null);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the ServiceControlManager to stop the service.
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean stop() throws Exception {
|
||||
Advapi32 advapi32;
|
||||
Pointer serviceManager, service;
|
||||
Advapi32.SERVICE_STATUS serviceStatus;
|
||||
boolean success = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(serviceManager != null) {
|
||||
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
|
||||
|
||||
if(service != null) {
|
||||
serviceStatus = new Advapi32.SERVICE_STATUS();
|
||||
success = advapi32.ControlService(service, WINSVC.SERVICE_CONTROL_STOP, serviceStatus);
|
||||
advapi32.CloseServiceHandle(service);
|
||||
}
|
||||
advapi32.CloseServiceHandle(serviceManager);
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the service, connect to the ServiceControlManager.
|
||||
*/
|
||||
public void init() {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_TABLE_ENTRY entry;
|
||||
|
||||
serviceMain = new ServiceMain();
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
entry = new Advapi32.SERVICE_TABLE_ENTRY();
|
||||
entry.lpServiceName = serviceName;
|
||||
entry.lpServiceProc = serviceMain;
|
||||
|
||||
advapi32.StartServiceCtrlDispatcher(entry.toArray(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a handle to the ServiceControlManager.
|
||||
*
|
||||
* @param machine name of the machine or null for localhost
|
||||
* @param access access flags
|
||||
* @return handle to ServiceControlManager or null when failed
|
||||
*/
|
||||
private Pointer openServiceControlManager(String machine, int access) {
|
||||
Pointer handle = null;
|
||||
Advapi32 advapi32;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = advapi32.OpenSCManager(machine, null, access);
|
||||
return(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report service status to the ServiceControlManager.
|
||||
*
|
||||
* @param status status
|
||||
* @param win32ExitCode exit code
|
||||
* @param waitHint time to wait
|
||||
*/
|
||||
private void reportStatus(int status, int win32ExitCode, int waitHint) {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_STATUS serviceStatus;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
serviceStatus = new Advapi32.SERVICE_STATUS();
|
||||
serviceStatus.dwServiceType = WINNT.SERVICE_WIN32_OWN_PROCESS;
|
||||
serviceStatus.dwControlsAccepted = WINSVC.SERVICE_ACCEPT_STOP | WINSVC.SERVICE_ACCEPT_SHUTDOWN;
|
||||
serviceStatus.dwWin32ExitCode = win32ExitCode;
|
||||
serviceStatus.dwWaitHint = waitHint;
|
||||
serviceStatus.dwCurrentState = status;
|
||||
|
||||
advapi32.SetServiceStatus(serviceStatusHandle, serviceStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when service is starting.
|
||||
*/
|
||||
public abstract void onStart();
|
||||
|
||||
/*
|
||||
* Called when service should stop.
|
||||
*/
|
||||
public abstract void onStop();
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the service main function.
|
||||
*/
|
||||
private class ServiceMain implements Advapi32.SERVICE_MAIN_FUNCTION {
|
||||
|
||||
/**
|
||||
* Called when the service is starting.
|
||||
*
|
||||
* @param dwArgc number of arguments
|
||||
* @param lpszArgv pointer to arguments
|
||||
*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv) {
|
||||
Advapi32 advapi32;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
serviceControl = new ServiceControl();
|
||||
serviceStatusHandle = advapi32.RegisterServiceCtrlHandlerEx(serviceName, serviceControl, null);
|
||||
|
||||
reportStatus(WINSVC.SERVICE_START_PENDING, WINERROR.NO_ERROR, 3000);
|
||||
reportStatus(WINSVC.SERVICE_RUNNING, WINERROR.NO_ERROR, 0);
|
||||
|
||||
onStart();
|
||||
|
||||
try {
|
||||
synchronized(waitObject) {
|
||||
waitObject.wait();
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
reportStatus(WINSVC.SERVICE_STOPPED, WINERROR.NO_ERROR, 0);
|
||||
|
||||
// Avoid returning from ServiceMain, which will cause a crash
|
||||
// See http://support.microsoft.com/kb/201349, which recommends
|
||||
// having init() wait for this thread.
|
||||
// Waiting on this thread in init() won't fix the crash, though.
|
||||
//System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the service control function.
|
||||
*/
|
||||
private class ServiceControl implements Advapi32.HandlerEx {
|
||||
|
||||
/**
|
||||
* Called when the service get a control code.
|
||||
*
|
||||
* @param dwControl
|
||||
* @param dwEventType
|
||||
* @param lpEventData
|
||||
* @param lpContext
|
||||
*/
|
||||
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext) {
|
||||
switch(dwControl) {
|
||||
case WINSVC.SERVICE_CONTROL_STOP:
|
||||
case WINSVC.SERVICE_CONTROL_SHUTDOWN:
|
||||
reportStatus(WINSVC.SERVICE_STOP_PENDING, WINERROR.NO_ERROR, 5000);
|
||||
onStop();
|
||||
synchronized(waitObject) {
|
||||
waitObject.notifyAll();
|
||||
}
|
||||
}
|
||||
return WINERROR.NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# placeholder
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="platform" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project platform.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<condition property="tests.platform" value="test-win32">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<target name="test" description="Run unit tests." if="tests.platform">
|
||||
<antcall target="${tests.platform}" />
|
||||
</target>
|
||||
<target name="test-report">
|
||||
<junitreport todir="${build.test.results.dir}">
|
||||
<fileset dir="${build.test.results.dir}">
|
||||
<include name="TEST-*.xml"/>
|
||||
</fileset>
|
||||
<report todir="${build.test.results.dir}"/>
|
||||
</junitreport>
|
||||
<echo message="View test report in file://${build.test.results.dir}/index.html" />
|
||||
</target>
|
||||
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
</project>
|
||||
@@ -0,0 +1,541 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -0,0 +1,59 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>platform</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,135 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.W32FileMonitor;
|
||||
|
||||
/** Provides notification of file system changes. Actual capabilities may
|
||||
* vary slightly by platform.
|
||||
* <p>
|
||||
* Watched files which are removed from the filesystem are no longer watched.
|
||||
* @author twall
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class FileMonitor {
|
||||
|
||||
public static final int FILE_CREATED = 0x1;
|
||||
public static final int FILE_DELETED = 0x2;
|
||||
public static final int FILE_MODIFIED = 0x4;
|
||||
public static final int FILE_ACCESSED = 0x8;
|
||||
public static final int FILE_NAME_CHANGED_OLD = 0x10;
|
||||
public static final int FILE_NAME_CHANGED_NEW = 0x20;
|
||||
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
|
||||
public static final int FILE_SIZE_CHANGED = 0x40;
|
||||
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
|
||||
public static final int FILE_SECURITY_CHANGED = 0x100;
|
||||
public static final int FILE_ANY = 0x1FF;
|
||||
|
||||
public interface FileListener {
|
||||
public void fileChanged(FileEvent e);
|
||||
}
|
||||
|
||||
public class FileEvent extends EventObject {
|
||||
private final File file;
|
||||
private final int type;
|
||||
public FileEvent(File file, int type) {
|
||||
super(FileMonitor.this);
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
public File getFile() { return file; }
|
||||
public int getType() { return type; }
|
||||
public String toString() {
|
||||
return "FileEvent: " + file + ":" + type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<File, Integer> watched = new HashMap<File, Integer>();
|
||||
private List<FileListener> listeners = new ArrayList<FileListener>();
|
||||
|
||||
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
|
||||
protected abstract void unwatch(File file);
|
||||
public abstract void dispose();
|
||||
|
||||
public void addWatch(File dir) throws IOException {
|
||||
addWatch(dir, FILE_ANY);
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask) throws IOException {
|
||||
addWatch(dir, mask, dir.isDirectory());
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
|
||||
watched.put(dir, new Integer(mask));
|
||||
watch(dir, mask, recursive);
|
||||
}
|
||||
|
||||
public void removeWatch(File file) {
|
||||
if (watched.remove(file) != null) {
|
||||
unwatch(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notify(FileEvent e) {
|
||||
for (FileListener listener : listeners) {
|
||||
listener.fileChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addFileListener(FileListener listener) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.add(listener);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
public synchronized void removeFileListener(FileListener x) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.remove(x);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
for (File watchedFile : watched.keySet()) {
|
||||
removeWatch(watchedFile);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileMonitor INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileMonitor();
|
||||
}
|
||||
else {
|
||||
throw new Error("FileMonitor not implemented for " + os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileMonitor getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
}
|
||||
+44
-56
@@ -10,19 +10,27 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import com.sun.jna.examples.win32.Shell32;
|
||||
import com.sun.jna.examples.win32.Shell32.SHFILEOPSTRUCT;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.mac.MacFileUtils;
|
||||
import com.sun.jna.platform.win32.W32FileUtils;
|
||||
|
||||
/** Miscellaneous file utils not provided for by Java. */
|
||||
public abstract class FileUtils {
|
||||
|
||||
public boolean hasTrash() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Move the given file to the system trash, if one is available.
|
||||
Returns whether the operation was successful.
|
||||
Throws an exception on failure.
|
||||
*/
|
||||
public abstract boolean moveToTrash(File[] files);
|
||||
public abstract void moveToTrash(File[] files) throws IOException;
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
@@ -43,49 +51,11 @@ public abstract class FileUtils {
|
||||
|
||||
public static FileUtils getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class W32FileUtils extends FileUtils {
|
||||
public boolean moveToTrash(File[] files) {
|
||||
Shell32 shell = Shell32.INSTANCE;
|
||||
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
|
||||
fileop.wFunc = Shell32.FO_DELETE;
|
||||
String[] paths = new String[files.length];
|
||||
for (int i=0;i < paths.length;i++) {
|
||||
paths[i] = files[i].getAbsolutePath();
|
||||
}
|
||||
fileop.pFrom = fileop.encodePaths(paths);
|
||||
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
|
||||
return shell.SHFileOperation(fileop) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MacFileUtils extends FileUtils {
|
||||
public boolean moveToTrash(File[] files) {
|
||||
// TODO: account for stuff not on the same volume
|
||||
// Also should suffix file by time moved to trash
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (trash.exists()) {
|
||||
boolean success = true;
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DefaultFileUtils extends FileUtils {
|
||||
/** The default implementation attempts to move the file to
|
||||
* the desktop "Trash" folder.
|
||||
*/
|
||||
public boolean moveToTrash(File[] files) {
|
||||
|
||||
private File getTrashDirectory() {
|
||||
// very simple implementation. should take care of renaming when
|
||||
// a file already exists, or any other platform-specific behavior
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
@@ -98,21 +68,39 @@ public abstract class FileUtils {
|
||||
trash = new File(desktop, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(desktop, "Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(System.getProperty("fileutils.trash", "Trash"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trash.exists()) {
|
||||
boolean success = true;
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target))
|
||||
success = false;
|
||||
}
|
||||
return success;
|
||||
return trash;
|
||||
}
|
||||
|
||||
public boolean hasTrash() {
|
||||
return getTrashDirectory().exists();
|
||||
}
|
||||
|
||||
/** The default implementation attempts to move the file to
|
||||
* the desktop "Trash" folder.
|
||||
*/
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
File trash = getTrashDirectory();
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
-40
@@ -10,15 +10,17 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.KeyEvent;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
|
||||
/** Provide access to the local keyboard state. Note that this is meaningless
|
||||
* on a headless system and some VNC setups.
|
||||
@@ -35,19 +37,16 @@ public class KeyboardUtils {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("KeyboardUtils requires a keyboard");
|
||||
}
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
if (Platform.isWindows()) {
|
||||
INSTANCE = new W32KeyboardUtils();
|
||||
}
|
||||
else if (os.startsWith("Mac")) {
|
||||
else if (Platform.isMac()) {
|
||||
INSTANCE = new MacKeyboardUtils();
|
||||
throw new UnsupportedOperationException("No support (yet) for " + os);
|
||||
}
|
||||
else if (os.startsWith("Linux") || os.startsWith("SunOS")) {
|
||||
INSTANCE = new X11KeyboardUtils();
|
||||
throw new UnsupportedOperationException("No support (yet) for "
|
||||
+ System.getProperty("os.name"));
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("No support for " + os);
|
||||
INSTANCE = new X11KeyboardUtils();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,30 +72,30 @@ public class KeyboardUtils {
|
||||
}
|
||||
if (code == KeyEvent.VK_SHIFT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RSHIFT;
|
||||
return WinUser.VK_RSHIFT;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LSHIFT;
|
||||
return WinUser.VK_LSHIFT;
|
||||
}
|
||||
return User32.VK_SHIFT;
|
||||
return WinUser.VK_SHIFT;
|
||||
}
|
||||
if (code == KeyEvent.VK_CONTROL) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RCONTROL;
|
||||
return WinUser.VK_RCONTROL;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LCONTROL;
|
||||
return WinUser.VK_LCONTROL;
|
||||
}
|
||||
return User32.VK_CONTROL;
|
||||
return WinUser.VK_CONTROL;
|
||||
}
|
||||
if (code == KeyEvent.VK_ALT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RMENU;
|
||||
return WinUser.VK_RMENU;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LMENU;
|
||||
return WinUser.VK_LMENU;
|
||||
}
|
||||
return User32.VK_MENU;
|
||||
return WinUser.VK_MENU;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -111,7 +110,7 @@ public class KeyboardUtils {
|
||||
}
|
||||
}
|
||||
private static class X11KeyboardUtils extends NativeKeyboardUtils {
|
||||
// TODO: map from X11 keycodes to java keycodes
|
||||
// TODO: fully map from X11 keycodes to java keycodes
|
||||
// this is a minimal implementation
|
||||
private int toKeySym(int code, int location) {
|
||||
if (code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z)
|
||||
@@ -142,25 +141,22 @@ public class KeyboardUtils {
|
||||
}
|
||||
public boolean isPressed(int keycode, int location) {
|
||||
X11 lib = X11.INSTANCE;
|
||||
Pointer dpy = lib.XOpenDisplay(null);
|
||||
Display dpy = lib.XOpenDisplay(null);
|
||||
if (dpy == null) {
|
||||
throw new Error("Can't open X Display");
|
||||
}
|
||||
try {
|
||||
byte[] keys = new byte[32];
|
||||
int result = lib.XQueryKeymap(dpy, keys);
|
||||
if (result != 0) {
|
||||
byte[] buf = new byte[1024];
|
||||
lib.XGetErrorText(dpy, result, buf, buf.length);
|
||||
throw new RuntimeException("Can't query keyboard: " + Native.toString(buf));
|
||||
}
|
||||
else {
|
||||
int keysym = toKeySym(keycode, location);
|
||||
for (int code=5;code < 256;code++) {
|
||||
int idx = code / 8;
|
||||
int shift = code % 8;
|
||||
if ((keys[idx] & (1 << shift)) != 0) {
|
||||
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0);
|
||||
if (sym == keysym)
|
||||
return true;
|
||||
}
|
||||
// Ignore the return value
|
||||
lib.XQueryKeymap(dpy, keys);
|
||||
int keysym = toKeySym(keycode, location);
|
||||
for (int code=5;code < 256;code++) {
|
||||
int idx = code / 8;
|
||||
int shift = code % 8;
|
||||
if ((keys[idx] & (1 << shift)) != 0) {
|
||||
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
|
||||
if (sym == keysym)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
/* Copyright (c) 2007 Olivier Chafik, All Rights Reserved
|
||||
* Copyright (c) 2008 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.MultiPixelPackedSampleModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.SinglePixelPackedSampleModel;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Methods that are useful to decompose a raster into a set of rectangles.
|
||||
* An occupied pixel has two possible meanings, depending on the raster :
|
||||
* <ul>
|
||||
* <li>if the raster has an alpha layer, occupied means with alpha not null</li>
|
||||
* <li>if the raster doesn't have any alpha layer, occupied means not completely black</li>
|
||||
* </ul>
|
||||
* @author Olivier Chafik
|
||||
*/
|
||||
public class RasterRangesUtils {
|
||||
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
|
||||
private static final int[] subColMasks = new int[] {
|
||||
0x0080, 0x0040, 0x0020, 0x0010,
|
||||
0x0008, 0x0004, 0x0002, 0x0001
|
||||
};
|
||||
|
||||
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((Rectangle)o1).x - ((Rectangle)o2).x;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstraction of a sink for ranges.
|
||||
*/
|
||||
public static interface RangesOutput {
|
||||
/**
|
||||
* Output a rectangular range.
|
||||
* @param x x coordinate of the top-left corner of the range
|
||||
* @param y y coordinate of the top-left corner of the range
|
||||
* @param w width of the range
|
||||
* @param h height of the range
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
boolean outputRange(int x, int y, int w, int h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs ranges of occupied pixels.
|
||||
* In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null.
|
||||
* In a raster without alpha layer, a pixel is occupied if it is not completely black.
|
||||
* @param raster image to be segmented in non black or non-transparent ranges
|
||||
* @param out destination of the non null ranges
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(Raster raster, RangesOutput out) {
|
||||
Rectangle bounds = raster.getBounds();
|
||||
SampleModel sampleModel = raster.getSampleModel();
|
||||
boolean hasAlpha = sampleModel.getNumBands() == 4;
|
||||
|
||||
// Try to use the underlying data array directly for a few common raster formats
|
||||
if (raster.getParent() == null && bounds.x == 0 && bounds.y == 0) {
|
||||
// No support for subraster (as obtained with Image.getSubimage(...))
|
||||
|
||||
DataBuffer data = raster.getDataBuffer();
|
||||
if (data.getNumBanks() == 1) {
|
||||
// There is always a single bank for all BufferedImage types, except maybe TYPE_CUSTOM
|
||||
|
||||
if (sampleModel instanceof MultiPixelPackedSampleModel) {
|
||||
MultiPixelPackedSampleModel packedSampleModel = (MultiPixelPackedSampleModel)sampleModel;
|
||||
if (packedSampleModel.getPixelBitStride() == 1) {
|
||||
// TYPE_BYTE_BINARY
|
||||
return outputOccupiedRangesOfBinaryPixels(((DataBufferByte)data).getData(), bounds.width, bounds.height, out);
|
||||
}
|
||||
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
|
||||
if (sampleModel.getDataType() == DataBuffer.TYPE_INT) {
|
||||
// TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR or TYPE_INT_RGB
|
||||
return outputOccupiedRanges(((DataBufferInt)data).getData(), bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
|
||||
}
|
||||
// TODO could easily handle cases of TYPE_USHORT_GRAY and TYPE_BYTE_GRAY.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback behaviour : copy pixels of raster
|
||||
int[] pixels = raster.getPixels(0, 0, bounds.width, bounds.height, (int[])null);
|
||||
return outputOccupiedRanges(pixels, bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the non-null values of a binary image as ranges of contiguous values.
|
||||
* @param binaryBits byte-packed binary bits of an image
|
||||
* @param w width of the image (in pixels)
|
||||
* @param h height of the image
|
||||
* @param out
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
int scanlineBytes = binaryBits.length / h;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int rowOffsetBytes = row * scanlineBytes;
|
||||
int startCol = -1;
|
||||
// Look at each batch of 8 columns in this row
|
||||
for (int byteCol = 0; byteCol < scanlineBytes; byteCol++) {
|
||||
int firstByteCol = byteCol << 3;
|
||||
byte byteColBits = binaryBits[rowOffsetBytes + byteCol];
|
||||
if (byteColBits == 0) {
|
||||
// all 8 bits are zeroes
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, firstByteCol - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
} else if (byteColBits == 0xff) {
|
||||
// all 8 bits are ones
|
||||
if (startCol < 0) {
|
||||
// start of new region
|
||||
startCol = firstByteCol;
|
||||
}
|
||||
} else {
|
||||
// mixed case : some bits are ones, others are zeroes
|
||||
for (int subCol = 0; subCol < 8; subCol++) {
|
||||
int col = firstByteCol | subCol;
|
||||
if ((byteColBits & subColMasks[subCol]) != 0) {
|
||||
if (startCol < 0) {
|
||||
// start of new region
|
||||
startCol = col;
|
||||
}
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, col - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region
|
||||
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the occupied values of an integer-pixels image as ranges of contiguous values.
|
||||
* A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null.
|
||||
* @param pixels integer values of the pixels of an image
|
||||
* @param w width of the image (in pixels)
|
||||
* @param h height of the image
|
||||
* @param occupationMask mask used to select which bits are used in a pixel to check its occupied status. 0xff000000 would only take the alpha layer into account, for instance.
|
||||
* @param out where to output all the contiguous ranges of non occupied pixels
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int idxOffset = row * w;
|
||||
int startCol = -1;
|
||||
|
||||
for (int col = 0; col < w; col++) {
|
||||
if ((pixels[idxOffset + col] & occupationMask) != 0) {
|
||||
if (startCol < 0) {
|
||||
startCol = col;
|
||||
}
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
curLine.add(new Rectangle(startCol, row, col-startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region of current row
|
||||
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current) {
|
||||
Set<Rectangle> unmerged = new HashSet<Rectangle>(prev);
|
||||
if (!prev.isEmpty() && !current.isEmpty()) {
|
||||
Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]);
|
||||
Rectangle[] cr = current.toArray(new Rectangle[current.size()]);
|
||||
int ipr = 0;
|
||||
int icr = 0;
|
||||
while (ipr < pr.length && icr < cr.length) {
|
||||
while (cr[icr].x < pr[ipr].x) {
|
||||
if (++icr == cr.length) {
|
||||
return unmerged;
|
||||
}
|
||||
}
|
||||
if (cr[icr].x == pr[ipr].x && cr[icr].width == pr[ipr].width) {
|
||||
unmerged.remove(pr[ipr]);
|
||||
cr[icr].y = pr[ipr].y;
|
||||
cr[icr].height = pr[ipr].height + 1;
|
||||
++icr;
|
||||
}
|
||||
else {
|
||||
++ipr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unmerged;
|
||||
}
|
||||
|
||||
}
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+5
-4
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Component;
|
||||
@@ -38,6 +38,7 @@ import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFileChooser;
|
||||
@@ -162,7 +163,7 @@ public abstract class DragHandler
|
||||
try {
|
||||
// getTransferable is available during drag only on 1.5+
|
||||
return (Transferable)
|
||||
e.getClass().getMethod("getTransferable", null).invoke(e, null);
|
||||
e.getClass().getMethod("getTransferable", (Class[])null).invoke(e, (Object[])null);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
// Method not available
|
||||
@@ -179,7 +180,7 @@ public abstract class DragHandler
|
||||
private Component dragSource;
|
||||
private GhostedDragImage ghost;
|
||||
private Point imageOffset;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private float ghostAlpha = DEFAULT_GHOST_ALPHA;
|
||||
|
||||
/** Enable drags from the given component, supporting the actions in
|
||||
@@ -529,4 +530,4 @@ public abstract class DragHandler
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
@@ -88,7 +88,7 @@ import java.util.Set;
|
||||
public abstract class DropHandler implements DropTargetListener {
|
||||
|
||||
private int acceptedActions;
|
||||
private List acceptedFlavors;
|
||||
private List<DataFlavor> acceptedFlavors;
|
||||
private DropTarget dropTarget;
|
||||
private boolean active = true;
|
||||
private DropTargetPainter painter;
|
||||
@@ -347,7 +347,7 @@ public abstract class DropHandler implements DropTargetListener {
|
||||
* constructor.
|
||||
*/
|
||||
protected boolean isSupported(DataFlavor[] flavors) {
|
||||
Set set = new HashSet(Arrays.asList(flavors));
|
||||
Set<DataFlavor> set = new HashSet<DataFlavor>(Arrays.asList(flavors));
|
||||
set.retainAll(acceptedFlavors);
|
||||
return !set.isEmpty();
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
+5
-8
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@@ -19,21 +19,17 @@ import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.DropTargetDragEvent;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.Area;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Provide a ghosted drag image for use during drags where
|
||||
* {@link DragSource#isDragImageSupported} returns false.<p>
|
||||
@@ -60,6 +56,7 @@ public class GhostedDragImage {
|
||||
// FIXME ensure gc is compatible (X11)
|
||||
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
|
||||
dragImage = new Window(JOptionPane.getRootFrame(), gc) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public void paint(Graphics g) {
|
||||
icon.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides integrated, extended drag and drop functionality,
|
||||
allowing ghosted drag images to be used on all platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
// TODO: use native API for moving to trash (if any)
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for the OS X platform.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides cross-platform utilities based on platform-specific libraries.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for Unix and X11-based platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface BaseTSD extends StdCallLibrary {
|
||||
/**
|
||||
* Signed long type for pointer precision.
|
||||
* Use when casting a pointer to a long to perform pointer arithmetic.
|
||||
*/
|
||||
public static class LONG_PTR extends IntegerType {
|
||||
public LONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SSIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public DWORD_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
public static class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Crypt32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Crypt32 extends StdCallLibrary {
|
||||
|
||||
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
|
||||
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
|
||||
* structure. Typically, only a user with the same logon credential as the encrypter
|
||||
* can decrypt the data. In addition, the encryption and decryption usually must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
|
||||
* @param szDataDescr
|
||||
* String with a readable description of the data to be encrypted. This description
|
||||
* string is included with the encrypted data. This parameter is optional and can
|
||||
* be set to NULL, except on Windows 2000.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
|
||||
* phase must also be used in the decryption phase. This parameter can be set to NULL
|
||||
* for no additional entropy.
|
||||
* @param pvReserved
|
||||
* Reserved for future use and must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL in both the encryption and decryption
|
||||
* phases.
|
||||
* @param dwFlags
|
||||
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
|
||||
* CRYPTPROTECT_VERIFY_PROTECTION.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
|
||||
* finished using the DATA_BLOB structure, free its pbData member by calling the
|
||||
* LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns TRUE. If the function fails,
|
||||
* it returns FALSE. For extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
|
||||
/**
|
||||
* The CryptUnprotectData function decrypts and does an integrity check of the data in
|
||||
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
|
||||
* encrypter can decrypt the data. In addition, the encryption and decryption must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
|
||||
* structure's cbData member holds the length of the pbData member's byte string that
|
||||
* contains the text to be encrypted.
|
||||
* @param szDataDescr
|
||||
* Pointer to a string-readable description of the encrypted data included with the
|
||||
* encrypted data. This parameter can be set to NULL. When you have finished using
|
||||
* ppszDataDescr, free it by calling the LocalFree function.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used when the data was encrypted. This parameter can be set to NULL;
|
||||
* however, if an optional entropy DATA_BLOB structure was used in the encryption
|
||||
* phase, that same DATA_BLOB structure must be used for the decryption phase.
|
||||
* @param pvReserved
|
||||
* Reserved for future use; must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL.
|
||||
* @param dwFlags
|
||||
* DWORD value that specifies options for this function. This parameter can be zero,
|
||||
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
|
||||
* When you have finished using the DATA_BLOB structure, free its pbData member by
|
||||
* calling the LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is TRUE. If the function fails, the
|
||||
* return value is FALSE.
|
||||
*/
|
||||
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Crypt32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Crypt32Util {
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data) {
|
||||
return cryptProtectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data with optional flags.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, int flags) {
|
||||
return cryptProtectData(data, null, flags, "", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param description
|
||||
* Optional description.
|
||||
* @param prompt
|
||||
* Prompt structure.
|
||||
* @return
|
||||
* Protected bytes.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
|
||||
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataProtected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
|
||||
pEntropy, null, prompt, flags, pDataProtected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataProtected.getData();
|
||||
} finally {
|
||||
if (pDataProtected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data) {
|
||||
return cryptUnprotectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, int flags) {
|
||||
return cryptUnprotectData(data, null, flags, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param prompt
|
||||
* Optional prompt structure.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
|
||||
CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataUnprotected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
PointerByReference pDescription = new PointerByReference();
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
|
||||
pEntropy, null, prompt, flags, pDataUnprotected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataUnprotected.getData();
|
||||
} finally {
|
||||
if (pDataUnprotected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
|
||||
}
|
||||
if (pDescription.getValue() != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
|
||||
/**
|
||||
* Ported from DsGetDC.h.
|
||||
* Windows SDK 6.0a
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface DsGetDC extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
* function to receive data about a domain controller.
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
|
||||
* is returned, if available. If the DNS-style name is not available, the
|
||||
* flat-style name (for example, "\\phoenix") is returned. This example would apply
|
||||
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
|
||||
* IP family of protocols.
|
||||
*/
|
||||
public WString DomainControllerName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the address of the discovered
|
||||
* domain controller. The address is prefixed with "\\". This WString is one of the
|
||||
* types defined by the DomainControllerAddressType member.
|
||||
*/
|
||||
public WString DomainControllerAddress;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the DomainControllerAddress member.
|
||||
*/
|
||||
public int DomainControllerAddressType;
|
||||
/**
|
||||
* The GUID of the domain. This member is zero if the domain controller does not have
|
||||
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
|
||||
* controller.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain. The
|
||||
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
|
||||
* the flat-style name, for example, "fabrikam", is returned. This name may be different
|
||||
* than the requested domain name if the domain has been renamed.
|
||||
*/
|
||||
public WString DomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
|
||||
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
|
||||
*/
|
||||
public WString DnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site where the
|
||||
* domain controller is located. This member may be NULL if the domain controller is
|
||||
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
|
||||
* controller.
|
||||
*/
|
||||
public WString DcSiteName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site that the
|
||||
* computer belongs to. The computer is specified in the ComputerName parameter passed
|
||||
* to DsGetDcName. This member may be NULL if the site that contains the computer
|
||||
* cannot be found; for example, if the DS administrator has not associated the
|
||||
* subnet that the computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to DOMAIN_CONTROLLER_INFO.
|
||||
*/
|
||||
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
}
|
||||
|
||||
/**
|
||||
* Domain is a member of the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_IN_FOREST = 0x0001;
|
||||
/**
|
||||
* Domain is directly trusted.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
|
||||
/**
|
||||
* Domain is root of a tree in the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
/**
|
||||
* Domain is the primary domain of queried server.
|
||||
*/
|
||||
public static final int DS_DOMAIN_PRIMARY = 0x0008;
|
||||
/**
|
||||
* Primary domain is running in native mode.
|
||||
*/
|
||||
public static final int DS_DOMAIN_NATIVE_MODE = 0x0010;
|
||||
/**
|
||||
* Domain is directly trusting.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
|
||||
/**
|
||||
* Valid domain flags.
|
||||
*/
|
||||
public static final int DS_DOMAIN_VALID_FLAGS =
|
||||
DS_DOMAIN_IN_FOREST |
|
||||
DS_DOMAIN_DIRECT_OUTBOUND |
|
||||
DS_DOMAIN_TREE_ROOT |
|
||||
DS_DOMAIN_PRIMARY |
|
||||
DS_DOMAIN_NATIVE_MODE |
|
||||
DS_DOMAIN_DIRECT_INBOUND;
|
||||
|
||||
/**
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
|
||||
* contain trust data for a domain.
|
||||
*/
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
|
||||
*/
|
||||
public WString NetbiosDomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
|
||||
*/
|
||||
public WString DnsDomainName;
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
*/
|
||||
public NativeLong ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustAttributes;
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID.ByReference DomainSid;
|
||||
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
};
|
||||
|
||||
/**
|
||||
* A pointer to an array of DS_DOMAIN_TRUSTS.
|
||||
*/
|
||||
public static class PDS_DOMAIN_TRUSTS extends Structure {
|
||||
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS.ByReference t;
|
||||
|
||||
/**
|
||||
* Returns domain trusts.
|
||||
* @param count
|
||||
* Number of domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
|
||||
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
|
||||
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>gdi32.dll</code>. */
|
||||
public interface GDI32 extends StdCallLibrary {
|
||||
|
||||
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ExtCreateRegion function creates a region from the specified region and transformation data.
|
||||
* @param lpXform
|
||||
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
|
||||
* the identity transformation is used.
|
||||
* @param nCount
|
||||
* Specifies the number of bytes pointed to by lpRgnData.
|
||||
* @param lpRgnData
|
||||
* Pointer to a RGNDATA structure that contains the region data in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the value of the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
|
||||
|
||||
/**
|
||||
* The CombineRgn function combines two regions and stores the result in a third region.
|
||||
* The two regions are combined according to the specified mode.
|
||||
* @param hrgnDest
|
||||
* Handle to a new region with dimensions defined by combining two other regions.
|
||||
* @param hrgnSrc1
|
||||
* Handle to the first of two regions to be combined.
|
||||
* @param hrgnSrc2
|
||||
* Handle to the second of two regions to be combined.
|
||||
* @param fnCombineMode
|
||||
* Specifies a mode indicating how the two regions will be combined.
|
||||
* @return
|
||||
* The return value specifies the type of the resulting region.
|
||||
*/
|
||||
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
|
||||
int fnCombineMode);
|
||||
|
||||
/**
|
||||
* The CreateRectRgn function creates a rectangular region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nWidthEllipse
|
||||
* Specifies the width of the ellipse used to create the rounded corners in logical units.
|
||||
* @param nHeightEllipse
|
||||
* Specifies the height of the ellipse used to create the rounded corners in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
/**
|
||||
* The CreatePolyPolygonRgn function creates a region consisting of a series
|
||||
* of polygons. The polygons can overlap.
|
||||
* @param lppt
|
||||
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
|
||||
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
|
||||
* specified only once.
|
||||
* @param lpPolyCounts
|
||||
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
|
||||
* in the array pointed to by lppt.
|
||||
* @param nCount
|
||||
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
|
||||
* @param fnPolyFillMode
|
||||
* Specifies the fill mode used to determine which pixels are in the region.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
|
||||
int nCount, int fnPolyFillMode);
|
||||
|
||||
/**
|
||||
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
|
||||
* @param hrgn
|
||||
* Handle to the region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @param x
|
||||
* Specifies the x-coordinate, in logical units, of the point to be set.
|
||||
* @param y
|
||||
* Specifies the y-coordinate, in logical units, of the point to be set.
|
||||
* @param crColor
|
||||
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
|
||||
* This value may differ from the color specified by crColor; that occurs when an exact match for the
|
||||
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
|
||||
* information, call GetLastError. This can be the following value.
|
||||
*/
|
||||
int SetPixel(HDC hDC, int x, int y, int crColor);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
|
||||
* @param hDC
|
||||
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
|
||||
* application's current screen.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to a memory DC.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HDC CreateCompatibleDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The DeleteDC function deletes the specified device context (DC).
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
|
||||
* sets the bitmap bits.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param lpbmih
|
||||
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
|
||||
* @param fdwInit
|
||||
* Specifies how the system initializes the bitmap bits.
|
||||
* @param lpbInit
|
||||
* Pointer to an array of bytes containing the initial bitmap data.
|
||||
* @param lpbmi
|
||||
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
|
||||
* the array pointed to by the lpbInit parameter.
|
||||
* @param fuUsage
|
||||
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
|
||||
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
|
||||
* fuUsage parameter must be one of the following values.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
|
||||
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
|
||||
|
||||
/**
|
||||
* The CreateDIBSection function creates a DIB that applications can write to directly.
|
||||
* The function gives you a pointer to the location of the bitmap bit values. You can supply
|
||||
* a handle to a file-mapping object that the function will use to create the bitmap, or you
|
||||
* can let the system allocate the memory for the bitmap.
|
||||
* @param hDC
|
||||
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
|
||||
* device context's logical palette to initialize the DIB colors.
|
||||
* @param pbmi
|
||||
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
|
||||
* the bitmap dimensions and colors.
|
||||
* @param iUsage
|
||||
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
|
||||
* pointed to by pbmi (either logical palette indexes or literal RGB values).
|
||||
* @param ppvBits
|
||||
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
|
||||
* @param hSection
|
||||
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
|
||||
* @param dwOffset
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
* @return
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
*/
|
||||
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
|
||||
PointerByReference ppvBits, Pointer hSection, int dwOffset);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
|
||||
* associated with the specified device context.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param width
|
||||
* Specifies the bitmap width, in pixels.
|
||||
* @param height
|
||||
* Specifies the bitmap height, in pixels.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
|
||||
|
||||
/**
|
||||
* The SelectObject function selects an object into the specified device context (DC).
|
||||
* The new object replaces the previous object of the same type.
|
||||
* @param hDC
|
||||
* Handle to the DC.
|
||||
* @param hGDIObj
|
||||
* Handle to the object to be selected.
|
||||
* @return
|
||||
* If the selected object is not a region and the function succeeds, the return value
|
||||
* is a handle to the object being replaced. If the selected object is a region and the
|
||||
* function succeeds, the return value is one of the REGION values.
|
||||
*/
|
||||
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
|
||||
|
||||
/**
|
||||
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
|
||||
* freeing all system resources associated with the object. After the object is deleted, the
|
||||
* specified handle is no longer valid.
|
||||
* @param hObject
|
||||
* Handle to a logical pen, brush, font, bitmap, region, or palette.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteObject(HANDLE hObject);
|
||||
|
||||
/** The GetDeviceCaps function retrieves device-specific information for
|
||||
* the specified device.
|
||||
* @param hdc A handle to the DC.
|
||||
* @param nIndex The item to be returned.
|
||||
* @return
|
||||
* The return value specifies the value of the desired item. When
|
||||
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
|
||||
* 16bpp, the return value is 16.
|
||||
*/
|
||||
int GetDeviceCaps(HDC hdc, int nIndex);
|
||||
|
||||
/** The GetDIBits function retrieves the bits fo the specified compatible
|
||||
* bitmap and copies them into a buffer as a DIB using the specified
|
||||
* format.
|
||||
* @param hdc A handle to the device context.
|
||||
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
|
||||
* (DDB).
|
||||
* @param uStartScan The first scan line to retrieve
|
||||
* @param cScanLines The number of scan lines to retrieve.
|
||||
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
|
||||
* this parameter is <code>null</code>, the function passes the dimensions
|
||||
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
|
||||
* by the <i>lpbi</i> parameter.
|
||||
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
|
||||
* the desired format for the DIB data.
|
||||
* @param uUsage The format of the bmiColors member of the {@link
|
||||
* BITMAPINFO} structure.
|
||||
*/
|
||||
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Guid extends StdCallLibrary {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public static class ByReference extends GUID implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public GUID() {
|
||||
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,957 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX;
|
||||
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HMODULE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>kernel32.dll</code>. */
|
||||
public interface Kernel32 extends StdCallLibrary {
|
||||
|
||||
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Frees the specified local memory object and invalidates its handle.
|
||||
* @param hLocal
|
||||
* A handle to the local memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL.
|
||||
* If the function fails, the return value is equal to a handle to the local memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalFree(Pointer hLocal);
|
||||
|
||||
/**
|
||||
* Frees the specified global memory object and invalidates its handle.
|
||||
* @param hGlobal
|
||||
* A handle to the global memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL
|
||||
* If the function fails, the return value is equal to a handle to the global memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer GlobalFree(Pointer hGlobal);
|
||||
|
||||
/**
|
||||
* The GetModuleHandle function retrieves a module handle for the specified module
|
||||
* if the file has been mapped into the address space of the calling process.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the module
|
||||
* (either a .dll or .exe file).
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the specified module.
|
||||
* If the function fails, the return value is NULL. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
HMODULE GetModuleHandle(String name);
|
||||
|
||||
/**
|
||||
* The GetSystemTime function retrieves the current system date and time.
|
||||
* The system time is expressed in Coordinated Universal Time (UTC).
|
||||
* @param lpSystemTime
|
||||
* Pointer to a SYSTEMTIME structure to receive the current system date and time.
|
||||
*/
|
||||
void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime);
|
||||
|
||||
/**
|
||||
* The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
|
||||
* @return
|
||||
* Number of milliseconds that have elapsed since the system was started.
|
||||
*/
|
||||
int GetTickCount();
|
||||
|
||||
/**
|
||||
* The GetCurrentThreadId function retrieves the thread identifier of the calling thread.
|
||||
* @return
|
||||
* The return value is the thread identifier of the calling thread.
|
||||
*/
|
||||
int GetCurrentThreadId();
|
||||
|
||||
/**
|
||||
* The GetCurrentThread function retrieves a pseudo handle for the current thread.
|
||||
* @return
|
||||
* The return value is a pseudo handle for the current thread.
|
||||
*/
|
||||
HANDLE GetCurrentThread();
|
||||
|
||||
/**
|
||||
* This function returns the process identifier of the calling process.
|
||||
* @return
|
||||
* The return value is the process identifier of the calling process.
|
||||
*/
|
||||
int GetCurrentProcessId();
|
||||
|
||||
/**
|
||||
* This function returns a pseudohandle for the current process.
|
||||
* @return
|
||||
* The return value is a pseudohandle to the current process.
|
||||
*/
|
||||
HANDLE GetCurrentProcess();
|
||||
|
||||
/**
|
||||
* The GetProcessId function retrieves the process identifier of the
|
||||
* specified process.
|
||||
* @param process
|
||||
* Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the process identifier of the
|
||||
* specified process. If the function fails, the return value is zero. To get
|
||||
* extended error information, call GetLastError.
|
||||
*/
|
||||
int GetProcessId(HANDLE process);
|
||||
|
||||
/**
|
||||
* The GetProcessVersion function retrieves the major and minor version numbers of the system
|
||||
* on which the specified process expects to run.
|
||||
* @param processId
|
||||
* Process identifier of the process of interest. A value of zero specifies the
|
||||
* calling process.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the version of the system on
|
||||
* which the process expects to run. The high word of the return value contains
|
||||
* the major version number. The low word of the return value contains the minor
|
||||
* version number. If the function fails, the return value is zero. To get extended
|
||||
* error information, call GetLastError. The function fails if ProcessId is an
|
||||
* invalid value.
|
||||
*/
|
||||
int GetProcessVersion(int processId);
|
||||
|
||||
/**
|
||||
* Retrieves the termination status of the specified process.
|
||||
* @param hProcess A handle to the process.
|
||||
* @param lpExitCode A pointer to a variable to receive the process termination status.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetExitCodeProcess(HANDLE hProcess, IntByReference lpExitCode);
|
||||
|
||||
/**
|
||||
* Terminates the specified process and all of its threads.
|
||||
* @param hProcess A handle to the process to be terminated.
|
||||
* @param uExitCode The exit code to be used by the process and threads
|
||||
* terminated as a result of this call.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean TerminateProcess(HANDLE hProcess, int uExitCode);
|
||||
|
||||
/**
|
||||
* The GetLastError function retrieves the calling thread's last-error code value.
|
||||
* The last-error code is maintained on a per-thread basis. Multiple threads do not
|
||||
* overwrite each other's last-error code.
|
||||
* @return
|
||||
* The return value is the calling thread's last-error code value.
|
||||
*/
|
||||
int GetLastError();
|
||||
|
||||
/**
|
||||
* The SetLastError function sets the last-error code for the calling thread.
|
||||
* @param dwErrCode
|
||||
* Last-error code for the thread.
|
||||
*/
|
||||
void SetLastError(int dwErrCode);
|
||||
|
||||
/**
|
||||
* The GetDriveType function determines whether a disk drive is a removable,
|
||||
* fixed, CD-ROM, RAM disk, or network drive.
|
||||
* @param lpRootPathName
|
||||
* Pointer to a null-terminated string that specifies the root directory of
|
||||
* the disk to return information about. A trailing backslash is required.
|
||||
* If this parameter is NULL, the function uses the root of the current directory.
|
||||
* @return
|
||||
* The return value specifies the type of drive.
|
||||
*/
|
||||
int GetDriveType(String lpRootPathName);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, PointerByReference lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, Buffer lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The CreateFile function creates or opens a file, file stream, directory, physical
|
||||
* disk, volume, console buffer, tape drive, communications resource, mailslot, or
|
||||
* named pipe. The function returns a handle that can be used to access an object.
|
||||
* @param lpFileName
|
||||
* A pointer to a null-terminated string that specifies the name of an object to create or open.
|
||||
* @param dwDesiredAccess
|
||||
* The access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode
|
||||
* The sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param lpSecurityAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not
|
||||
* the returned handle can be inherited by child processes. If lpSecurityAttributes
|
||||
* is NULL, the handle cannot be inherited.
|
||||
* @param dwCreationDisposition
|
||||
* An action to take on files that exist and do not exist.
|
||||
* @param dwFlagsAndAttributes
|
||||
* The file attributes and flags.
|
||||
* @param hTemplateFile
|
||||
* Handle to a template file with the GENERIC_READ access right. The template file
|
||||
* supplies file attributes and extended attributes for the file that is being
|
||||
* created. This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to a specified file.
|
||||
* If a specified file exists before the function call and dwCreationDisposition is
|
||||
* CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS,
|
||||
* even when the function succeeds. If a file does not exist before the call,
|
||||
* GetLastError returns 0 (zero). If the function fails, the return value is
|
||||
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition,
|
||||
int dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
|
||||
|
||||
/**
|
||||
* The CreateDirectory function creates a new directory. If the underlying file
|
||||
* system supports security on files and directories, the function applies a
|
||||
* specified security descriptor to the new directory.
|
||||
* @param lpPathName
|
||||
* Pointer to a null-terminated string that specifies the path of the directory
|
||||
* to be created.
|
||||
* @param lpSecurityAttributes
|
||||
* Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member
|
||||
* of the structure specifies a security descriptor for the new directory. If
|
||||
* lpSecurityAttributes is NULL, the directory gets a default security descriptor.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. If the function fails,
|
||||
* the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean CreateDirectory(String lpPathName,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
/**
|
||||
* Reads data from the specified file or input/output (I/O) device. Reads
|
||||
* occur at the position specified by the file pointer if supported by the
|
||||
* device.
|
||||
*
|
||||
* This function is designed for both synchronous and asynchronous
|
||||
* operations. For a similar function designed solely for asynchronous
|
||||
* operation, see ReadFileEx
|
||||
*
|
||||
* @param hFile A handle to the device (for example, a file, file stream,
|
||||
* physical disk, volume, console buffer, tape drive, socket, communications
|
||||
* resource, mailslot, or pipe).
|
||||
* @param lpBuffer A pointer to the buffer that receives the data read from a file or device.
|
||||
* @param nNumberOfBytesToRead The maximum number of bytes to be read.
|
||||
* @param lpNumberOfBytesRead A pointer to the variable that receives the number of bytes
|
||||
* read when using a synchronous hFile parameter
|
||||
* @param lpOverlapped A pointer to an OVERLAPPED structure is required if the hFile
|
||||
* parameter was opened with FILE_FLAG_OVERLAPPED, otherwise it can be NULL.
|
||||
* @return If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*
|
||||
* Note The GetLastError code ERROR_IO_PENDING is not a failure; it designates the read
|
||||
* operation is pending completion asynchronously. For more information, see Remarks.
|
||||
*/
|
||||
boolean ReadFile(
|
||||
HANDLE hFile,
|
||||
Buffer lpBuffer,
|
||||
int nNumberOfBytesToRead,
|
||||
IntByReference lpNumberOfBytesRead,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
/**
|
||||
* Creates an input/output (I/O) completion port and associates it with a specified
|
||||
* file handle, or creates an I/O completion port that is not yet associated with a
|
||||
* file handle, allowing association at a later time.
|
||||
* @param FileHandle
|
||||
* An open file handle or INVALID_HANDLE_VALUE.
|
||||
* @param ExistingCompletionPort
|
||||
* A handle to an existing I/O completion port or NULL.
|
||||
* @param CompletionKey
|
||||
* The per-handle user-defined completion key that is included in every I/O completion
|
||||
* packet for the specified file handle.
|
||||
* @param NumberOfConcurrentThreads
|
||||
* The maximum number of threads that the operating system can allow to concurrently
|
||||
* process I/O completion packets for the I/O completion port.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to an I/O completion port:
|
||||
* If the ExistingCompletionPort parameter was NULL, the return value is a new handle.
|
||||
* If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle.
|
||||
* If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
|
||||
Pointer CompletionKey, int NumberOfConcurrentThreads);
|
||||
|
||||
/**
|
||||
* Attempts to dequeue an I/O completion packet from the specified I/O completion
|
||||
* port. If there is no completion packet queued, the function waits for a pending
|
||||
* I/O operation associated with the completion port to complete.
|
||||
* @param CompletionPort
|
||||
* A handle to the completion port.
|
||||
* @param lpNumberOfBytes
|
||||
* A pointer to a variable that receives the number of bytes transferred during
|
||||
* an I/O operation that has completed.
|
||||
* @param lpCompletionKey
|
||||
* A pointer to a variable that receives the completion key value associated with
|
||||
* the file handle whose I/O operation has completed.
|
||||
* @param lpOverlapped
|
||||
* A pointer to a variable that receives the address of the OVERLAPPED structure
|
||||
* that was specified when the completed I/O operation was started.
|
||||
* @param dwMilliseconds
|
||||
* The number of milliseconds that the caller is willing to wait for a completion
|
||||
* packet to appear at the completion port.
|
||||
* @return
|
||||
* Returns nonzero (TRUE) if successful or zero (FALSE) otherwise.
|
||||
*/
|
||||
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
|
||||
PointerByReference lpOverlapped, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Posts an I/O completion packet to an I/O completion port.
|
||||
* @param CompletionPort
|
||||
* A handle to an I/O completion port to which the I/O completion packet is to be posted.
|
||||
* @param dwNumberOfBytesTransferred
|
||||
* The value to be returned through the lpNumberOfBytesTransferred parameter of the GetQueuedCompletionStatus function.
|
||||
* @param dwCompletionKey
|
||||
* The value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function.
|
||||
* @param lpOverlapped
|
||||
* The value to be returned through the lpOverlapped parameter of the GetQueuedCompletionStatus function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError .
|
||||
*/
|
||||
boolean PostQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
int dwNumberOfBytesTransferred, Pointer dwCompletionKey,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Waits until the specified object is in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForSingleObjectEx function.
|
||||
* To wait for multiple objects, use the WaitForMultipleObjects.
|
||||
* @param hHandle
|
||||
* A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
|
||||
* If this handle is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForMultipleObjectsEx function.
|
||||
* @param nCount
|
||||
* The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS.
|
||||
* @param hHandle
|
||||
* An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types.
|
||||
* It may not contain multiple copies of the same handle.
|
||||
* If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param bWaitAll
|
||||
* If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled.
|
||||
* If FALSE, the function returns when the state of any one of the objects is set to signaled.
|
||||
* In the latter case, the return value indicates the object whose state caused the function to return.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* The DuplicateHandle function duplicates an object handle.
|
||||
*
|
||||
* @param hSourceProcessHandle
|
||||
* Handle to the process with the handle to duplicate.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param hSourceHandle
|
||||
* Handle to duplicate. This is an open object handle that is valid in the
|
||||
* context of the source process.
|
||||
* @param hTargetProcessHandle
|
||||
* Handle to the process that is to receive the duplicated handle.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param lpTargetHandle
|
||||
* Pointer to a variable that receives the duplicate handle. This handle value is valid in
|
||||
* the context of the target process. If hSourceHandle is a pseudo handle returned by
|
||||
* GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to
|
||||
* a process or thread, respectively.
|
||||
* @param dwDesiredAccess
|
||||
* Access requested for the new handle.
|
||||
* @param bInheritHandle
|
||||
* Indicates whether the handle is inheritable.
|
||||
* @param dwOptions
|
||||
* Optional actions.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
|
||||
HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle,
|
||||
int dwDesiredAccess, boolean bInheritHandle, int dwOptions);
|
||||
|
||||
/**
|
||||
* The CloseHandle function closes an open object handle.
|
||||
*
|
||||
* @param hObject
|
||||
* Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean CloseHandle(HANDLE hObject);
|
||||
|
||||
// TODO: figure out how OVERLAPPED is used and apply an appropriate mapping
|
||||
interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback {
|
||||
void callback(int errorCode, int nBytesTransferred,
|
||||
WinBase.OVERLAPPED overlapped);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves information that describes the changes within the specified directory.
|
||||
* The function does not report changes to the specified directory itself.
|
||||
* Note: there's no ReadDirectoryChangesA.
|
||||
* @param directory
|
||||
* A handle to the directory to be monitored. This directory must be opened with the
|
||||
* FILE_LIST_DIRECTORY access right.
|
||||
* @param info
|
||||
* A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned.
|
||||
* @param length
|
||||
* The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
|
||||
* @param watchSubtree
|
||||
* If this parameter is TRUE, the function monitors the directory tree rooted at the specified
|
||||
* directory. If this parameter is FALSE, the function monitors only the directory specified by
|
||||
* the hDirectory parameter.
|
||||
* @param notifyFilter
|
||||
* The filter criteria that the function checks to determine if the wait operation has completed.
|
||||
* @param bytesReturned
|
||||
* For synchronous calls, this parameter receives the number of bytes transferred into the
|
||||
* lpBuffer parameter. For asynchronous calls, this parameter is undefined. You must use an asynchronous
|
||||
* notification technique to retrieve the number of bytes transferred.
|
||||
* @param overlapped
|
||||
* A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
|
||||
* Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used.
|
||||
* @param completionRoutine
|
||||
* A pointer to a completion routine to be called when the operation has been completed or canceled and
|
||||
* the calling thread is in an alertable wait state.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. For synchronous calls, this means that the
|
||||
* operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the network redirector or the target file system does not support this operation, the function
|
||||
* fails with ERROR_INVALID_FUNCTION.
|
||||
*/
|
||||
public boolean ReadDirectoryChangesW(HANDLE directory,
|
||||
WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree,
|
||||
int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped,
|
||||
OVERLAPPED_COMPLETION_ROUTINE completionRoutine);
|
||||
|
||||
/**
|
||||
* Retrieves the short path form of the specified path.
|
||||
* @param lpszLongPath
|
||||
* The path string.
|
||||
* @param lpdzShortPath
|
||||
* A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies.
|
||||
* @param cchBuffer
|
||||
* The size of the buffer that lpszShortPath points to, in TCHARs.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to
|
||||
* lpszShortPath, not including the terminating null character.
|
||||
* If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer,
|
||||
* in TCHARs, that is required to hold the path and the terminating null character.
|
||||
* If the function fails for any other reason, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer);
|
||||
|
||||
/**
|
||||
* The LocalAlloc function allocates the specified number of bytes from the heap.
|
||||
* Windows memory management does not provide a separate local heap and global heap.
|
||||
* @param type
|
||||
* Memory allocation attributes. The default is the LMEM_FIXED value.
|
||||
* @param cbInput
|
||||
* Number of bytes to allocate. If this parameter is zero and the uFlags parameter
|
||||
* specifies LMEM_MOVEABLE, the function returns a handle to a memory object that
|
||||
* is marked as discarded.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly allocated memory object.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalAlloc(int type, int cbInput);
|
||||
|
||||
/**
|
||||
* Writes data to the specified file or input/output (I/O) device.
|
||||
* @param hFile
|
||||
* A handle to the file or I/O device (for example, a file, file stream, physical disk, volume,
|
||||
* console buffer, tape drive, socket, communications resource, mailslot, or pipe).
|
||||
* @param lpBuffer
|
||||
* A pointer to the buffer containing the data to be written to the file or device.
|
||||
* @param nNumberOfBytesToWrite
|
||||
* The number of bytes to be written to the file or device.
|
||||
* @param lpNumberOfBytesWritten
|
||||
* A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.
|
||||
* @param lpOverlapped
|
||||
* A pointer to an OVERLAPPED structure is required if the hFile parameter was opened with FILE_FLAG_OVERLAPPED,
|
||||
* otherwise this parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
|
||||
IntByReference lpNumberOfBytesWritten,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed event object.
|
||||
* @param lpEventAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL,
|
||||
* the handle cannot be inherited by child processes.
|
||||
* @param bManualReset
|
||||
* If this parameter is TRUE, the function creates a manual-reset event object,
|
||||
* which requires the use of the ResetEvent function to set the event state to nonsignaled.
|
||||
* If this parameter is FALSE, the function creates an auto-reset event object, and system
|
||||
* automatically resets the event state to nonsignaled after a single waiting thread has
|
||||
* been released.
|
||||
* @param bInitialState
|
||||
* If this parameter is TRUE, the initial state of the event object is signaled; otherwise,
|
||||
* it is nonsignaled.
|
||||
* @param lpName
|
||||
* The name of the event object. The name is limited to MAX_PATH characters. Name comparison
|
||||
* is case sensitive.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the event object. If the named event
|
||||
* object existed before the function call, the function returns a handle to the existing object
|
||||
* and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateEvent(WinBase.SECURITY_ATTRIBUTES lpEventAttributes,
|
||||
boolean bManualReset, boolean bInitialState,
|
||||
String lpName);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state and then resets it to the nonsignaled
|
||||
* state after releasing the appropriate number of waiting threads.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean PulseEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed file mapping object for a specified file.
|
||||
* @param hFile
|
||||
* A handle to the file from which to create a file mapping object.
|
||||
* @param lpAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object.
|
||||
* @param flProtect
|
||||
* Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection.
|
||||
* @param dwMaximumSizeHigh
|
||||
* The high-order DWORD of the maximum size of the file mapping object.
|
||||
* @param dwMaximumSizeLow
|
||||
* The low-order DWORD of the maximum size of the file mapping object.
|
||||
* @param lpName
|
||||
* The name of the file mapping object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly created file mapping object.
|
||||
* If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFileMapping(HANDLE hFile, WinBase.SECURITY_ATTRIBUTES lpAttributes,
|
||||
int flProtect, int dwMaximumSizeHigh,
|
||||
int dwMaximumSizeLow, String lpName);
|
||||
|
||||
/**
|
||||
* Maps a view of a file mapping into the address space of a calling process.
|
||||
* @param hFileMappingObject
|
||||
* A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle.
|
||||
* @param dwDesiredAccess
|
||||
* The type of access to a file mapping object, which determines the protection of the pages.
|
||||
* @param dwFileOffsetHigh
|
||||
* A high-order DWORD of the file offset where the view begins.
|
||||
* @param dwFileOffsetLow
|
||||
* A low-order DWORD of the file offset where the view is to begin.
|
||||
* @param dwNumberOfBytesToMap
|
||||
* The number of bytes of a file mapping to map to the view.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
|
||||
int dwFileOffsetHigh, int dwFileOffsetLow,
|
||||
int dwNumberOfBytesToMap);
|
||||
|
||||
/**
|
||||
* Unmaps a mapped view of a file from the calling process's address space.
|
||||
* @param lpBaseAddress
|
||||
* A pointer to the base address of the mapped view of a file that is to be unmapped.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UnmapViewOfFile(Pointer lpBaseAddress);
|
||||
|
||||
/**
|
||||
* Retrieves only the NetBIOS name of the local computer.
|
||||
*
|
||||
* @param buffer
|
||||
* A pointer to a buffer that receives the computer name or the cluster virtual server
|
||||
* name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1
|
||||
* characters.
|
||||
* @param lpnSize
|
||||
* On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs
|
||||
* copied to the destination buffer, not including the terminating null character. If
|
||||
* the buffer is too small, the function fails and GetLastError returns
|
||||
* ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required,
|
||||
* including the terminating null character.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean GetComputerName(char[] buffer, IntByReference lpnSize);
|
||||
|
||||
/**
|
||||
* The OpenThread function opens an existing thread object.
|
||||
* @param dwDesiredAccess
|
||||
* Access to the thread object. This access right is checked against any security
|
||||
* descriptor for the thread.
|
||||
* @param bInheritHandle
|
||||
* If this parameter is TRUE, the new process inherits the handle. If the parameter
|
||||
* is FALSE, the handle is not inherited.
|
||||
* @param dwThreadId
|
||||
* Identifier of the thread to be opened.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to the specified process.
|
||||
* If the function fails, the return value is NULL. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId);
|
||||
|
||||
/**
|
||||
* This function returns a handle to an existing process object.
|
||||
* @param fdwAccess
|
||||
* Not supported; set to zero.
|
||||
* @param fInherit
|
||||
* Not supported; set to FALSE.
|
||||
* @param IDProcess
|
||||
* Specifies the process identifier of the process to open.
|
||||
* @return
|
||||
* An open handle to the specified process indicates success.
|
||||
* NULL indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE OpenProcess(int fdwAccess, boolean fInherit, int IDProcess);
|
||||
|
||||
/**
|
||||
* The GetTempPath function retrieves the path of the directory designated
|
||||
* for temporary files.
|
||||
* @param nBufferLength
|
||||
* Size of the string buffer identified by lpBuffer, in TCHARs.
|
||||
* @param buffer
|
||||
* Pointer to a string buffer that receives the null-terminated string specifying the
|
||||
* temporary file path. The returned string ends with a backslash, for example,
|
||||
* C:\TEMP\.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string
|
||||
* copied to lpBuffer, not including the terminating null character. If the return value
|
||||
* is greater than nBufferLength, the return value is the length, in TCHARs, of the
|
||||
* buffer required to hold the path.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
DWORD GetTempPath(DWORD nBufferLength, char[] buffer);
|
||||
|
||||
/**
|
||||
* The GetVersion function returns the current version number of the operating system.
|
||||
* @return
|
||||
* If the function succeeds, the return value includes the major and minor version numbers
|
||||
* of the operating system in the low order word, and information about the operating system
|
||||
* platform in the high order word.
|
||||
*/
|
||||
DWORD GetVersion();
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFO data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFO lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFOEX data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFOEX lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetSystemInfo function returns information about the current system.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The GetNativeSystemInfo function retrieves information about the current system to an
|
||||
* application running under WOW64. If the function is called from a 64-bit application,
|
||||
* it is equivalent to the GetSystemInfo function.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The IsWow64Process function determines whether the specified process is running under WOW64.
|
||||
* @param hProcess
|
||||
* Handle to a process.
|
||||
* @param Wow64Process
|
||||
* Pointer to a value that is set to TRUE if the process is running under WOW64.
|
||||
* Otherwise, the value is set to FALSE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
|
||||
|
||||
/**
|
||||
* Retrieves information about the system's current usage of both physical and virtual memory.
|
||||
* @param lpBuffer
|
||||
* A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetLogicalDriveStrings function fills a buffer with strings that specify
|
||||
* valid drives in the system.
|
||||
* @param nBufferLength
|
||||
* Maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include
|
||||
* the terminating null character. If this parameter is zero, lpBuffer is not used.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives a series of null-terminated strings, one for each valid
|
||||
* drive in the system, plus with an additional null character. Each string is a device name.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in characters, of the strings
|
||||
* copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII
|
||||
* null character uses one byte, but a Unicode null character uses two bytes.
|
||||
* If the buffer is not large enough, the return value is greater than nBufferLength. It is
|
||||
* the size of the buffer required to hold the drive strings.
|
||||
* If the function fails, the return value is zero. To get extended error information, use
|
||||
* the GetLastError function.
|
||||
*/
|
||||
DWORD GetLogicalDriveStrings(DWORD nBufferLength, char[] lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetDiskFreeSpaceEx function retrieves information about the amount of space that is
|
||||
* available on a disk volume, which is the total amount of space, the total amount of free
|
||||
* space, and the total amount of free space available to the user that is associated with
|
||||
* the calling thread.
|
||||
* @param lpDirectoryName
|
||||
* A pointer to a null-terminated string that specifies a directory on a disk.
|
||||
* If this parameter is NULL, the function uses the root of the current disk.
|
||||
* If this parameter is a UNC name, it must include a trailing backslash, for example,
|
||||
* \\MyServer\MyShare\.
|
||||
* This parameter does not have to specify the root directory on a disk. The function
|
||||
* accepts any directory on a disk.
|
||||
* @param lpFreeBytesAvailable
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk that
|
||||
* are available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfBytes
|
||||
* A pointer to a variable that receives the total number of bytes on a disk that are
|
||||
* available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfFreeBytes
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk.
|
||||
* This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is 0 (zero). To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable,
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
|
||||
|
||||
/**
|
||||
* Deletes an existing file.
|
||||
* @param filename
|
||||
* The name of the file to be deleted.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean DeleteFile(String filename);
|
||||
|
||||
/**
|
||||
* Creates an anonymous pipe, and returns handles to the read and write ends of the pipe.
|
||||
* @param hReadPipe A pointer to a variable that receives the read handle for the pipe.
|
||||
* @param hWritePipe A pointer to a variable that receives the write handle for the pipe.
|
||||
* @param lpPipeAttributes A pointer to a SECURITY_ATTRIBUTES structure that determines whether
|
||||
* the returned handle can be inherited by child processes.
|
||||
* @param nSize The size of the buffer for the pipe, in bytes.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CreatePipe(
|
||||
HANDLEByReference hReadPipe,
|
||||
HANDLEByReference hWritePipe,
|
||||
WinBase.SECURITY_ATTRIBUTES lpPipeAttributes,
|
||||
int nSize);
|
||||
|
||||
/**
|
||||
* Sets certain properties of an object handle.
|
||||
* @param hObject A handle to an object whose information is to be set.
|
||||
* @param dwMask A mask that specifies the bit flags to be changed. Use the same constants shown in the description of dwFlags.
|
||||
* @param dwFlags Set of bit flags that specifies properties of the object handle.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetHandleInformation(
|
||||
HANDLE hObject,
|
||||
int dwMask,
|
||||
int dwFlags);
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
* @param lpFileName The name of the file or directory. Prepend \\?\ to the path for names up to 32,767 wide characters
|
||||
* @return INVALID_FILE_ATTRIBUTES if the function fails, otherwise the file attributes WinNT.FILE_ATTRIBUTE_*
|
||||
*/
|
||||
public int GetFileAttributes(String lpFileName);
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.LastErrorException;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Kernel32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Kernel32Util {
|
||||
|
||||
/**
|
||||
* Get current computer NetBIOS name.
|
||||
* @return
|
||||
* Netbios name.
|
||||
*/
|
||||
public static String getComputerName() {
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1];
|
||||
IntByReference lpnSize = new IntByReference(buffer.length);
|
||||
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a message from an HRESULT.
|
||||
* @param code
|
||||
* HRESULT
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromHR(HRESULT code) {
|
||||
PointerByReference buffer = new PointerByReference();
|
||||
if (0 == Kernel32.INSTANCE.FormatMessage(
|
||||
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
null,
|
||||
code.intValue(),
|
||||
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
|
||||
buffer,
|
||||
0,
|
||||
null)) {
|
||||
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
|
||||
s = s.replace(".\r",".").replace(".\n",".");
|
||||
Kernel32.INSTANCE.LocalFree(buffer.getValue());
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a system message from an error code.
|
||||
* @param code
|
||||
* Error code, typically a result of GetLastError.
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromLastErrorCode(int code) {
|
||||
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path designated for temporary files.
|
||||
* @return
|
||||
* Path.
|
||||
*/
|
||||
public static String getTempPath() {
|
||||
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
|
||||
char[] buffer = new char[nBufferLength.intValue()];
|
||||
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
public static void deleteFile(String filename) {
|
||||
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns valid drives in the system.
|
||||
* @return
|
||||
* An array of valid drives.
|
||||
*/
|
||||
public static String[] getLogicalDriveStrings() {
|
||||
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
char buf[] = new char[dwSize.intValue()];
|
||||
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
List<String> drives = new ArrayList<String>();
|
||||
String drive = "";
|
||||
// the buffer is double-null-terminated
|
||||
for(int i = 0; i < buf.length - 1; i++) {
|
||||
if (buf[i] == 0) {
|
||||
drives.add(drive);
|
||||
drive = "";
|
||||
} else {
|
||||
drive += buf[i];
|
||||
}
|
||||
}
|
||||
return drives.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
* @param fileName
|
||||
* The name of the file or directory.
|
||||
* @return
|
||||
* The attributes of the specified file or directory.
|
||||
*/
|
||||
public static int getFileAttributes(String fileName) {
|
||||
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
|
||||
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return fileAttributes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMAccess.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMAccess extends StdCallLibrary {
|
||||
|
||||
public static class LOCALGROUP_INFO_0 extends Structure {
|
||||
public LOCALGROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
public static class LOCALGROUP_INFO_1 extends Structure {
|
||||
public LOCALGROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui1_name;
|
||||
public WString lgrui1_comment;
|
||||
}
|
||||
|
||||
//
|
||||
// bit masks for the NetUserEnum filter parameter.
|
||||
//
|
||||
|
||||
public static final int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
|
||||
public static final int FILTER_NORMAL_ACCOUNT = 0x0002;
|
||||
// public static final int FILTER_PROXY_ACCOUNT = 0x0004;
|
||||
public static final int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
|
||||
public static final int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
|
||||
public static final int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
|
||||
|
||||
/**
|
||||
* The USER_INFO_0 structure contains a user account name.
|
||||
*/
|
||||
public static class USER_INFO_0 extends Structure {
|
||||
public USER_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user account.
|
||||
*/
|
||||
public WString usri0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The USER_INFO_1 structure contains information about a user account, including
|
||||
* account name, password data, privilege level, and the path to the user's home
|
||||
* directory.
|
||||
*/
|
||||
public static class USER_INFO_1 extends Structure {
|
||||
public USER_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user
|
||||
* account.
|
||||
*/
|
||||
public WString usri1_name;
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the password of the user
|
||||
* indicated by the usri1_name member.
|
||||
*/
|
||||
public WString usri1_password;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the number of seconds that have
|
||||
* elapsed since the usri1_password member was last changed.
|
||||
*/
|
||||
public int usri1_password_age;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the level of privilege assigned
|
||||
* to the usri1_name member.
|
||||
*/
|
||||
public int usri1_priv;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path of the home directory
|
||||
* for the user specified in the usri1_name member.
|
||||
*/
|
||||
public WString usri1_home_dir;
|
||||
/**
|
||||
* Pointer to a Unicode string that contains a comment to associate with
|
||||
* the user account.
|
||||
*/
|
||||
public WString usri1_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that determines several features.
|
||||
*/
|
||||
public int usri1_flags;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path for the user's
|
||||
* logon script file.
|
||||
*/
|
||||
public WString usri1_script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_USERS_INFO_0 structure contains global group member information.
|
||||
*/
|
||||
public static class GROUP_USERS_INFO_0 extends Structure {
|
||||
public GROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies a name.
|
||||
*/
|
||||
public WString grui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The LOCALGROUP_USERS_INFO_0 structure contains local group member information.
|
||||
*/
|
||||
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
|
||||
public LOCALGROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
|
||||
*/
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_0 structure contains the name of a global group in the security
|
||||
* database, which is the security accounts manager (SAM) database or, in the case
|
||||
* of domain controllers, the Active Directory.
|
||||
*/
|
||||
public static class GROUP_INFO_0 extends Structure {
|
||||
public GROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_1 structure contains a global group name and a comment to
|
||||
* associate with the group.
|
||||
*/
|
||||
public static class GROUP_INFO_1 extends Structure {
|
||||
public GROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi1_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* a remark associated with the global group. This member can be a null
|
||||
* string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi1_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_2 structure contains information about a global group, including
|
||||
* name, identifier, and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_2 extends Structure {
|
||||
public GROUP_INFO_2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_2(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi2_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that contains a
|
||||
* remark associated with the global group. This member can be a null string.
|
||||
* The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi2_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that contains the relative identifier (RID) of
|
||||
* the global group.
|
||||
*/
|
||||
public int grpi2_group_id;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED,
|
||||
* and SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi2_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_3 structure contains information about a global group, including
|
||||
* name, security identifier (SID), and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_3 extends Structure {
|
||||
public GROUP_INFO_3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_3(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi3_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* contains a remark associated with the global group. This member can be
|
||||
* a null string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi3_comment;
|
||||
/**
|
||||
* Pointer to a SID structure that contains the security identifier (SID) that
|
||||
* uniquely identifies the global group.
|
||||
*/
|
||||
public PSID grpi3_group_sid;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and
|
||||
* SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi3_attributes;
|
||||
}
|
||||
|
||||
//
|
||||
// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
|
||||
//
|
||||
|
||||
public static final int USER_PRIV_MASK = 3;
|
||||
public static final int USER_PRIV_GUEST = 0;
|
||||
public static final int USER_PRIV_USER = 1;
|
||||
public static final int USER_PRIV_ADMIN = 2;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMCons.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMCons extends StdCallLibrary {
|
||||
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
|
||||
|
||||
/**
|
||||
* Value to be used with APIs which have a "preferred maximum length" parameter.
|
||||
* This value indicates that the API should just allocate "as much as it takes."
|
||||
*/
|
||||
public static final int MAX_PREFERRED_LENGTH = -1;
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMErr.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMErr extends StdCallLibrary {
|
||||
public static final int NERR_Success = 0;
|
||||
public static final int NERR_BASE = 2100;
|
||||
|
||||
public static final int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */
|
||||
public static final int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */
|
||||
public static final int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */
|
||||
|
||||
public static final int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */
|
||||
public static final int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */
|
||||
public static final int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */
|
||||
/* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
|
||||
/* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
|
||||
/* UNUSED BASE + 10 */
|
||||
/* UNUSED BASE + 11 */
|
||||
/* UNUSED BASE + 12 */
|
||||
/* UNUSED BASE + 13 */
|
||||
public static final int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */
|
||||
public static final int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */
|
||||
public static final int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */
|
||||
public static final int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */
|
||||
public static final int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */
|
||||
public static final int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */
|
||||
/* UNUSED BASE + 20 */
|
||||
public static final int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */
|
||||
public static final int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */
|
||||
public static final int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */
|
||||
/* UNUSED BASE + 24 */
|
||||
/* UNUSED BASE + 25 */
|
||||
/* UNUSED BASE + 26 */
|
||||
public static final int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */
|
||||
/* UNUSED BASE + 28 */
|
||||
/* UNUSED BASE + 29 */
|
||||
/* UNUSED BASE + 30 */
|
||||
public static final int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */
|
||||
/* UNUSED BASE + 32 */
|
||||
/* UNUSED BASE + 33 */
|
||||
/* UNUSED BASE + 34 */
|
||||
/* UNUSED BASE + 35 */
|
||||
public static final int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */
|
||||
public static final int NERR_WkstaInconsistentState = NERR_BASE + 37;
|
||||
/* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */
|
||||
public static final int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */
|
||||
public static final int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */
|
||||
public static final int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/
|
||||
public static final int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */
|
||||
public static final int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */
|
||||
public static final int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */
|
||||
public static final int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */
|
||||
/*
|
||||
* Config API related
|
||||
* Error codes from BASE + 45 to BASE + 49
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 45 */
|
||||
public static final int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */
|
||||
public static final int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */
|
||||
public static final int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */
|
||||
|
||||
/*
|
||||
* Spooler API related
|
||||
* Error codes from BASE + 50 to BASE + 79
|
||||
*/
|
||||
|
||||
public static final int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */
|
||||
public static final int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */
|
||||
public static final int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */
|
||||
public static final int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */
|
||||
public static final int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */
|
||||
public static final int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */
|
||||
public static final int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */
|
||||
public static final int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */
|
||||
public static final int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */
|
||||
public static final int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */
|
||||
public static final int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */
|
||||
public static final int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */
|
||||
public static final int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */
|
||||
public static final int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */
|
||||
public static final int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */
|
||||
public static final int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */
|
||||
public static final int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */
|
||||
public static final int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */
|
||||
public static final int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */
|
||||
|
||||
/*
|
||||
* Service API related
|
||||
* Error codes from BASE + 80 to BASE + 99
|
||||
*/
|
||||
|
||||
public static final int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */
|
||||
public static final int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */
|
||||
public static final int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */
|
||||
public static final int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */
|
||||
public static final int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */
|
||||
public static final int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */
|
||||
public static final int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */
|
||||
public static final int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */
|
||||
public static final int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */
|
||||
public static final int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */
|
||||
public static final int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */
|
||||
public static final int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */
|
||||
public static final int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */
|
||||
public static final int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */
|
||||
public static final int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */
|
||||
|
||||
/*
|
||||
* Wksta and Logon API related
|
||||
* Error codes from BASE + 100 to BASE + 118
|
||||
*/
|
||||
|
||||
public static final int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */
|
||||
public static final int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */
|
||||
public static final int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */
|
||||
public static final int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */
|
||||
public static final int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */
|
||||
public static final int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */
|
||||
/* UNUSED BASE + 108 */
|
||||
public static final int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */
|
||||
public static final int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */
|
||||
public static final int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */
|
||||
public static final int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */
|
||||
/* UNUSED BASE + 113 */
|
||||
public static final int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */
|
||||
public static final int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */
|
||||
public static final int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */
|
||||
public static final int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */
|
||||
|
||||
/*
|
||||
* ACF API related = access, user, group;
|
||||
* Error codes from BASE + 119 to BASE + 149
|
||||
*/
|
||||
|
||||
public static final int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */
|
||||
public static final int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */
|
||||
public static final int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */
|
||||
public static final int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */
|
||||
public static final int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */
|
||||
public static final int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */
|
||||
public static final int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */
|
||||
public static final int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */
|
||||
public static final int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */
|
||||
public static final int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */
|
||||
public static final int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/
|
||||
public static final int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */
|
||||
public static final int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */
|
||||
public static final int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */
|
||||
public static final int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */
|
||||
public static final int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */
|
||||
public static final int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */
|
||||
public static final int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */
|
||||
public static final int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */
|
||||
public static final int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */
|
||||
public static final int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */
|
||||
public static final int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */
|
||||
public static final int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */
|
||||
public static final int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */
|
||||
public static final int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */
|
||||
public static final int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */
|
||||
public static final int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */
|
||||
public static final int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */
|
||||
public static final int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */
|
||||
public static final int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */
|
||||
public static final int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */
|
||||
|
||||
/*
|
||||
* Use API related
|
||||
* Error codes from BASE + 150 to BASE + 169
|
||||
*/
|
||||
|
||||
public static final int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */
|
||||
public static final int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */
|
||||
public static final int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */
|
||||
public static final int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */
|
||||
|
||||
|
||||
/*
|
||||
* Message Server related
|
||||
* Error codes BASE + 170 to BASE + 209
|
||||
*/
|
||||
|
||||
public static final int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */
|
||||
public static final int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */
|
||||
public static final int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */
|
||||
public static final int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */
|
||||
public static final int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */
|
||||
public static final int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */
|
||||
public static final int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */
|
||||
public static final int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */
|
||||
public static final int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/
|
||||
public static final int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */
|
||||
public static final int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */
|
||||
public static final int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */
|
||||
public static final int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */
|
||||
public static final int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */
|
||||
public static final int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */
|
||||
public static final int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */
|
||||
public static final int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */
|
||||
public static final int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */
|
||||
public static final int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */
|
||||
public static final int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */
|
||||
public static final int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */
|
||||
public static final int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */
|
||||
/* UNUSED BASE + 196 */
|
||||
public static final int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */
|
||||
public static final int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */
|
||||
public static final int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */
|
||||
public static final int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */
|
||||
|
||||
/*
|
||||
* Server API related
|
||||
* Error codes BASE + 210 to BASE + 229
|
||||
*/
|
||||
|
||||
public static final int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/
|
||||
public static final int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */
|
||||
public static final int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */
|
||||
public static final int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */
|
||||
public static final int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */
|
||||
public static final int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */
|
||||
public static final int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */
|
||||
public static final int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */
|
||||
public static final int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */
|
||||
public static final int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */
|
||||
public static final int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */
|
||||
|
||||
/*
|
||||
* CharDev API related
|
||||
* Error codes BASE + 230 to BASE + 249
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 230 */
|
||||
public static final int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */
|
||||
public static final int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */
|
||||
public static final int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */
|
||||
public static final int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */
|
||||
public static final int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */
|
||||
public static final int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */
|
||||
public static final int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */
|
||||
public static final int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */
|
||||
public static final int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */
|
||||
public static final int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */
|
||||
public static final int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */
|
||||
|
||||
/*
|
||||
* NetICanonicalize and NetIType and NetIMakeLMFileName
|
||||
* NetIListCanon and NetINameCheck
|
||||
* Error codes BASE + 250 to BASE + 269
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */
|
||||
/* UNUSED BASE + 252 */
|
||||
/* UNUSED BASE + 253 */
|
||||
public static final int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */
|
||||
/* UNUSED BASE + 255 */
|
||||
public static final int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */
|
||||
public static final int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */
|
||||
/* UNUSED BASE + 258 */
|
||||
/* UNUSED BASE + 259 */
|
||||
public static final int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */
|
||||
|
||||
/*
|
||||
* NetProfile
|
||||
* Error codes BASE + 270 to BASE + 276
|
||||
*/
|
||||
|
||||
public static final int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */
|
||||
public static final int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */
|
||||
public static final int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */
|
||||
public static final int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/
|
||||
public static final int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */
|
||||
public static final int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */
|
||||
|
||||
|
||||
/*
|
||||
* NetAudit and NetErrorLog
|
||||
* Error codes BASE + 277 to BASE + 279
|
||||
*/
|
||||
|
||||
public static final int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */
|
||||
public static final int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */
|
||||
public static final int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */
|
||||
|
||||
|
||||
/*
|
||||
* NetRemote
|
||||
* Error codes BASE + 280 to BASE + 299
|
||||
*/
|
||||
public static final int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */
|
||||
public static final int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */
|
||||
public static final int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */
|
||||
public static final int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */
|
||||
/* UNUSED BASE + 284 */
|
||||
public static final int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */
|
||||
/* UNUSED BASE + 286 */
|
||||
/* UNUSED BASE + 287 */
|
||||
/* UNUSED BASE + 288 */
|
||||
public static final int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */
|
||||
/* UNUSED BASE + 290 */
|
||||
public static final int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */
|
||||
public static final int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/
|
||||
/* UNUSED BASE + 293 */
|
||||
/* UNUSED BASE + 294 */
|
||||
|
||||
|
||||
/*
|
||||
* NetWksta.sys = redir; returned error codes.
|
||||
*
|
||||
* NERR_BASE + = 300-329;
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */
|
||||
public static final int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */
|
||||
public static final int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */
|
||||
public static final int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */
|
||||
public static final int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */
|
||||
public static final int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */
|
||||
|
||||
/*
|
||||
* Alert error codes.
|
||||
*
|
||||
* NERR_BASE + = 330-339;
|
||||
*/
|
||||
public static final int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */
|
||||
public static final int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */
|
||||
public static final int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */
|
||||
public static final int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/
|
||||
public static final int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted
|
||||
* because the user's logon hours are no longer valid. */
|
||||
|
||||
/*
|
||||
* Additional Error and Audit log codes.
|
||||
*
|
||||
* NERR_BASE + (340-343;
|
||||
*/
|
||||
public static final int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */
|
||||
/* UNUSED BASE + 341 */
|
||||
/* UNUSED BASE + 342 */
|
||||
/* UNUSED BASE + 343 */
|
||||
|
||||
/*
|
||||
* Additional UAS and NETLOGON codes
|
||||
*
|
||||
* NERR_BASE + (350-359;
|
||||
*/
|
||||
public static final int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */
|
||||
public static final int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */
|
||||
public static final int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */
|
||||
public static final int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */
|
||||
public static final int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */
|
||||
public static final int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */
|
||||
public static final int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */
|
||||
public static final int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */
|
||||
public static final int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */
|
||||
|
||||
|
||||
/*
|
||||
* Server Integration error codes.
|
||||
*
|
||||
* NERR_BASE + (360-369;
|
||||
*/
|
||||
public static final int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */
|
||||
public static final int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */
|
||||
public static final int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */
|
||||
public static final int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */
|
||||
public static final int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */
|
||||
public static final int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */
|
||||
public static final int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */
|
||||
public static final int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */
|
||||
/* UNUSED BASE + 368 */
|
||||
/* UNUSED BASE + 369 */
|
||||
|
||||
public static final int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */
|
||||
|
||||
/*
|
||||
* UPS error codes.
|
||||
*
|
||||
* NERR_BASE + = 380-384;
|
||||
*/
|
||||
public static final int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */
|
||||
public static final int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */
|
||||
public static final int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */
|
||||
public static final int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */
|
||||
public static final int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */
|
||||
|
||||
/*
|
||||
* Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 400-419;
|
||||
* Error codes 400 - 405 are used by RPLBOOT.SYS.
|
||||
* Error codes 403, 407 - 416 are used by RPLLOADR.COM,
|
||||
* Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;.
|
||||
* Error code 418 is for when REMOTEBOOT can't start
|
||||
* Error code 419 is for a disallowed 2nd rpl connection
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/
|
||||
public static final int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/
|
||||
public static final int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/
|
||||
public static final int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/
|
||||
public static final int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/
|
||||
public static final int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/
|
||||
public static final int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/
|
||||
public static final int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/
|
||||
public static final int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/
|
||||
public static final int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/
|
||||
public static final int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/
|
||||
public static final int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/
|
||||
public static final int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/
|
||||
public static final int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/
|
||||
public static final int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/
|
||||
public static final int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/
|
||||
|
||||
/*
|
||||
* FTADMIN API error codes
|
||||
*
|
||||
* NERR_BASE + = 425-434;
|
||||
*
|
||||
* = Currently not used in NT;
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Browser service API error codes
|
||||
*
|
||||
* NERR_BASE + = 450-475;
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */
|
||||
|
||||
/*
|
||||
* Additional Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 510-550;
|
||||
*/
|
||||
public static final int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/
|
||||
public static final int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/
|
||||
public static final int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/
|
||||
public static final int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/
|
||||
public static final int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/
|
||||
public static final int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/
|
||||
public static final int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/
|
||||
public static final int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/
|
||||
public static final int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/
|
||||
public static final int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/
|
||||
public static final int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/
|
||||
public static final int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/
|
||||
public static final int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/
|
||||
public static final int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/
|
||||
public static final int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/
|
||||
public static final int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/
|
||||
public static final int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/
|
||||
public static final int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/
|
||||
public static final int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/
|
||||
public static final int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/
|
||||
public static final int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/
|
||||
public static final int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/
|
||||
public static final int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/
|
||||
public static final int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/
|
||||
public static final int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/
|
||||
public static final int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/
|
||||
public static final int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/
|
||||
public static final int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/
|
||||
public static final int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/
|
||||
public static final int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/
|
||||
|
||||
/**INTERNAL_ONLY**/
|
||||
|
||||
/*
|
||||
* Dfs API error codes.
|
||||
*
|
||||
* NERR_BASE + = 560-590;
|
||||
*/
|
||||
|
||||
public static final int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/
|
||||
public static final int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/
|
||||
public static final int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/
|
||||
public static final int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/
|
||||
public static final int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/
|
||||
public static final int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/
|
||||
public static final int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/
|
||||
public static final int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/
|
||||
public static final int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/
|
||||
public static final int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/
|
||||
public static final int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/
|
||||
public static final int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/
|
||||
public static final int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/
|
||||
public static final int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/
|
||||
public static final int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/
|
||||
public static final int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/
|
||||
public static final int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/
|
||||
public static final int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/
|
||||
public static final int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/
|
||||
public static final int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/
|
||||
public static final int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/
|
||||
public static final int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/
|
||||
public static final int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/
|
||||
|
||||
/*
|
||||
* Net setup error codes.
|
||||
*
|
||||
* NERR_BASE + = 591-600;
|
||||
*/
|
||||
public static final int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/
|
||||
public static final int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/
|
||||
public static final int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/
|
||||
public static final int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/
|
||||
public static final int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/
|
||||
public static final int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/
|
||||
public static final int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/
|
||||
public static final int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/
|
||||
public static final int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/
|
||||
|
||||
/*
|
||||
* Some Password and account error results
|
||||
*
|
||||
* NERR_BASE + = 601 - 608;
|
||||
*/
|
||||
public static final int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */
|
||||
public static final int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */
|
||||
public static final int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */
|
||||
public static final int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */
|
||||
public static final int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2750-2799 has been *
|
||||
*allocated to the IBM LAN Server *
|
||||
***********************************/
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2900-2999 has been *
|
||||
*reserved for Microsoft OEMs *
|
||||
***********************************/
|
||||
|
||||
public static final int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMJoin.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMJoin extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* Status of a workstation.
|
||||
*/
|
||||
public abstract class NETSETUP_JOIN_STATUS {
|
||||
public static final int NetSetupUnknownStatus = 0;
|
||||
public static final int NetSetupUnjoined = 1;
|
||||
public static final int NetSetupWorkgroupName = 2;
|
||||
public static final int NetSetupDomainName = 3;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from NTSecApi.h
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface NTSecApi extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
|
||||
* functions to specify a Unicode string.
|
||||
*/
|
||||
public static class LSA_UNICODE_STRING extends Structure {
|
||||
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
|
||||
* not including the terminating null character, if any.
|
||||
*/
|
||||
public short Length;
|
||||
/**
|
||||
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
|
||||
* MaximumLength bytes can be written into the buffer without trampling memory.
|
||||
*/
|
||||
public short MaximumLength;
|
||||
/**
|
||||
* Pointer to a wide character string. Note that the strings returned by the
|
||||
* various LSA functions might not be null terminated.
|
||||
*/
|
||||
public Pointer Buffer;
|
||||
|
||||
/**
|
||||
* String representation of the buffer.
|
||||
* @return
|
||||
* Unicode string.
|
||||
*/
|
||||
public String getString() {
|
||||
byte[] data = Buffer.getByteArray(0, Length);
|
||||
if (data.length < 2 || data[data.length - 1] != 0) {
|
||||
Memory newdata = new Memory(data.length + 2);
|
||||
newdata.write(0, data, 0, data.length);
|
||||
return newdata.getString(0, true);
|
||||
}
|
||||
return Buffer.getString(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to an LSA_UNICODE_STRING.
|
||||
*/
|
||||
public static class PLSA_UNICODE_STRING {
|
||||
public static class ByReference extends PLSA_UNICODE_STRING
|
||||
implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING.ByReference s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record contains an included top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelName = 0;
|
||||
/**
|
||||
* Record contains an excluded top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelNameEx = 1;
|
||||
/**
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
*/
|
||||
public static final int ForestTrustDomainInfo = 2;
|
||||
|
||||
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
|
||||
public PSID.ByReference Sid;
|
||||
public LSA_UNICODE_STRING DnsName;
|
||||
public LSA_UNICODE_STRING NetbiosName;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
|
||||
public NativeLong Length;
|
||||
public Pointer Buffer;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_RECORD extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public static class UNION extends Union {
|
||||
public static class ByReference extends UNION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING TopLevelName;
|
||||
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
|
||||
public LSA_FOREST_TRUST_BINARY_DATA Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags that control the behavior of the operation.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
|
||||
/**
|
||||
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
|
||||
* The following table shows the possible values.
|
||||
* ForestTrustTopLevelName
|
||||
* Record contains an included top-level name.
|
||||
* ForestTrustTopLevelNameEx
|
||||
* Record contains an excluded top-level name.
|
||||
* ForestTrustDomainInfo
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
* ForestTrustRecordTypeLast
|
||||
* Marks the end of an enumeration.
|
||||
*/
|
||||
public int ForestTrustType;
|
||||
public LARGE_INTEGER Time;
|
||||
|
||||
/**
|
||||
* Data type depending on ForestTrustType.
|
||||
*/
|
||||
public UNION u;
|
||||
|
||||
public void read() {
|
||||
super.read();
|
||||
|
||||
switch(ForestTrustType) {
|
||||
case NTSecApi.ForestTrustTopLevelName:
|
||||
case NTSecApi.ForestTrustTopLevelNameEx:
|
||||
u.setType(LSA_UNICODE_STRING.class);
|
||||
break;
|
||||
case NTSecApi.ForestTrustDomainInfo:
|
||||
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
|
||||
break;
|
||||
default:
|
||||
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
|
||||
break;
|
||||
}
|
||||
|
||||
u.read();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_RECORD.ByReference tr;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
|
||||
* Entries member.
|
||||
*/
|
||||
public NativeLong RecordCount;
|
||||
/**
|
||||
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
|
||||
* each of which contains one piece of forest trust information.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
|
||||
|
||||
/**
|
||||
* Get an array of LSA_FOREST_TRUST_RECORD entries.
|
||||
* @return
|
||||
* An array of forest trust records.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
|
||||
* forest trust information.
|
||||
*/
|
||||
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
public interface NTStatus extends StdCallLibrary {
|
||||
|
||||
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
|
||||
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_0
|
||||
//
|
||||
public static final int STATUS_WAIT_0 = 0x00000000; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_1
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_1
|
||||
//
|
||||
public static final int STATUS_WAIT_1 = 0x00000001;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_2
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_2
|
||||
//
|
||||
public static final int STATUS_WAIT_2 = 0x00000002;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_3
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_3
|
||||
//
|
||||
public static final int STATUS_WAIT_3 = 0x00000003;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_63
|
||||
//
|
||||
public static final int STATUS_WAIT_63 = 0x0000003F;
|
||||
|
||||
//
|
||||
// The success status codes 128 - 191 are reserved for wait completion
|
||||
// status with an abandoned mutant object.
|
||||
//
|
||||
public static final int STATUS_ABANDONED = 0x00000080;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_63 = 0x000000BF;
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Netapi32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Netapi32 extends StdCallLibrary {
|
||||
|
||||
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
|
||||
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Retrieves join status information for the specified computer.
|
||||
*
|
||||
* @param lpServer
|
||||
* Specifies the DNS or NetBIOS name of the computer on which to
|
||||
* call the function.
|
||||
* @param lpNameBuffer
|
||||
* Receives the NetBIOS name of the domain or workgroup to which
|
||||
* the computer is joined.
|
||||
* @param BufferType
|
||||
* Join status of the specified computer.
|
||||
* @return If the function succeeds, the return value is NERR_Success. If
|
||||
* the function fails, the return value is a system error code.
|
||||
*/
|
||||
public int NetGetJoinInformation(String lpServer,
|
||||
PointerByReference lpNameBuffer, IntByReference BufferType);
|
||||
|
||||
/**
|
||||
* Frees the memory that the NetApiBufferAllocate function allocates.
|
||||
*
|
||||
* @param buffer
|
||||
* @return If the function succeeds, the return value is NERR_Success. If
|
||||
* the function fails, the return value is a system error code.
|
||||
*/
|
||||
public int NetApiBufferFree(Pointer buffer);
|
||||
|
||||
/**
|
||||
* Returns information about each local group account on the specified
|
||||
* server.
|
||||
*
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on
|
||||
* which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the address of the buffer that receives the
|
||||
* information structure.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in
|
||||
* bytes.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements
|
||||
* actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the approximate total number
|
||||
* of entries that could have been enumerated from the current
|
||||
* resume position.
|
||||
* @param resume_handle
|
||||
* Pointer to a value that contains a resume handle that is used
|
||||
* to continue an existing local group search.
|
||||
* @return If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetLocalGroupEnum(String serverName, int level,
|
||||
PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC).
|
||||
*
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on which the function is
|
||||
* to execute. If this parameter is NULL, the local computer is used.
|
||||
* @param domainName
|
||||
* Specifies the name of the domain.
|
||||
* @param bufptr
|
||||
* Receives a string that specifies the server name of the PDC of the domain.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetGetDCName(String serverName, String domainName,
|
||||
PointerByReference bufptr);
|
||||
|
||||
/**
|
||||
* The NetGroupEnum function retrieves information about each global group
|
||||
* in the security database, which is the security accounts manager (SAM) database or,
|
||||
* in the case of domain controllers, the Active Directory.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer to receive the global group information structure.
|
||||
* The format of this data depends on the value of the level parameter.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of the returned data, in bytes.
|
||||
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
|
||||
* memory required to hold the data. If you specify another value in this
|
||||
* parameter, it can restrict the number of bytes that the function returns.
|
||||
* If the buffer size is insufficient to hold all entries, the function
|
||||
* returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have
|
||||
* been enumerated from the current resume position. The total number of entries
|
||||
* is only a hint.
|
||||
* @param resume_handle
|
||||
* Pointer to a variable that contains a resume handle that is used to continue
|
||||
* the global group enumeration. The handle should be zero on the first call and
|
||||
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
|
||||
* is stored.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* The NetUserEnum function provides information about all user accounts on a server.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param filter
|
||||
* Specifies a value that filters the account types for enumeration.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. The format of this data depends
|
||||
* on the value of the level parameter. This buffer is allocated by the system and
|
||||
* must be freed using the NetApiBufferFree function. Note that you must free the
|
||||
* buffer even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
|
||||
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
|
||||
* required for the data. If you specify another value in this parameter, it can
|
||||
* restrict the number of bytes that the function returns. If the buffer size is
|
||||
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have
|
||||
* been enumerated from the current resume position. Note that applications should
|
||||
* consider this value only as a hint.
|
||||
* @param resume_handle
|
||||
* Pointer to a value that contains a resume handle which is used to continue an
|
||||
* existing user search. The handle should be zero on the first call and left
|
||||
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
|
||||
* handle is stored.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* The NetUserGetGroups function retrieves a list of global groups to which a
|
||||
* specified user belongs.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user to search for
|
||||
* in each group account. For more information, see the following Remarks section.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. This buffer is allocated by the
|
||||
* system and must be freed using the NetApiBufferFree function. Note that you must
|
||||
* free the buffer even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in bytes. If you specify
|
||||
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
|
||||
* data. If you specify another value in this parameter, it can restrict the number
|
||||
* of bytes that the function returns. If the buffer size is insufficient to hold
|
||||
* all entries, the function returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually retrieved.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have been retrieved.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserGetGroups(String servername, String username, int level,
|
||||
PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/**
|
||||
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
|
||||
* specified user belongs.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
|
||||
* server on which the function is to execute. If this parameter is NULL, the local
|
||||
* computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user for which to return
|
||||
* local group membership information. If the string is of the form DomainName\UserName
|
||||
* the user name is expected to be found on that domain. If the string is of the form
|
||||
* UserName, the user name is expected to be found on the server specified by the
|
||||
* servername parameter.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param flags
|
||||
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
|
||||
* defined. If this bit is set, the function also returns the names of the local
|
||||
* groups in which the user is indirectly a member (that is, the user has membership
|
||||
* in a global group that is itself a member of one or more local groups).
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. The format of this data depends on
|
||||
* the value of the level parameter. This buffer is allocated by the system and must
|
||||
* be freed using the NetApiBufferFree function. Note that you must free the buffer
|
||||
* even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in bytes. If you specify
|
||||
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
|
||||
* data. If you specify another value in this parameter, it can restrict the number of
|
||||
* bytes that the function returns. If the buffer size is insufficient to hold all
|
||||
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
|
||||
* Management Function Buffers and Network Management Function Buffer Lengths.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have been enumerated.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserGetLocalGroups(String servername, String username, int level,
|
||||
int flags, PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/**
|
||||
* The NetUserAdd function adds a user account and assigns a password and privilege level.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
|
||||
* on which the function is to execute.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param buf
|
||||
* Pointer to the buffer that specifies the data. The format of this data depends on the
|
||||
* value of the level parameter.
|
||||
* @param parm_err
|
||||
* Pointer to a value that receives the index of the first member of the user information
|
||||
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
|
||||
* not returned on error.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserAdd(String servername, int level,
|
||||
Structure buf, IntByReference parm_err);
|
||||
|
||||
|
||||
/**
|
||||
* The NetUserDel function deletes a user account from a server.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
|
||||
* server on which the function is to execute. If this parameter is NULL, the local
|
||||
* computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user account to delete.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserDel(String servername, String username);
|
||||
|
||||
/**
|
||||
* The NetUserChangePassword function changes a user's password for a specified
|
||||
* network server or domain.
|
||||
* @param domainname
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
|
||||
* server or domain on which the function is to execute. If this parameter is NULL,
|
||||
* the logon domain of the caller is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
|
||||
* function changes the password for the specified user. If this parameter is NULL,
|
||||
* the logon name of the caller is used.
|
||||
* @param oldpassword
|
||||
* Pointer to a constant string that specifies the user's old password.
|
||||
* @param newpassword
|
||||
* Pointer to a constant string that specifies the user's new password.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserChangePassword(String domainname, String username,
|
||||
String oldpassword, String newpassword);
|
||||
|
||||
/**
|
||||
* The DsGetDcName function returns the name of a domain controller in a specified domain.
|
||||
* This function accepts additional domain controller selection criteria to indicate
|
||||
* preference for a domain controller with particular characteristics.
|
||||
* @param ComputerName
|
||||
* Pointer to a null-terminated string that specifies the name of the server to process
|
||||
* this function. Typically, this parameter is NULL, which indicates that the local
|
||||
* computer is used.
|
||||
* @param DomainName
|
||||
* Pointer to a null-terminated string that specifies the name of the domain or application
|
||||
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
|
||||
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
|
||||
* may be specified with or without a trailing period.
|
||||
* @param DomainGuid
|
||||
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
|
||||
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
|
||||
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
|
||||
* by DomainGuid.
|
||||
* @param SiteName
|
||||
* Pointer to a null-terminated string that specifies the name of the site where the returned
|
||||
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
|
||||
* to return a domain controller in the site closest to the site of the computer specified by
|
||||
* ComputerName. This parameter should be NULL, by default.
|
||||
* @param Flags
|
||||
* Contains a set of flags that provide additional data used to process the request.
|
||||
* @param DomainControllerInfo
|
||||
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
|
||||
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
|
||||
* This structure is allocated by DsGetDcName. The caller must free the structure using
|
||||
* the NetApiBufferFree function when it is no longer required.
|
||||
* @return
|
||||
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
|
||||
* If the function fails, the return code is one of ERROR_* values.
|
||||
*/
|
||||
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
|
||||
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO.ByReference DomainControllerInfo);
|
||||
|
||||
/**
|
||||
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
|
||||
* @param serverName
|
||||
* Contains the name of the domain controller that DsGetForestTrustInformationW
|
||||
* is connected to remotely. The caller must be an authenticated user on this server.
|
||||
* If this parameter is NULL, the local server is used.
|
||||
* @param trustedDomainName
|
||||
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
|
||||
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
|
||||
* trust attribute. If this parameter is NULL, the forest trust data for the domain
|
||||
* hosted by ServerName is retrieved.
|
||||
* @param Flags
|
||||
* Contains a set of flags that modify the behavior of this function.
|
||||
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
|
||||
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
|
||||
* @param ForestTrustInfo
|
||||
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
|
||||
* trust data that describes the namespaces claimed by the domain specified by
|
||||
* TrustedDomainName. The Time member of all returned records will be zero.
|
||||
* @return
|
||||
* Returns NO_ERROR if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
|
||||
PLSA_FOREST_TRUST_INFORMATION.ByReference ForestTrustInfo);
|
||||
|
||||
/**
|
||||
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
|
||||
* @param serverName
|
||||
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
|
||||
* obtain the trust information for. This computer must be running the Windows 2000 or later
|
||||
* operating system. If this parameter is NULL, the name of the local computer is used.
|
||||
* The caller must be an authenticated user in this domain.
|
||||
* @param Flags
|
||||
* Contains a set of flags that determines which domain trusts to enumerate.
|
||||
* @param Domains
|
||||
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
|
||||
* Each structure in this array contains trust data about a domain. The caller must free this
|
||||
* memory when it is no longer required by calling NetApiBufferFree.
|
||||
* @param DomainCount
|
||||
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
|
||||
* @return
|
||||
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
|
||||
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Netapi32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Netapi32Util {
|
||||
|
||||
/**
|
||||
* A group.
|
||||
*/
|
||||
public static class Group {
|
||||
/**
|
||||
* Group name.
|
||||
*/
|
||||
public String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user.
|
||||
*/
|
||||
public static class User {
|
||||
/**
|
||||
* The name of the user account.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Contains a comment associated with the user account.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
/**
|
||||
* A local group.
|
||||
*/
|
||||
public static class LocalGroup extends Group {
|
||||
/**
|
||||
* Group comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC) on the current computer.
|
||||
* @return The name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName() {
|
||||
return getDCName(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC).
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on which the function is
|
||||
* to execute.
|
||||
* @param domainName
|
||||
* Specifies the name of the domain.
|
||||
* @return
|
||||
* Name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName(String serverName, String domainName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufptr.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus() {
|
||||
return getJoinStatus(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @param computerName Computer name.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufferType.getValue();
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a computer.
|
||||
* @param computerName
|
||||
* @return Domain or workgroup name.
|
||||
*/
|
||||
public static String getDomainName(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// type of domain: bufferType.getValue()
|
||||
return lpNameBuffer.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on the current computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups() {
|
||||
return getLocalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LOCALGROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui1_name.toString();
|
||||
lgp.comment = lgpi.lgrui1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups() {
|
||||
return getGlobalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.grpi1_name.toString();
|
||||
lgp.comment = lgpi.grpi1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a local computer.
|
||||
* @return Users.
|
||||
*/
|
||||
public static User[] getUsers() {
|
||||
return getUsers(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of users.
|
||||
*/
|
||||
public static User[] getUsers(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
|
||||
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<User> result = new ArrayList<User>();
|
||||
for(LMAccess.USER_INFO_1 lu : users) {
|
||||
User auser = new User();
|
||||
auser.name = lu.usri1_name.toString();
|
||||
result.add(auser);
|
||||
}
|
||||
return result.toArray(new User[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of the current user.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserLocalGroups() {
|
||||
return getUserLocalGroups(Secur32Util.getUserNameEx(
|
||||
EXTENDED_NAME_FORMAT.NameSamCompatible));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName) {
|
||||
return getUserLocalGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
|
||||
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
|
||||
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName) {
|
||||
return getUserGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
|
||||
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
|
||||
GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
Group lgp = new Group();
|
||||
lgp.name = lgpi.grui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain controller.
|
||||
*/
|
||||
public static class DomainController {
|
||||
/**
|
||||
* Specifies the computer name of the discovered domain controller.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Specifies the address of the discovered domain controller.
|
||||
*/
|
||||
public String address;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the
|
||||
* DomainControllerAddress member.
|
||||
*/
|
||||
public int addressType;
|
||||
/**
|
||||
* The GUID of the domain.
|
||||
*/
|
||||
public GUID domainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain.
|
||||
*/
|
||||
public String domainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree.
|
||||
*/
|
||||
public String dnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int flags;
|
||||
/**
|
||||
* The name of the site that the computer belongs to.
|
||||
*/
|
||||
public String clientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain controller for a current computer.
|
||||
* @return
|
||||
* Domain controller information.
|
||||
*/
|
||||
public static DomainController getDC() {
|
||||
PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
|
||||
if (W32Errors.ERROR_SUCCESS != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
DomainController dc = new DomainController();
|
||||
dc.address = pdci.dci.DomainControllerAddress.toString();
|
||||
dc.addressType = pdci.dci.DomainControllerAddressType;
|
||||
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
|
||||
dc.dnsForestName = pdci.dci.DnsForestName.toString();
|
||||
dc.domainGuid = pdci.dci.DomainGuid;
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
dc.flags = pdci.dci.Flags;
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain trust relationship.
|
||||
*/
|
||||
public static class DomainTrust {
|
||||
/**
|
||||
* NetBIOS name of the domain.
|
||||
*/
|
||||
public String NetbiosDomainName;
|
||||
/**
|
||||
* DNS name of the domain.
|
||||
*/
|
||||
public String DnsDomainName;
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID DomainSid;
|
||||
/**
|
||||
* Contains the string representation of the security identifier of the domain
|
||||
* represented by this structure.
|
||||
*/
|
||||
public String DomainSidString;
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Contains the string representation of the GUID of the domain represented by
|
||||
* this structure.
|
||||
*/
|
||||
public String DomainGuidString;
|
||||
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
private int flags;
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is a member of the same forest
|
||||
* as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInForest() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is directly trusted by the domain
|
||||
* that the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isOutbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the root of a tree and a member
|
||||
* of the same forest as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isRoot() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the primary domain of the server
|
||||
* specified in the ServerName parameter of the DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isPrimary() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is running in the Windows 2000 native mode.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isNativeMode() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure directly trusts the domain that
|
||||
* the server specified in the ServerName parameter of the DsEnumerateDomainTrusts
|
||||
* function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts() {
|
||||
return getDomainTrusts(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts for a given server.
|
||||
* @param serverName
|
||||
* Server name.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts(String serverName) {
|
||||
NativeLongByReference domainCount = new NativeLongByReference();
|
||||
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
|
||||
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
int domainCountValue = domainCount.getValue().intValue();
|
||||
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
|
||||
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
|
||||
DomainTrust t = new DomainTrust();
|
||||
t.DnsDomainName = trust.DnsDomainName.toString();
|
||||
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
|
||||
t.DomainSid = trust.DomainSid;
|
||||
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
|
||||
t.DomainGuid = trust.DomainGuid;
|
||||
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
|
||||
t.flags = trust.Flags.intValue();
|
||||
trusts.add(t);
|
||||
}
|
||||
return trusts.toArray(new DomainTrust[0]);
|
||||
} finally {
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* ntdll.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface NtDll extends StdCallLibrary {
|
||||
|
||||
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
|
||||
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ZwQueryKey routine provides information about the class of a registry key,
|
||||
* and the number and sizes of its subkeys.
|
||||
* @param KeyHandle
|
||||
* Handle to the registry key to obtain information about. This handle is created by
|
||||
* a successful call to ZwCreateKey or ZwOpenKey.
|
||||
* @param KeyInformationClass
|
||||
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
|
||||
* returned in the KeyInformation buffer.
|
||||
* @param KeyInformation
|
||||
* Pointer to a caller-allocated buffer that receives the requested information.
|
||||
* @param Length
|
||||
* Specifies the size, in bytes, of the KeyInformation buffer.
|
||||
* @param ResultLength
|
||||
* Pointer to a variable that receives the size, in bytes, of the requested key
|
||||
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
|
||||
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
|
||||
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
|
||||
* required buffer size.
|
||||
* @return
|
||||
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
|
||||
*/
|
||||
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
|
||||
Structure KeyInformation, int Length, IntByReference ResultLength);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.Wdm.KEY_BASIC_INFORMATION;
|
||||
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* NtDll Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class NtDllUtil {
|
||||
|
||||
/**
|
||||
* Retrieve the name of an opened registry key.
|
||||
* @param hkey Opened registry key.
|
||||
* @return Basic key name, not including node information.
|
||||
*/
|
||||
public static String getKeyName(HKEY hkey) {
|
||||
IntByReference resultLength = new IntByReference();
|
||||
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
|
||||
null, 0, resultLength);
|
||||
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
|
||||
resultLength.getValue());
|
||||
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
|
||||
keyInformation, resultLength.getValue(), resultLength);
|
||||
if (rc != NTStatus.STATUS_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return keyInformation.getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
|
||||
/**
|
||||
* Definitions from ObjBase.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface ObjBase {
|
||||
|
||||
public static final int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
|
||||
|
||||
// With DCOM, CLSCTX_REMOTE_SERVER should be included
|
||||
public static final int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_INPROC_HANDLER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
|
||||
public static final int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Ole32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Ole32 extends StdCallLibrary {
|
||||
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
|
||||
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
|
||||
* @param pguid
|
||||
* A pointer to the requested GUID.
|
||||
* @return
|
||||
* S_OK if the GUID was successfully created.
|
||||
*/
|
||||
HRESULT CoCreateGuid(GUID.ByReference pguid);
|
||||
|
||||
/**
|
||||
* Converts a globally unique identifier (GUID) into a string of printable characters.
|
||||
* @param rguid
|
||||
* The GUID to be converted.
|
||||
* @param lpsz
|
||||
* A pointer to a caller-allocated string variable to receive the resulting string.
|
||||
* @param cchMax
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of characters in the
|
||||
* returned string, including the null terminator. If the buffer is too small to contain
|
||||
* the string, the return value is 0.
|
||||
*/
|
||||
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* original interface identifier (IID).
|
||||
* @param lpsz
|
||||
* A pointer to the string representation of the IID.
|
||||
* @param lpiid
|
||||
* A pointer to the requested IID on return.
|
||||
* @return
|
||||
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
|
||||
* and S_OK.
|
||||
*/
|
||||
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
|
||||
|
||||
/**
|
||||
* Initializes the COM library for use by the calling thread, sets the thread's
|
||||
* concurrency model, and creates a new apartment for the thread if one is required.
|
||||
* @param reserved This parameter is reserved and must be NULL.
|
||||
* @param dwCoInit The concurrency model and initialization options for the
|
||||
* thread. Values for this parameter are taken from the COINIT enumeration.
|
||||
* Any combination of values from COINIT can be used, except that the
|
||||
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
|
||||
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
|
||||
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
|
||||
*/
|
||||
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
|
||||
|
||||
/**
|
||||
* Closes the COM library on the current thread, unloads all DLLs loaded by
|
||||
* the thread, frees any other resources that the thread maintains, and
|
||||
* forces all RPC connections on the thread to close.
|
||||
*
|
||||
*/
|
||||
void CoUninitialize();
|
||||
|
||||
/**
|
||||
* Creates a single uninitialized object of the class associated with a specified CLSID.
|
||||
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
|
||||
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
|
||||
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
|
||||
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
|
||||
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
|
||||
* @return an HRESULT
|
||||
*/
|
||||
HRESULT CoCreateInstance(
|
||||
GUID rclsid,
|
||||
Pointer pUnkOuter,
|
||||
int dwClsContext,
|
||||
GUID riid,
|
||||
PointerByReference ppv);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Ole32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Ole32Util {
|
||||
|
||||
/**
|
||||
* Convert a string to a GUID.
|
||||
* @param guidString
|
||||
* String representation of a GUID, including { }.
|
||||
* @return
|
||||
* A GUID.
|
||||
*/
|
||||
public static GUID getGUIDFromString(String guidString) {
|
||||
GUID.ByReference lpiid = new GUID.ByReference();
|
||||
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new RuntimeException(hr.toString());
|
||||
}
|
||||
return lpiid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a GUID into a string.
|
||||
* @param guid
|
||||
* GUID.
|
||||
* @return
|
||||
* String representation of a GUID.
|
||||
*/
|
||||
public static String getStringFromGUID(GUID guid) {
|
||||
GUID.ByReference pguid = new GUID.ByReference(guid.getPointer());
|
||||
int max = 39;
|
||||
char[] lpsz = new char[max];
|
||||
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
|
||||
if (len == 0) {
|
||||
throw new RuntimeException("StringFromGUID2");
|
||||
}
|
||||
lpsz[len - 1] = 0;
|
||||
return Native.toString(lpsz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new GUID.
|
||||
* @return
|
||||
* New GUID.
|
||||
*/
|
||||
public static GUID generateGUID() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new RuntimeException(hr.toString());
|
||||
}
|
||||
return pguid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Digital Rapids Corp., All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface Oleaut32 extends StdCallLibrary {
|
||||
|
||||
Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary(
|
||||
"Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function allocates a new string and copies the passed string into it.
|
||||
* @param sz
|
||||
* Null-terminated UNICODE string to copy.
|
||||
* @return
|
||||
* Null if there is insufficient memory or if a null pointer is passed in.
|
||||
*/
|
||||
Pointer SysAllocString(String sz);
|
||||
|
||||
/**
|
||||
* This function frees a string allocated previously by SysAllocString,
|
||||
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
|
||||
* SysReAllocStringLen.
|
||||
* @param bstr
|
||||
* Unicode string that was allocated previously, or NULL. Setting this parameter
|
||||
* to NULL causes the function to simply return.
|
||||
*/
|
||||
void SysFreeString(Pointer bstr);
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Sspi.CredHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
|
||||
import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
|
||||
import com.sun.jna.platform.win32.Sspi.TimeStamp;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LUID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Secur32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Secur32 extends StdCallLibrary {
|
||||
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
|
||||
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Specifies a format for a directory service object name.
|
||||
* http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx
|
||||
*/
|
||||
public abstract class EXTENDED_NAME_FORMAT {
|
||||
public static final int NameUnknown = 0;
|
||||
public static final int NameFullyQualifiedDN = 1;
|
||||
public static final int NameSamCompatible = 2;
|
||||
public static final int NameDisplay = 3;
|
||||
public static final int NameUniqueId = 6;
|
||||
public static final int NameCanonical = 7;
|
||||
public static final int NameUserPrincipal = 8;
|
||||
public static final int NameCanonicalEx = 9;
|
||||
public static final int NameServicePrincipal = 10;
|
||||
public static final int NameDnsDomain = 12;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated with
|
||||
* the calling thread. You can specify the format of the returned name.
|
||||
* @param nameFormat The format of the name.
|
||||
* @param lpNameBuffer A pointer to a buffer that receives the name in the specified format.
|
||||
* @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character.
|
||||
* @return True if the function succeeds. False otherwise.
|
||||
*/
|
||||
public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len);
|
||||
|
||||
/**
|
||||
* The AcquireCredentialsHandle function acquires a handle to preexisting credentials
|
||||
* of a security principal. This handle is required by the AcceptSecurityContext
|
||||
* and InitializeSecurityContext functions. These can be either preexisting credentials,
|
||||
* which are established through a system logon that is not described here, or the
|
||||
* caller can provide alternative credentials.
|
||||
* @param pszPrincipal
|
||||
* A pointer to a null-terminated string that specifies the name of the principal whose
|
||||
* credentials the handle will reference.
|
||||
* @param pszPackage
|
||||
* A pointer to a null-terminated string that specifies the name of the security package
|
||||
* with which these credentials will be used.
|
||||
* @param fCredentialUse
|
||||
* A flag that indicates how these credentials will be used.
|
||||
* @param pvLogonID
|
||||
* A pointer to a locally unique identifier (LUID) that identifies the user.
|
||||
* @param pAuthData
|
||||
* A pointer to package-specific data. This parameter can be NULL, which indicates
|
||||
* that the default credentials for that package must be used. To use supplied
|
||||
* credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials
|
||||
* in this parameter.
|
||||
* @param pGetKeyFn
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param pvGetKeyArgument
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param phCredential
|
||||
* A pointer to a CredHandle structure to receive the credential handle.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the time at which the returned
|
||||
* credentials expire. The value returned in this TimeStamp structure depends on
|
||||
* the security package. The security package must return this value in local time.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
|
||||
NativeLong fCredentialUse, LUID pvLogonID,
|
||||
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
|
||||
Pointer pvGetKeyArgument, CredHandle phCredential,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The InitializeSecurityContext function initiates the client side, outbound security
|
||||
* context from a credential handle. The function is used to build a security context
|
||||
* between the client application and a remote peer. InitializeSecurityContext returns
|
||||
* a token that the client must pass to the remote peer, which the peer in turn submits
|
||||
* to the local security implementation through the AcceptSecurityContext call. The
|
||||
* token generated should be considered opaque by all callers.
|
||||
*
|
||||
* Typically, the InitializeSecurityContext function is called in a loop until a
|
||||
* sufficient security context is established.
|
||||
*
|
||||
* @param phCredential
|
||||
* A handle to the credentials returned by AcquireCredentialsHandle. This handle is
|
||||
* used to build the security context. The InitializeSecurityContext function requires
|
||||
* at least OUTBOUND credentials.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer is NULL. On the second call, this parameter is a pointer to the handle
|
||||
* to the partially formed context returned in the phNewContext parameter by the first
|
||||
* call.
|
||||
* @param pszTargetName
|
||||
* A pointer to a null-terminated string that indicates the target of the context.
|
||||
* The string contents are security-package specific.
|
||||
* @param fContextReq
|
||||
* Bit flags that indicate requests for the context. Not all packages can support all
|
||||
* requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example,
|
||||
* ISC_REQ_DELEGATE.
|
||||
* @param Reserved1
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can be
|
||||
* either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied
|
||||
* as input to the package. The pointer must be NULL on the first call to the function.
|
||||
* On subsequent calls to the function, it is a pointer to a buffer allocated with enough
|
||||
* memory to hold the token returned by the remote peer.
|
||||
* @param Reserved2
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer receives the new context handle. On the second call, phNewContext can be
|
||||
* the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure
|
||||
* that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it
|
||||
* will be there on output. The system will allocate a buffer for the security token if
|
||||
* requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer
|
||||
* descriptor for the security token.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable to receive a set of bit flags that indicate the attributes of
|
||||
* the established context. Flags used for this parameter are prefixed with ISC_RET,
|
||||
* such as ISC_RET_DELEGATE.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* It is recommended that the security package always return this value in local time.
|
||||
* This parameter is optional and NULL should be passed for short-lived clients.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
|
||||
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The DeleteSecurityContext function deletes the local data structures associated
|
||||
* with the specified security context.
|
||||
* @param phContext
|
||||
* Handle of the security context to delete.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int DeleteSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* The FreeCredentialsHandle function notifies the security system that the
|
||||
* credentials are no longer needed. An application calls this function to free
|
||||
* the credential handle acquired in the call to the AcquireCredentialsHandle
|
||||
* function. When all references to this credential set have been removed, the
|
||||
* credentials themselves can be removed.
|
||||
* @param phCredential
|
||||
* A pointer to the credential handle obtained by using the AcquireCredentialsHandle
|
||||
* function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int FreeCredentialsHandle(CredHandle phCredential);
|
||||
|
||||
/**
|
||||
* The AcceptSecurityContext function enables the server component of a transport
|
||||
* application to establish a security context between the server and a remote client.
|
||||
* The remote client uses the InitializeSecurityContext function to start the process
|
||||
* of establishing a security context. The server can require one or more reply tokens
|
||||
* from the remote client to complete establishing the security context.
|
||||
* @param phCredential
|
||||
* A handle to the credentials of the server. The server calls the AcquireCredentialsHandle
|
||||
* function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve
|
||||
* this handle.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer is NULL. On subsequent calls, phContext is the handle to the partially
|
||||
* formed context that was returned in the phNewContext parameter by the first call.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure generated by a client call to
|
||||
* InitializeSecurityContext that contains the input buffer descriptor.
|
||||
* @param fContextReq
|
||||
* Bit flags that specify the attributes required by the server to establish the
|
||||
* context. Bit flags can be combined by using bitwise-OR operations.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can
|
||||
* be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer receives the new context handle. On subsequent calls, phNewContext
|
||||
* can be the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains the output buffer descriptor.
|
||||
* This buffer is sent to the client for input into additional calls to
|
||||
* InitializeSecurityContext. An output buffer may be generated even if the function
|
||||
* returns SEC_E_OK. Any buffer generated must be sent back to the client application.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable that receives a set of bit flags that indicate the
|
||||
* attributes of the established context. For a description of the various attributes,
|
||||
* see Context Requirements. Flags used for this parameter are prefixed with ASC_RET,
|
||||
* for example, ASC_RET_DELEGATE.
|
||||
* @param ptsTimeStamp
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* @return
|
||||
* This function returns one of SEC_* values.
|
||||
*/
|
||||
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsTimeStamp);
|
||||
|
||||
/**
|
||||
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
|
||||
* describe the security packages available to the client.
|
||||
* @param pcPackages
|
||||
* A pointer to a ULONG variable that receives the number of packages returned.
|
||||
* @param ppPackageInfo
|
||||
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
|
||||
* Each structure contains information from the security support provider (SSP) that
|
||||
* describes a security package that is available within that SSP.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int EnumerateSecurityPackages(IntByReference pcPackages,
|
||||
PSecPkgInfo.ByReference ppPackageInfo);
|
||||
|
||||
/**
|
||||
* The FreeContextBuffer function enables callers of security package functions to free a memory
|
||||
* buffer that was allocated by the security package as a result of calls to InitializeSecurityContext
|
||||
* and AcceptSecurityContext.
|
||||
* @param buffer
|
||||
* A pointer to memory allocated by the security package.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int FreeContextBuffer(Pointer buffer);
|
||||
|
||||
/**
|
||||
* The QuerySecurityContextToken function obtains the access token for a client security context
|
||||
* and uses it directly.
|
||||
* @param phContext
|
||||
* Handle of the context to query.
|
||||
* @param phToken
|
||||
* Returned handle to the access token.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code. One possible error code return is
|
||||
* SEC_E_INVALID_HANDLE.
|
||||
*/
|
||||
public int QuerySecurityContextToken(CtxtHandle phContext,
|
||||
HANDLEByReference phToken);
|
||||
|
||||
/**
|
||||
* The ImpersonateSecurityContext function allows a server to impersonate a client by using
|
||||
* a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken.
|
||||
* This function allows the application server to act as the client, and thus all necessary
|
||||
* access controls are enforced.
|
||||
* @param phContext
|
||||
* The handle of the context to impersonate. This handle must have been obtained by a call
|
||||
* to the AcceptSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or
|
||||
* SEC_E_UNSUPPORTED_FUNCTION error code.
|
||||
*/
|
||||
public int ImpersonateSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* Allows a security package to discontinue the impersonation of the caller and restore its
|
||||
* own security context.
|
||||
* @param phContext
|
||||
* Handle of the security context being impersonated. This handle must have been obtained in
|
||||
* the call to the AcceptSecurityContext function and used in the call to the
|
||||
* ImpersonateSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION.
|
||||
*/
|
||||
public int RevertSecurityContext(CtxtHandle phContext);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
|
||||
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Secur32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Secur32Util {
|
||||
|
||||
/**
|
||||
* An SSPI package.
|
||||
*/
|
||||
public static class SecurityPackage {
|
||||
/**
|
||||
* Package name.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Package comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated
|
||||
* with the calling thread.
|
||||
*
|
||||
* @param format User name format.
|
||||
* @return User name in a given format.
|
||||
*/
|
||||
public static String getUserNameEx(int format) {
|
||||
char[] buffer = new char[128];
|
||||
IntByReference len = new IntByReference(buffer.length);
|
||||
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
|
||||
if (! result) {
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_MORE_DATA:
|
||||
buffer = new char[len.getValue() + 1];
|
||||
break;
|
||||
default:
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
}
|
||||
|
||||
if (! result) {
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the security packages installed on the current computer.
|
||||
* @return
|
||||
* An array of SSPI security packages.
|
||||
*/
|
||||
public static SecurityPackage[] getSecurityPackages() {
|
||||
IntByReference pcPackages = new IntByReference();
|
||||
PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference();
|
||||
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
|
||||
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
|
||||
for(SecPkgInfo packageInfo : packagesInfo) {
|
||||
SecurityPackage securityPackage = new SecurityPackage();
|
||||
securityPackage.name = packageInfo.Name.toString();
|
||||
securityPackage.comment = packageInfo.Comment.toString();
|
||||
packages.add(securityPackage);
|
||||
}
|
||||
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer());
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return packages.toArray(new SecurityPackage[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Shell32.dll Interface.
|
||||
*/
|
||||
public interface Shell32 extends StdCallLibrary {
|
||||
|
||||
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function can be used to copy, move, rename, or delete a file system object.
|
||||
* @param fileop
|
||||
* Address of an SHFILEOPSTRUCT structure that contains information this function
|
||||
* needs to carry out the specified operation.
|
||||
* @return
|
||||
* Returns zero if successful, or nonzero otherwise.
|
||||
*/
|
||||
int SHFileOperation(SHFILEOPSTRUCT fileop);
|
||||
|
||||
/**
|
||||
* Takes the CSIDL of a folder and returns the path.
|
||||
* @param hwndOwner
|
||||
* Handle to an owner window. This parameter is typically set to NULL. If it is not NULL,
|
||||
* and a dial-up connection needs to be made to access the folder, a user interface (UI)
|
||||
* prompt will appear in this window.
|
||||
* @param nFolder
|
||||
* A CSIDL value that identifies the folder whose path is to be retrieved. Only real
|
||||
* folders are valid. If a virtual folder is specified, this function will fail. You can
|
||||
* force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with
|
||||
* CSIDL_FLAG_CREATE.
|
||||
* @param hToken
|
||||
* An access token that can be used to represent a particular user.
|
||||
* @param dwFlags
|
||||
* Flags to specify which path is to be returned.
|
||||
* @param pszPath
|
||||
* Pointer to a null-terminated string of length MAX_PATH which will receive the path.
|
||||
* If an error occurs or S_FALSE is returned, this string will be empty.
|
||||
* @return
|
||||
* Returns standard HRESULT codes.
|
||||
*/
|
||||
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
|
||||
char[] pszPath);
|
||||
|
||||
/**
|
||||
* Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
|
||||
* The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call
|
||||
* given a suitable interface definition for IShellFolder
|
||||
* @param ppshf A place to put the IShellFolder interface pointer
|
||||
* @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
|
||||
*/
|
||||
HRESULT SHGetDesktopFolder( PointerByReference ppshf );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Shell32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Shell32Util {
|
||||
|
||||
/**
|
||||
* Get a special folder path.
|
||||
* @param hwnd
|
||||
* Parent window.
|
||||
* @param nFolder
|
||||
* Folder CSLID.
|
||||
* @param dwFlags
|
||||
* Flags.
|
||||
* @return
|
||||
* Special folder.
|
||||
*/
|
||||
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
|
||||
char[] pszPath = new char[WinDef.MAX_PATH];
|
||||
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
|
||||
nFolder, null, dwFlags,
|
||||
pszPath);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new Win32Exception(hr);
|
||||
}
|
||||
return Native.toString(pszPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a special folder path.
|
||||
* @param nFolder
|
||||
* Folder CSLID.
|
||||
* @return
|
||||
* Special folder path.
|
||||
*/
|
||||
public static String getFolderPath(int nFolder) {
|
||||
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
|
||||
}
|
||||
}
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário